Skip to content

Commit

Permalink
Merge pull request #233 from xcompact3d/restart_validation_optional
Browse files Browse the repository at this point in the history
Make the validation of the restart optional
  • Loading branch information
pbartholomew08 authored Oct 19, 2023
2 parents ff75dab + aba14c5 commit 8d7b078
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 42 deletions.
1 change: 1 addition & 0 deletions src/module_param.f90
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ module param
real(mytype) :: dens1, dens2
real(mytype) :: C_filter
character(len=512) :: inflowpath
logical :: validation_restart

! Logical, true when synchronization is needed
logical, save :: sync_vel_needed = .true.
Expand Down
4 changes: 3 additions & 1 deletion src/parameters.f90
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ subroutine parameter(input_i3d)
NAMELIST /NumOptions/ ifirstder, isecondder, itimescheme, iimplicit, &
nu0nu, cnu, ipinter
NAMELIST /InOutParam/ irestart, icheckpoint, ioutput, nvisu, ilist, iprocessing, &
ninflows, ntimesteps, inflowpath, ioutflow, output2D, nprobes
ninflows, ntimesteps, inflowpath, ioutflow, output2D, nprobes, &
validation_restart
NAMELIST /Statistics/ wrotation,spinup_time, nstat, initstat, istatfreq
NAMELIST /ProbesParam/ flag_all_digits, flag_extra_probes, xyzprobes
NAMELIST /ScalarParam/ sc, ri, uset, cp, &
Expand Down Expand Up @@ -685,6 +686,7 @@ subroutine parameter_defaults()
ioutflow=0
output2D = 0
nprobes=0
validation_restart = .true.

!! PROBES
flag_all_digits = .false.
Expand Down
83 changes: 42 additions & 41 deletions src/tools.f90
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ subroutine restart(ux1,uy1,uz1,dux1,duy1,duz1,ep1,pp3,phi1,dphi1,px1,py1,pz1,rho

if (adios2_restart_initialised) then
! First, rename old checkpoint in case of error
call rename(resfile, resfile_old)
if (validation_restart) call rename(resfile, resfile_old)
end if
end if

Expand Down Expand Up @@ -315,46 +315,47 @@ subroutine restart(ux1,uy1,uz1,dux1,duy1,duz1,ep1,pp3,phi1,dphi1,px1,py1,pz1,rho
call decomp_2d_close_io(io_restart, resfile)

! Validate restart file then remove old file and update restart.info
if (validate_restart(resfile_old, resfile)) then
call delete_filedir(resfile_old)

! Write info file for restart - Kay Schäfer
if (nrank == 0) then
write(filename,"('restart.info')")
write(fmt2,'("(A,I16)")')
write(fmt3,'("(A,F16.4)")')
write(fmt4,'("(A,F16.12)")')
!
open (111,file=filename,action='write',status='replace')
write(111,'(A)')'!========================='
write(111,'(A)')'&Time'
write(111,'(A)')'!========================='
write(111,fmt3) 'tfield= ',t
write(111,fmt2) 'itime= ',itime
write(111,'(A)')'/End'
write(111,'(A)')'!========================='
write(111,'(A)')'&NumParam'
write(111,'(A)')'!========================='
write(111,fmt2) 'nx= ',nx
write(111,fmt2) 'ny= ',ny
write(111,fmt2) 'nz= ',nz
write(111,fmt3) 'Lx= ',xlx
write(111,fmt3) 'Ly= ',yly
write(111,fmt3) 'Lz= ',zlz
write(111,fmt2) 'istret= ',istret
write(111,fmt4) 'beta= ',beta
write(111,fmt2) 'iscalar= ',iscalar
write(111,fmt2) 'numscalar=',numscalar
write(111,'(A,I14)') 'itimescheme=',itimescheme
write(111,fmt2) 'iimplicit=',iimplicit
write(111,'(A)')'/End'
write(111,'(A)')'!========================='

close(111)
end if
else
call decomp_2d_abort(1, &
"Writing restart - validation failed!")
if (validation_restart) then
if (validate_restart(resfile_old, resfile)) then
call delete_filedir(resfile_old)
else
call decomp_2d_abort(1, "Writing restart - validation failed!")
endif
endif

! Write info file for restart - Kay Schäfer
if (nrank == 0) then
write(filename,"('restart.info')")
write(fmt2,'("(A,I16)")')
write(fmt3,'("(A,F16.4)")')
write(fmt4,'("(A,F16.12)")')
!
open (111,file=filename,action='write',status='replace')
write(111,'(A)')'!========================='
write(111,'(A)')'&Time'
write(111,'(A)')'!========================='
write(111,fmt3) 'tfield= ',t
write(111,fmt2) 'itime= ',itime
write(111,'(A)')'/End'
write(111,'(A)')'!========================='
write(111,'(A)')'&NumParam'
write(111,'(A)')'!========================='
write(111,fmt2) 'nx= ',nx
write(111,fmt2) 'ny= ',ny
write(111,fmt2) 'nz= ',nz
write(111,fmt3) 'Lx= ',xlx
write(111,fmt3) 'Ly= ',yly
write(111,fmt3) 'Lz= ',zlz
write(111,fmt2) 'istret= ',istret
write(111,fmt4) 'beta= ',beta
write(111,fmt2) 'iscalar= ',iscalar
write(111,fmt2) 'numscalar=',numscalar
write(111,'(A,I14)') 'itimescheme=',itimescheme
write(111,fmt2) 'iimplicit=',iimplicit
write(111,'(A)')'/End'
write(111,'(A)')'!========================='

close(111)
end if
else
if (nrank==0) then
Expand Down

0 comments on commit 8d7b078

Please sign in to comment.