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
13 changes: 9 additions & 4 deletions cicecore/cicedyn/infrastructure/io/io_binary/ice_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ module ice_restart

use ice_broadcast
use ice_kinds_mod
use ice_restart_shared, only: &
restart, restart_ext, restart_dir, restart_file, pointer_file, &
runid, runtype, use_restart_time, lenstr
use ice_restart_shared
use ice_communicate, only: my_task, master_task
use ice_fileunits, only: nu_diag, nu_rst_pointer
use ice_fileunits, only: nu_dump, nu_dump_eap, nu_dump_FY, nu_dump_age
Expand Down Expand Up @@ -396,6 +394,7 @@ subroutine init_restart_write(filename_spec)
nbtrcr ! number of bgc tracers

character(len=char_len_long) :: filename
character(len=char_len_long) :: lpointer_file

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

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

! write pointer (path/file)
if (my_task == master_task) then
open(nu_rst_pointer,file=pointer_file)
lpointer_file = pointer_file
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)
if (restart_ext) then
Expand Down
14 changes: 9 additions & 5 deletions cicecore/cicedyn/infrastructure/io/io_netcdf/ice_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ module ice_restart
use netcdf
#endif
use ice_read_write, only: ice_check_nc
use ice_restart_shared, only: &
restart_ext, restart_dir, restart_file, pointer_file, &
runid, use_restart_time, lenstr, restart_coszen, restart_format, &
restart_chunksize, restart_deflate
use ice_restart_shared
use ice_fileunits, only: nu_diag, nu_rst_pointer
use ice_exit, only: abort_ice
use icepack_intfc, only: icepack_query_parameters
Expand Down Expand Up @@ -168,6 +165,7 @@ subroutine init_restart_write(filename_spec)
nbtrcr ! number of bgc tracers

character(len=char_len_long) :: filename
character(len=char_len_long) :: lpointer_file

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

Expand Down Expand Up @@ -214,7 +212,13 @@ subroutine init_restart_write(filename_spec)
! write pointer (path/file)
if (my_task == master_task) then
filename = trim(filename) // '.nc'
open(nu_rst_pointer,file=pointer_file)
lpointer_file = pointer_file
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: 8 additions & 4 deletions cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,20 @@ subroutine init_restart_write(filename_spec)
myear,'-',mmonth,'-',mday,'-',msec
end if

if (restart_format(1:3) /= 'bin') filename = trim(filename) // '.nc'
filename = trim(filename) // '.nc'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious about this change. I guess binary restart is only supported with the io_binary package? What happens if binary is set with io_netcdf and io_pio2? Should there be an abort if restart_format = 'bin'? Are there equivalent issues with history format? As an aside, I have wanted to merge the three io_ directories for years and support binary, netcdf, or pio all at the same time via run-time settings, but it would be a big project.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if statement didn't really make any sense, so i removed it as the io_binary code isn't included if using pio.

What happens if binary is set with io_netcdf and io_pio2? Should there be an abort if restart_format = 'bin'? Are there equivalent issues with history format?

I don't think there is any error handling of this.


! 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 @@ -329,6 +330,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