Skip to content

Commit

Permalink
new checkpointing mode
Browse files Browse the repository at this point in the history
  • Loading branch information
p-costa committed Mar 5, 2022
1 parent 9b71165 commit 810f723
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/__MULTI_BLOCK_GEOMETRY/kovasznay_flow/dns.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
1. 1. .025 ! uref, lref, rey
50000 100. 0.1 ! nstep,time_max,tw_max
T F F ! stop_type(1:3)
F T ! restart,is_overwrite_save
F T 0 ! restart,is_overwrite_save,nsaves_max
10 10 200000 50000000 100 200 ! icheck, iout0d, iout1d, iout2d, iout3d, isave
0. 0. 0. ! bforce(1:3)
4 ! nthreadsmax
2 changes: 2 additions & 0 deletions src/INFO_INPUT.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ a checkpoint file `fld.bin` will be saved before the simulation is terminated.

`is_overwrite_save`, if true, overwrites the checkpoint file `fld.bin` at every save; if false, a symbolic link is created which makes `fld.bin` point to the last checkpoint file with name `fld_???????.bin`. In the latter case, to restart a run from a different checkpoint one just has to point the file `fld.bin` to the right file, e.g.: ` ln -sf fld_0000100.bin fld.bin`.

`nsaves_max` limits the number of saved checkpoint files, if `is_over_write_save` is false; a value of `0` or any negative integer corresponds to no limit, and the code uses the file format described above; otherwise, only `nsaves_max` checkpoint files are saved, with the oldest save being overwritten when the number of saved checkpoints exceeds this threshold; in this case, files with a format `fld_????.bin` are saved (with `????` denoting the saved file number), with `fld.bin` pointing to the last checkpoint file as described above; moreover, a file `log_saves.out` records information about the time step number and physical time corresponding to each saved file number.

---

~~~
Expand Down
2 changes: 1 addition & 1 deletion src/dns.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
1. 1. 100. ! uref, lref, rey
100 100. 0.1 ! nstep,time_max,tw_max
T F F ! stop_type(1:3)
F T ! restart,is_overwrite_save
F T 0 ! restart,is_overwrite_save,nsaves_max
10 10 200000 50000000 10 20 ! icheck, iout0d, iout1d, iout2d, iout3d, isave
0. 0. 0. ! bforce(1:3)
4 ! nthreadsmax
16 changes: 14 additions & 2 deletions src/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ program snac
rkcoeff, &
cfl,dtmin,uref,lref,rey,visc, &
nstep,time_max,tw_max,stop_type, &
restart,is_overwrite_save, &
restart,is_overwrite_save,nsaves_max, &
nthreadsmax, &
icheck,iout0d,iout1d,iout2d,iout3d,isave, &
dims,lo,hi,lmin,lmax, &
Expand Down Expand Up @@ -171,10 +171,12 @@ program snac
real(rp), dimension(100) :: var
character(len=3 ) :: cblock
character(len=7 ) :: fldnum
character(len=4 ) :: chkptnum
character(len=100) :: filename
integer :: iunit
!
real(rp) :: twi,tw
integer :: savecounter
logical :: is_done,kill
#ifdef _TIMING
real(rp) :: dt12,dt12av,dt12min,dt12max
Expand All @@ -184,6 +186,7 @@ program snac
call MPI_INIT()
call MPI_COMM_RANK(MPI_COMM_WORLD, myid)
twi = MPI_WTIME()
savecounter = 0
!
! read parameter file
!
Expand Down Expand Up @@ -1065,7 +1068,16 @@ program snac
if(is_overwrite_save) then
filename = 'fld_b_'//cblock//'.bin'
else
filename = 'fld_'//fldnum//'_b_'//cblock//'.bin'
if(nsaves_max > 0) then
if(savecounter >= nsaves_max) savecounter = 0
savecounter = savecounter + 1
write(chkptnum,'(i4.4)') savecounter
filename = 'fld_'//chkptnum//'_b_'//cblock//'.bin'
var(1) = 1.*istep
var(2) = time
var(3) = 1.*savecounter
call out0d(trim(datadir)//'log_saves.out',3,myid,var)
endif
end if
call load('w',trim(datadir)//trim(filename),comm_block,ng,[1,1,1],lo_1,hi_1,u,v,w,p,po,time,istep)
if(.not.is_overwrite_save) then
Expand Down
3 changes: 2 additions & 1 deletion src/param.f90
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module mod_param
real(rp) :: time_max,tw_max
logical , dimension(3) :: stop_type
logical :: restart,is_overwrite_save
integer :: nsaves_max
integer :: icheck,iout0d,iout1d,iout2d,iout3d,isave
real(rp), dimension(3) :: bforce
integer :: nthreadsmax
Expand Down Expand Up @@ -69,7 +70,7 @@ subroutine read_input()
read(iunit,*) uref,lref,rey
read(iunit,*) nstep, time_max,tw_max
read(iunit,*) stop_type(1),stop_type(2),stop_type(3)
read(iunit,*) restart,is_overwrite_save
read(iunit,*) restart,is_overwrite_save,nsaves_max
read(iunit,*) icheck,iout0d,iout1d,iout2d,iout3d,isave
read(iunit,*) bforce(1),bforce(2),bforce(3)
read(iunit,*) nthreadsmax
Expand Down
2 changes: 1 addition & 1 deletion tests/lid_driven_cavity/dns.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
1. 1. 1000. ! uref, lref, rey
1500 100. 0.1 ! nstep,time_max,tw_max
T F F ! stop_type(1:3)
F T ! restart,is_overwrite_save
F T 0 ! restart,is_overwrite_save,nsaves_max
10 10 20 500 500 2000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave
0. 0. 0. ! bforce(1:3)
4 ! nthreadsmax

0 comments on commit 810f723

Please sign in to comment.