Skip to content

Commit

Permalink
Merge pull request #354 from sfiligoi/restart_2403
Browse files Browse the repository at this point in the history
Add RESTART_PRESERVATION_MODE input option. Defaults to 3.
  • Loading branch information
jcandy authored Mar 4, 2024
2 parents 5d10cfd + d9360ca commit f001bf8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions cgyro/bin/cgyro_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
x.add('MAX_TIME','100.0')
x.add('PRINT_STEP','100')
x.add('RESTART_STEP','10')
x.add('RESTART_PRESERVATION_MODE','3')
x.add('FREQ_TOL','0.001')
x.add('UP_RADIAL','1.0')
x.add('UP_THETA','1.0')
Expand Down
1 change: 1 addition & 0 deletions cgyro/src/cgyro_globals.F90
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module cgyro_globals
real :: max_time
integer :: print_step
integer :: restart_step
integer :: restart_preservation_mode
real :: freq_tol
real :: up_radial
real :: up_theta
Expand Down
1 change: 1 addition & 0 deletions cgyro/src/cgyro_read_input.f90
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ subroutine cgyro_read_input
call cgyro_readbc_real(max_time)
call cgyro_readbc_int(print_step,'PRINT_STEP')
call cgyro_readbc_int(restart_step,'RESTART_STEP')
call cgyro_readbc_int(restart_preservation_mode,'RESTART_PRESERVATION_MODE')
call cgyro_readbc_real(freq_tol)
call cgyro_readbc_real(up_radial)
call cgyro_readbc_real(up_theta)
Expand Down
26 changes: 23 additions & 3 deletions cgyro/src/cgyro_write_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ subroutine cgyro_write_restart_one
return
endif

if ((i_proc == 0) .and. (restart_preservation_mode<4)) then
! Anything but restart_preservation_mode == 4
! User does not want high guarntees for the old file
! So, remove .old file, if it exists
call UNLINK(trim(path)//runfile_restart//".old")
! NOTE: We will not check if it succeeded... not important, may not even exist (yet)
endif

if ((i_proc == 0) .and. (restart_preservation_mode<2)) then
! restart_preservation_mode == 1
! User wants to save disk space
! So, remove existing restart file, if it exists
call UNLINK(trim(path)//runfile_restart)
! NOTE: We will not check if it succeeded... not important, may not even exist (yet)
endif

! TODO Error handling
call MPI_INFO_CREATE(finfo,i_err)

Expand Down Expand Up @@ -167,10 +183,14 @@ subroutine cgyro_write_restart_one

! now that we know things worked well, move the file in its final location
if (i_proc == 0) then
! but first try to save any existing file
i_err = RENAME(trim(path)//runfile_restart, trim(path)//runfile_restart//".old")
! NOTE: We will not check if it succeeded... not important, may not even exist (yet)
if (restart_preservation_mode>2) then
! restart_preservation_mode == 3 or 4
! First try to save any existing restart file as old
i_err = RENAME(trim(path)//runfile_restart, trim(path)//runfile_restart//".old")
! NOTE: We will not check if it succeeded... not important, may not even exist (yet)
endif

! Rename part into the final expected file name
i_err = RENAME(trim(path)//runfile_restart//".part", trim(path)//runfile_restart)
if (i_err /= 0) then
call cgyro_error('Final rename in cgyro_write_restart failed')
Expand Down

0 comments on commit f001bf8

Please sign in to comment.