Skip to content

Commit b010325

Browse files
anton-seaiceaekissdougiesquire
authored
NUOPC/CMEPS only: Make datestamps in pointer filenames configurable (#9) (CICE-Consortium#1031)
This adds support in NUOPC/CMEPS driver for the addition of datestamps to the pointer filenames to be configurable through the nuopc option restart_pointer_append_date . This is a companion change to ESCOMP/CESM_share#70, and does not impact any current default behaviour. * Make datestamps in pointer filenames configurable (#9) * set across all io options consistently * use ice_restart_shared consistently across all 3 methods --------- Co-authored-by: Andrew Kiss <31054815+aekiss@users.noreply.github.com> Co-authored-by: Dougie Squire <42455466+dougiesquire@users.noreply.github.com>
1 parent b4a6c44 commit b010325

File tree

5 files changed

+40
-14
lines changed

5 files changed

+40
-14
lines changed

cicecore/cicedyn/infrastructure/io/io_binary/ice_restart.F90

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ module ice_restart
99

1010
use ice_broadcast
1111
use ice_kinds_mod
12-
use ice_restart_shared, only: &
13-
restart, restart_ext, restart_dir, restart_file, pointer_file, &
14-
runid, runtype, use_restart_time, lenstr
12+
use ice_restart_shared
1513
use ice_communicate, only: my_task, master_task
1614
use ice_fileunits, only: nu_diag, nu_rst_pointer
1715
use ice_fileunits, only: nu_dump, nu_dump_eap, nu_dump_FY, nu_dump_age
@@ -396,6 +394,7 @@ subroutine init_restart_write(filename_spec)
396394
nbtrcr ! number of bgc tracers
397395

398396
character(len=char_len_long) :: filename
397+
character(len=char_len_long) :: lpointer_file
399398

400399
character(len=*), parameter :: subname = '(init_restart_write)'
401400

@@ -422,7 +421,13 @@ subroutine init_restart_write(filename_spec)
422421

423422
! write pointer (path/file)
424423
if (my_task == master_task) then
425-
open(nu_rst_pointer,file=pointer_file)
424+
lpointer_file = pointer_file
425+
if (pointer_date) then
426+
! append date to pointer filename
427+
write(lpointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') &
428+
trim(lpointer_file)//'.',myear,'-',mmonth,'-',mday,'-',msec
429+
end if
430+
open(nu_rst_pointer,file=lpointer_file)
426431
write(nu_rst_pointer,'(a)') filename
427432
close(nu_rst_pointer)
428433
if (restart_ext) then

cicecore/cicedyn/infrastructure/io/io_netcdf/ice_restart.F90

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ module ice_restart
1616
use netcdf
1717
#endif
1818
use ice_read_write, only: ice_check_nc
19-
use ice_restart_shared, only: &
20-
restart_ext, restart_dir, restart_file, pointer_file, &
21-
runid, use_restart_time, lenstr, restart_coszen, restart_format, &
22-
restart_chunksize, restart_deflate
19+
use ice_restart_shared
2320
use ice_fileunits, only: nu_diag, nu_rst_pointer
2421
use ice_exit, only: abort_ice
2522
use icepack_intfc, only: icepack_query_parameters
@@ -168,6 +165,7 @@ subroutine init_restart_write(filename_spec)
168165
nbtrcr ! number of bgc tracers
169166

170167
character(len=char_len_long) :: filename
168+
character(len=char_len_long) :: lpointer_file
171169

172170
integer (kind=int_kind), allocatable :: dims(:)
173171

@@ -215,7 +213,13 @@ subroutine init_restart_write(filename_spec)
215213
! write pointer (path/file)
216214
if (my_task == master_task) then
217215
filename = trim(filename) // '.nc'
218-
open(nu_rst_pointer,file=pointer_file)
216+
lpointer_file = pointer_file
217+
if (pointer_date) then
218+
! append date to pointer filename
219+
write(lpointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') &
220+
trim(lpointer_file)//'.',myear,'-',mmonth,'-',mday,'-',msec
221+
end if
222+
open(nu_rst_pointer,file=lpointer_file)
219223
write(nu_rst_pointer,'(a)') filename
220224
close(nu_rst_pointer)
221225

cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,20 @@ subroutine init_restart_write(filename_spec)
220220
myear,'-',mmonth,'-',mday,'-',msec
221221
end if
222222

223-
if (restart_format(1:3) /= 'bin') filename = trim(filename) // '.nc'
223+
filename = trim(filename) // '.nc'
224224

225225
! write pointer (path/file)
226226
if (my_task == master_task) then
227-
#ifdef CESMCOUPLED
228-
write(lpointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') &
229-
'rpointer.ice'//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec
227+
#ifdef CESMCOUPLED
228+
lpointer_file = 'rpointer.ice'//trim(inst_suffix)
230229
#else
231230
lpointer_file = pointer_file
232231
#endif
232+
if (pointer_date) then
233+
! append date to pointer filename
234+
write(lpointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') &
235+
trim(lpointer_file)//'.',myear,'-',mmonth,'-',mday,'-',msec
236+
end if
233237
open(nu_rst_pointer,file=lpointer_file)
234238
write(nu_rst_pointer,'(a)') filename
235239
close(nu_rst_pointer)

cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ module ice_comp_nuopc
3030
use ice_kinds_mod , only : dbl_kind, int_kind, char_len, char_len_long
3131
use ice_fileunits , only : nu_diag, nu_diag_set, inst_index, inst_name
3232
use ice_fileunits , only : inst_suffix, release_all_fileunits, flush_fileunit
33-
use ice_restart_shared , only : runid, runtype, restart, use_restart_time, restart_dir, restart_file, restart_format, restart_chunksize
33+
use ice_restart_shared , only : runid, runtype, restart, use_restart_time, restart_dir, restart_file, &
34+
restart_format, restart_chunksize, pointer_date
3435
use ice_history , only : accum_hist
3536
use ice_history_shared , only : history_format, history_chunksize
3637
use ice_exit , only : abort_ice
@@ -329,6 +330,15 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
329330
if (trim(cvalue) .eq. '.true.') restart_eor = .true.
330331
endif
331332

333+
#ifdef CESMCOUPLED
334+
pointer_date = .true.
335+
#endif
336+
337+
! set CICE internal pointer_date variable based on nuopc settings
338+
! this appends a datestamp to the "rpointer" file
339+
call NUOPC_CompAttributeGet(gcomp, name="restart_pointer_append_date", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
340+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
341+
if (isPresent .and. isSet) pointer_date = (trim(cvalue) .eq. ".true.")
332342
!----------------------------------------------------------------------------
333343
! generate local mpi comm
334344
!----------------------------------------------------------------------------

cicecore/shared/ice_restart_shared.F90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ module ice_restart_shared
2525
character (len=char_len_long), public :: &
2626
pointer_file ! input pointer file for restarts
2727

28+
logical (kind=log_kind), public :: &
29+
pointer_date = .false. ! if true, append datestamp to pointer file
30+
2831
character (len=char_len), public :: &
2932
restart_format , & ! format of restart files 'nc'
3033
restart_rearranger ! restart file rearranger, box or subset for pio

0 commit comments

Comments
 (0)