diff --git a/cgyro/bin/cgyro_parse.py b/cgyro/bin/cgyro_parse.py index 3add3d21b..57b16d134 100644 --- a/cgyro/bin/cgyro_parse.py +++ b/cgyro/bin/cgyro_parse.py @@ -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') diff --git a/cgyro/src/cgyro_globals.F90 b/cgyro/src/cgyro_globals.F90 index 988bde474..698589963 100644 --- a/cgyro/src/cgyro_globals.F90 +++ b/cgyro/src/cgyro_globals.F90 @@ -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 diff --git a/cgyro/src/cgyro_read_input.f90 b/cgyro/src/cgyro_read_input.f90 index 047d20e37..00449bbef 100644 --- a/cgyro/src/cgyro_read_input.f90 +++ b/cgyro/src/cgyro_read_input.f90 @@ -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) diff --git a/cgyro/src/cgyro_write_restart.F90 b/cgyro/src/cgyro_write_restart.F90 index 234223004..991ab8b9b 100644 --- a/cgyro/src/cgyro_write_restart.F90 +++ b/cgyro/src/cgyro_write_restart.F90 @@ -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) @@ -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')