Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions config_src/drivers/nuopc_cap/mom_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1943,12 +1943,14 @@ subroutine ModelAdvance(gcomp, rc)
msg=subname//' ERROR opening '//rpointer_filename, line=__LINE__, file=u_FILE_u, rcToReturn=rc)
return
endif
if (len_trim(inst_suffix) == 0) then
write(writeunit,'(a)') trim(restartname)//'.nc'
else
write(writeunit,'(a)') trim(restartname)//'.'//trim(inst_suffix)//'.nc'

! update restart file name to include the instance suffix
if (len_trim(inst_suffix) > 0) then
write(restartname, '(A,".mom6",A,".r",A)') trim(casename), trim(inst_suffix), timestamp
endif

write(writeunit,'(a)') trim(restartname)//'.nc'

if (num_rest_files > 1) then
! append i.th restart file name to rpointer
do i=1, num_rest_files-1
Expand Down
33 changes: 29 additions & 4 deletions src/framework/MOM_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ module MOM_restart
type(p4d), pointer :: var_ptr4d(:) => NULL()
!>@}
integer :: max_fields !< The maximum number of restart fields
character(len=32) :: restartfile_appx_prefix !< The prefix for the restart file appendix (i.e., ensemble id)
end type MOM_restart_CS

!> Register fields for restarts
Expand Down Expand Up @@ -1613,6 +1614,8 @@ subroutine save_restart(directory, time, G, CS, time_stamped, filename, GV, num_
integer :: turns ! Number of quarter turns from input to model domain
integer, parameter :: nmax_extradims = 5
type(axis_info), dimension(:), allocatable :: extra_axes
integer :: prefix_index ! The index of the first occurrence of prefix in the restart filename.
integer :: prefix_length ! The length of the prefix string.

turns = CS%turns

Expand Down Expand Up @@ -1654,10 +1657,26 @@ subroutine save_restart(directory, time, G, CS, time_stamped, filename, GV, num_
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)

! Determine if a valid prefix for appendix is provided.
prefix_index = 0
prefix_length = len_trim(CS%restartfile_appx_prefix)
if (prefix_length > 0) prefix_index = index(restartname, trim(CS%restartfile_appx_prefix))

if (prefix_index == 0) then ! No prefix is found
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
else ! Prefix is found
if (restartname(length-2:length) == '.nc') then
restartname = restartname(1:prefix_index-1+prefix_length) // &
trim(filename_appendix) // restartname(prefix_index+prefix_length:length-3) // '.nc'
else
restartname = restartname(1:prefix_index-1+prefix_length) // &
trim(filename_appendix) // restartname(prefix_index+prefix_length:)
endif
endif
endif

Expand Down Expand Up @@ -2304,6 +2323,12 @@ subroutine restart_init(param_file, CS, restart_root)
"made from a run with a different mask_table than the current run, "//&
"in which case the checksums will not match and cause crash.",&
default=.true.)
call get_param(param_file, mdl, "RESTARTFILE_APPENDIX_PREFIX", CS%restartfile_appx_prefix, &
"The prefix for the restart file appendix (i.e., ensemble id for ensemble runs). "// &
"If this prefix is found in the restart file name, the appendix is added right after the "// &
"first occurrence of the prefix. If not found, the appendix is added to the end of the "// &
"file name. This parameter is ignored for non-ensemble runs.", &
default="")
call get_param(param_file, mdl, "RESTART_SYMMETRIC_CHECKSUMS", CS%symmetric_checksums, &
"If true, do the restart checksums on all the edge points for a non-reentrant "//&
"grid. This requires that SYMMETRIC_MEMORY_ is defined at compile time.", &
Expand Down