Skip to content

Commit

Permalink
Make datestamps in pointer filenames configurable (#9)
Browse files Browse the repository at this point in the history
This adds support in cice for the addition of datestamps to the pointer filenames to be configured through the nuopc option restart_pointer_append_date .

Co-authored-by: Andrew Kiss <[email protected]>
Co-authored-by: Dougie Squire <[email protected]>
  • Loading branch information
3 people authored Jan 24, 2025
1 parent 0d9e0d3 commit e68e05b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
10 changes: 7 additions & 3 deletions cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,16 @@ subroutine init_restart_write(filename_spec)

! write pointer (path/file)
if (my_task == master_task) then
#ifdef CESMCOUPLED
write(lpointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') &
'rpointer.ice'//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec
#ifdef CESMCOUPLED
lpointer_file = 'rpointer.ice'//trim(inst_suffix)
#else
lpointer_file = pointer_file
#endif
if (pointer_date) then
! append date to pointer filename
write(lpointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') &
trim(lpointer_file)//'.',myear,'-',mmonth,'-',mday,'-',msec
end if
open(nu_rst_pointer,file=lpointer_file)
write(nu_rst_pointer,'(a)') filename
close(nu_rst_pointer)
Expand Down
12 changes: 11 additions & 1 deletion cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ module ice_comp_nuopc
use ice_kinds_mod , only : dbl_kind, int_kind, char_len, char_len_long
use ice_fileunits , only : nu_diag, nu_diag_set, inst_index, inst_name
use ice_fileunits , only : inst_suffix, release_all_fileunits, flush_fileunit
use ice_restart_shared , only : runid, runtype, restart, use_restart_time, restart_dir, restart_file, restart_format, restart_chunksize
use ice_restart_shared , only : runid, runtype, restart, use_restart_time, restart_dir, restart_file, &
restart_format, restart_chunksize, pointer_date
use ice_history , only : accum_hist
use ice_history_shared , only : history_format, history_chunksize
use ice_exit , only : abort_ice
Expand Down Expand Up @@ -323,6 +324,15 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
if (trim(cvalue) .eq. '.true.') restart_eor = .true.
endif

#ifdef CESMCOUPLED
pointer_date = .true.
#endif

! set CICE internal pointer_date variable based on nuopc settings
! this appends a datestamp to the "rpointer" file
call NUOPC_CompAttributeGet(gcomp, name="restart_pointer_append_date", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) pointer_date = (trim(cvalue) .eq. ".true.")
!----------------------------------------------------------------------------
! generate local mpi comm
!----------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions cicecore/shared/ice_restart_shared.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ module ice_restart_shared
character (len=char_len_long), public :: &
pointer_file ! input pointer file for restarts

logical (kind=log_kind), public :: &
pointer_date = .false. ! if true, append datestamp to pointer file

character (len=char_len), public :: &
restart_format , & ! format of restart files 'nc'
restart_rearranger ! restart file rearranger, box or subset for pio
Expand Down

0 comments on commit e68e05b

Please sign in to comment.