Skip to content

Commit

Permalink
Fix issue with restart filenames when using ensembles.
Browse files Browse the repository at this point in the history
Moved call for filename_appendix outside of loop.

Fixes issue where restart filename was
./MOM.res.ens_01.nc
./MOM.res.ens_01.ens_01_1.nc
./MOM.res.ens_01.ens_01.ens_01_2.nc
./MOM.res.ens_01.ens_01.ens_01.ens_01_3.nc

instead of
./MOM.res.ens_01.nc
./MOM.res.ens_01_1.nc
./MOM.res.ens_01_2.nc
./MOM.res.ens_01_3.nc
  • Loading branch information
wfcooke committed Feb 1, 2024
1 parent 414510e commit 2698ef2
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/framework/MOM_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,17 @@ subroutine save_restart(directory, time, G, CS, time_stamped, filename, GV, num_
restartname = trim(CS%restartfile)//trim(restartname)
endif ; endif

! Determine if there is a filename_appendix (used for ensemble runs).
call get_filename_appendix(filename_appendix)
if (len_trim(filename_appendix) > 0) then
length = len_trim(restartname)
if (restartname(length-2:length) == '.nc') then
restartname = restartname(1:length-3)//'.'//trim(filename_appendix)//'.nc'
else
restartname = restartname(1:length) //'.'//trim(filename_appendix)
endif
endif

next_var = 1
do while (next_var <= CS%novars )
start_var = next_var
Expand All @@ -1430,17 +1441,6 @@ subroutine save_restart(directory, time, G, CS, time_stamped, filename, GV, num_
enddo
next_var = m

! Determine if there is a filename_appendix (used for ensemble runs).
call get_filename_appendix(filename_appendix)
if (len_trim(filename_appendix) > 0) then
length = len_trim(restartname)
if (restartname(length-2:length) == '.nc') then
restartname = restartname(1:length-3)//'.'//trim(filename_appendix)//'.nc'
else
restartname = restartname(1:length) //'.'//trim(filename_appendix)
endif
endif

restartpath = trim(directory) // trim(restartname)

if (num_files < 10) then
Expand Down

0 comments on commit 2698ef2

Please sign in to comment.