Skip to content

Commit a50763e

Browse files
committed
CFL restarts: don't overwrite the restart checkpoint on the first step
CFL mode saved when abs(mod(mytime, t_save)) < dt. A restart starts at exactly n_start*t_save, so after the first step mod(mytime, t_save) is within an ulp of dt and falls below it about half the time. The save then writes index int(mytime/t_save) = n_start and replaces the restart checkpoint with the state one step later. Save instead when int(mytime/t_save), the index s_save_data writes, moves past the last saved index (n_start at start), or at t_stop. Fresh-run saves happen at the same steps as before. The CFL restart test restarts from save indices 1-4 and checks that each restart leaves its own checkpoint byte-identical.
1 parent 078f9d3 commit a50763e

6 files changed

Lines changed: 303 additions & 5 deletions

File tree

‎src/simulation/p_main.fpp‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ program p_main
1212

1313
implicit none
1414

15-
integer :: t_step !< Iterator for the time-stepping loop
15+
integer :: t_step !< Iterator for the time-stepping loop
1616
real(wp) :: time_avg, time_final
1717
real(wp) :: io_time_avg, io_time_final
1818
real(wp), allocatable, dimension(:) :: proc_time
1919
real(wp), allocatable, dimension(:) :: io_proc_time
2020
logical :: file_exists
2121
real(wp) :: start, finish
2222
integer :: nt
23+
integer :: last_save !< Index of the last CFL-mode save
2324

2425
call system_clock(COUNT=cpu_start, COUNT_RATE=cpu_rate)
2526

@@ -47,6 +48,7 @@ program p_main
4748
t_step = 0
4849
t_step_start = 0
4950
mytime = t_save*n_start
51+
last_save = n_start
5052
else
5153
t_step = t_step_start
5254
if (t_step == 0) then
@@ -78,8 +80,10 @@ program p_main
7880
call s_perform_time_step(t_step, time_avg)
7981

8082
if (cfl_dt) then
81-
if (abs(mod(mytime, t_save)) < dt .or. mytime >= t_stop) then
83+
! Save once per index; a mod(mytime, t_save) < dt test can refire on a restart and overwrite n_start
84+
if (int(mytime/t_save) > last_save .or. mytime >= t_stop) then
8285
call s_save_data(t_step, start, finish, io_time_avg, nt)
86+
last_save = int(mytime/t_save)
8387
end if
8488
else
8589
if (mod(t_step - t_step_start, t_step_save) == 0 .or. t_step == t_step_stop) then

‎tests/25EB3D1F/golden-metadata.txt‎

Lines changed: 191 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)