From 56dc381243119192c245e74eeea8a19b5b5f3b9b Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 17 Oct 2024 11:14:20 -0600 Subject: [PATCH 01/10] support for cesm write_restart_at_endofrun --- .../infrastructure/io/io_pio2/ice_restart.F90 | 13 +++-- .../drivers/nuopc/cmeps/ice_comp_nuopc.F90 | 50 +++++++++---------- .../drivers/nuopc/cmeps/ice_shr_methods.F90 | 11 +++- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 index 2d98716b2..3ac98fdf1 100644 --- a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 @@ -163,7 +163,7 @@ subroutine init_restart_write(filename_spec) logical (kind=log_kind) :: & tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero, & - tr_pond_topo, tr_pond_lvl, tr_brine, tr_snow, & + tr_pond_topo, tr_pond_lvl, tr_pond_sealvl, tr_brine, tr_snow, & tr_bgc_N, tr_bgc_C, tr_bgc_Nit, & tr_bgc_Sil, tr_bgc_DMS, & tr_bgc_chl, tr_bgc_Am, & @@ -193,6 +193,7 @@ subroutine init_restart_write(filename_spec) tr_iage_out=tr_iage, tr_FY_out=tr_FY, tr_lvl_out=tr_lvl, & tr_iso_out=tr_iso, tr_aero_out=tr_aero, & tr_pond_topo_out=tr_pond_topo, tr_pond_lvl_out=tr_pond_lvl, & + tr_pond_sealvl_out=tr_pond_sealvl, & tr_snow_out=tr_snow, tr_brine_out=tr_brine, & tr_bgc_N_out=tr_bgc_N, tr_bgc_C_out=tr_bgc_C, tr_bgc_Nit_out=tr_bgc_Nit, & tr_bgc_Sil_out=tr_bgc_Sil, tr_bgc_DMS_out=tr_bgc_DMS, & @@ -214,6 +215,8 @@ subroutine init_restart_write(filename_spec) restart_dir(1:lenstr(restart_dir)), & restart_file(1:lenstr(restart_file)),'.', & myear,'-',mmonth,'-',mday,'-',msec + write(pointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & + 'rpointer.ice.',myear,'-',mmonth,'-',mday,'-',msec end if if (restart_format(1:3) /= 'bin') filename = trim(filename) // '.nc' @@ -333,7 +336,7 @@ subroutine init_restart_write(filename_spec) call define_rest_field(File,'a12_4',dims) endif - if (tr_pond_lvl) then + if (tr_pond_lvl .or. tr_pond_sealvl) then call define_rest_field(File,'fsnow',dims) endif @@ -425,7 +428,7 @@ subroutine init_restart_write(filename_spec) call define_rest_field(File,'ipnd',dims) end if - if (tr_pond_lvl) then + if (tr_pond_lvl .or. tr_pond_sealvl) then call define_rest_field(File,'apnd',dims) call define_rest_field(File,'hpnd',dims) call define_rest_field(File,'ipnd',dims) @@ -741,8 +744,6 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & call ice_pio_check(pio_inq_varndims(File, vardesc, ndims), & subname// " ERROR: missing varndims "//trim(vname),file=__FILE__,line=__LINE__) - call pio_seterrorhandling(File, PIO_INTERNAL_ERROR) - if (ndim3 == ncat .and. ndims == 3) then call pio_read_darray(File, vardesc, iodesc3d_ncat, work, status) #ifdef CESMCOUPLED @@ -770,6 +771,8 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & call ice_pio_check(status, & subname//" ERROR: reading var "//trim(vname),file=__FILE__,line=__LINE__) + call pio_seterrorhandling(File, PIO_INTERNAL_ERROR) + if (diag) then if (ndim3 > 1) then do n=1,ndim3 diff --git a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 index edf5d289a..213e3bb01 100644 --- a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 +++ b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 @@ -683,7 +683,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if(mastertask) write(nu_diag,*) trim(subname)//'WARNING: pio_typename from driver needs to be set for netcdf output to work' end if - + #else @@ -850,7 +850,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) idate0 = start_ymd year_init = (idate0/10000) month_init= (idate0-year_init*10000)/100 ! integer month of basedate - day_init = idate0-year_init*10000-month_init*100 + day_init = idate0-year_init*10000-month_init*100 ! - Set use_leap_years based on calendar (as some CICE calls use this instead of the calendar type) if (calendar_type == ice_calendar_gregorian) then @@ -892,7 +892,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! Prescribed ice initialization !----------------------------------------------------------------- - call ice_prescribed_init(gcomp, clock, ice_mesh, rc) + call ice_prescribed_init(clock, ice_mesh, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return #ifdef CESMCOUPLED @@ -1330,51 +1330,51 @@ subroutine ModelSetRunClock(gcomp, rc) call ESMF_LogWrite(subname//'setting alarms for ' // trim(name), ESMF_LOGMSG_INFO) !---------------- - ! Restart alarm + ! Stop alarm !---------------- - call NUOPC_CompAttributeGet(gcomp, name="restart_option", value=restart_option, rc=rc) + call NUOPC_CompAttributeGet(gcomp, name="stop_option", value=stop_option, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call NUOPC_CompAttributeGet(gcomp, name="restart_n", value=cvalue, rc=rc) + call NUOPC_CompAttributeGet(gcomp, name="stop_n", value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) restart_n + read(cvalue,*) stop_n - call NUOPC_CompAttributeGet(gcomp, name="restart_ymd", value=cvalue, rc=rc) + call NUOPC_CompAttributeGet(gcomp, name="stop_ymd", value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) restart_ymd + read(cvalue,*) stop_ymd - call alarmInit(mclock, restart_alarm, restart_option, & - opt_n = restart_n, & - opt_ymd = restart_ymd, & + call alarmInit(mclock, stop_alarm, stop_option, & + opt_n = stop_n, & + opt_ymd = stop_ymd, & RefTime = mcurrTime, & - alarmname = 'alarm_restart', rc=rc) + alarmname = 'alarm_stop', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_AlarmSet(restart_alarm, clock=mclock, rc=rc) + call ESMF_AlarmSet(stop_alarm, clock=mclock, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return !---------------- - ! Stop alarm + ! Restart alarm !---------------- - call NUOPC_CompAttributeGet(gcomp, name="stop_option", value=stop_option, rc=rc) + call NUOPC_CompAttributeGet(gcomp, name="restart_option", value=restart_option, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call NUOPC_CompAttributeGet(gcomp, name="stop_n", value=cvalue, rc=rc) + call NUOPC_CompAttributeGet(gcomp, name="restart_n", value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) stop_n + read(cvalue,*) restart_n - call NUOPC_CompAttributeGet(gcomp, name="stop_ymd", value=cvalue, rc=rc) + call NUOPC_CompAttributeGet(gcomp, name="restart_ymd", value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) stop_ymd + read(cvalue,*) restart_ymd - call alarmInit(mclock, stop_alarm, stop_option, & - opt_n = stop_n, & - opt_ymd = stop_ymd, & + call alarmInit(mclock, restart_alarm, restart_option, & + opt_n = restart_n, & + opt_ymd = restart_ymd, & RefTime = mcurrTime, & - alarmname = 'alarm_stop', rc=rc) + alarmname = 'alarm_restart', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_AlarmSet(stop_alarm, clock=mclock, rc=rc) + call ESMF_AlarmSet(restart_alarm, clock=mclock, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if diff --git a/cicecore/drivers/nuopc/cmeps/ice_shr_methods.F90 b/cicecore/drivers/nuopc/cmeps/ice_shr_methods.F90 index 65596d822..94a2f8b23 100644 --- a/cicecore/drivers/nuopc/cmeps/ice_shr_methods.F90 +++ b/cicecore/drivers/nuopc/cmeps/ice_shr_methods.F90 @@ -12,7 +12,7 @@ module ice_shr_methods use ESMF , only : ESMF_Mesh, ESMF_MeshGet use ESMF , only : ESMF_GEOMTYPE_MESH, ESMF_GEOMTYPE_GRID, ESMF_FIELDSTATUS_COMPLETE use ESMF , only : ESMF_Clock, ESMF_ClockCreate, ESMF_ClockGet, ESMF_ClockSet - use ESMF , only : ESMF_ClockPrint, ESMF_ClockAdvance + use ESMF , only : ESMF_ClockPrint, ESMF_ClockAdvance, ESMF_ClockGetAlarm use ESMF , only : ESMF_Alarm, ESMF_AlarmCreate, ESMF_AlarmGet, ESMF_AlarmSet use ESMF , only : ESMF_Calendar, ESMF_CALKIND_NOLEAP, ESMF_CALKIND_GREGORIAN use ESMF , only : ESMF_Time, ESMF_TimeGet, ESMF_TimeSet @@ -65,6 +65,7 @@ module ice_shr_methods optMonthly = "monthly" , & optYearly = "yearly" , & optDate = "date" , & + optEnd = "end" , & optIfdays0 = "ifdays0" ! Module data @@ -920,6 +921,14 @@ subroutine alarmInit( clock, alarm, option, & if (chkerr(rc,__LINE__,u_FILE_u)) return update_nextalarm = .true. + case (optEnd) + call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_ClockGetAlarm(clock, alarmname="alarm_stop", alarm=alarm, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_AlarmGet(alarm, ringTime=NextAlarm, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case default call abort_ice(subname//'unknown option '//trim(option)) From 11da279ba5b733250b061a769401328fabe9ca5c Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 17 Oct 2024 11:33:31 -0600 Subject: [PATCH 02/10] clean up merge --- .../infrastructure/io/io_pio2/ice_restart.F90 | 16 ++++++++-------- cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 | 6 ++---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 index 3ac98fdf1..48a767101 100644 --- a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 @@ -64,6 +64,8 @@ subroutine init_restart_read(ice_ic) filename = trim(ice_ic) else if (my_task == master_task) then + write(pointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & + trim(pointer_file)//'.',myear,'-',mmonth,'-',mday,'-',msec open(nu_rst_pointer,file=pointer_file) read(nu_rst_pointer,'(a)') filename0 filename = trim(filename0) @@ -163,7 +165,7 @@ subroutine init_restart_write(filename_spec) logical (kind=log_kind) :: & tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero, & - tr_pond_topo, tr_pond_lvl, tr_pond_sealvl, tr_brine, tr_snow, & + tr_pond_topo, tr_pond_lvl, tr_brine, tr_snow, & tr_bgc_N, tr_bgc_C, tr_bgc_Nit, & tr_bgc_Sil, tr_bgc_DMS, & tr_bgc_chl, tr_bgc_Am, & @@ -193,7 +195,6 @@ subroutine init_restart_write(filename_spec) tr_iage_out=tr_iage, tr_FY_out=tr_FY, tr_lvl_out=tr_lvl, & tr_iso_out=tr_iso, tr_aero_out=tr_aero, & tr_pond_topo_out=tr_pond_topo, tr_pond_lvl_out=tr_pond_lvl, & - tr_pond_sealvl_out=tr_pond_sealvl, & tr_snow_out=tr_snow, tr_brine_out=tr_brine, & tr_bgc_N_out=tr_bgc_N, tr_bgc_C_out=tr_bgc_C, tr_bgc_Nit_out=tr_bgc_Nit, & tr_bgc_Sil_out=tr_bgc_Sil, tr_bgc_DMS_out=tr_bgc_DMS, & @@ -215,14 +216,14 @@ subroutine init_restart_write(filename_spec) restart_dir(1:lenstr(restart_dir)), & restart_file(1:lenstr(restart_file)),'.', & myear,'-',mmonth,'-',mday,'-',msec - write(pointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & - 'rpointer.ice.',myear,'-',mmonth,'-',mday,'-',msec end if if (restart_format(1:3) /= 'bin') filename = trim(filename) // '.nc' ! write pointer (path/file) if (my_task == master_task) then + write(pointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & + trim(pointer_file)//'.',myear,'-',mmonth,'-',mday,'-',msec open(nu_rst_pointer,file=pointer_file) write(nu_rst_pointer,'(a)') filename close(nu_rst_pointer) @@ -336,7 +337,7 @@ subroutine init_restart_write(filename_spec) call define_rest_field(File,'a12_4',dims) endif - if (tr_pond_lvl .or. tr_pond_sealvl) then + if (tr_pond_lvl) then call define_rest_field(File,'fsnow',dims) endif @@ -428,7 +429,7 @@ subroutine init_restart_write(filename_spec) call define_rest_field(File,'ipnd',dims) end if - if (tr_pond_lvl .or. tr_pond_sealvl) then + if (tr_pond_lvl) then call define_rest_field(File,'apnd',dims) call define_rest_field(File,'hpnd',dims) call define_rest_field(File,'ipnd',dims) @@ -743,6 +744,7 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & call ice_pio_check(pio_inq_varndims(File, vardesc, ndims), & subname// " ERROR: missing varndims "//trim(vname),file=__FILE__,line=__LINE__) + call pio_seterrorhandling(File, PIO_INTERNAL_ERROR) if (ndim3 == ncat .and. ndims == 3) then call pio_read_darray(File, vardesc, iodesc3d_ncat, work, status) @@ -771,8 +773,6 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & call ice_pio_check(status, & subname//" ERROR: reading var "//trim(vname),file=__FILE__,line=__LINE__) - call pio_seterrorhandling(File, PIO_INTERNAL_ERROR) - if (diag) then if (ndim3 > 1) then do n=1,ndim3 diff --git a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 index 213e3bb01..aaa149291 100644 --- a/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 +++ b/cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90 @@ -683,8 +683,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if(mastertask) write(nu_diag,*) trim(subname)//'WARNING: pio_typename from driver needs to be set for netcdf output to work' end if - - #else ! Read the cice namelist as part of the call to cice_init1 @@ -850,7 +848,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) idate0 = start_ymd year_init = (idate0/10000) month_init= (idate0-year_init*10000)/100 ! integer month of basedate - day_init = idate0-year_init*10000-month_init*100 + day_init = idate0-year_init*10000-month_init*100 ! - Set use_leap_years based on calendar (as some CICE calls use this instead of the calendar type) if (calendar_type == ice_calendar_gregorian) then @@ -892,7 +890,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! Prescribed ice initialization !----------------------------------------------------------------- - call ice_prescribed_init(clock, ice_mesh, rc) + call ice_prescribed_init(gcomp, clock, ice_mesh, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return #ifdef CESMCOUPLED From b8232d795ce7a72bade321e06e4c64491ff772bf Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 17 Oct 2024 12:41:27 -0600 Subject: [PATCH 03/10] correct rpointer file name for cesm --- .../infrastructure/io/io_pio2/ice_restart.F90 | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 index 48a767101..8ebca4b23 100644 --- a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 @@ -9,6 +9,9 @@ module ice_restart use ice_communicate, only: my_task, master_task use ice_exit, only: abort_ice use ice_fileunits, only: nu_diag, nu_restart, nu_rst_pointer +#ifdef CESMCOUPLED + use ice_fileunits, only: inst_suffix +#endif use ice_kinds_mod use ice_restart_shared use ice_pio @@ -46,7 +49,6 @@ subroutine init_restart_read(ice_ic) mday, msec, npt use ice_domain_size, only: ncat use ice_read_write, only: ice_open - character(len=char_len_long), intent(in), optional :: ice_ic ! local variables @@ -57,15 +59,19 @@ subroutine init_restart_read(ice_ic) integer (kind=int_kind) :: status logical (kind=log_kind), save :: first_call = .true. - + logical :: exist character(len=*), parameter :: subname = '(init_restart_read)' if (present(ice_ic)) then filename = trim(ice_ic) else if (my_task == master_task) then +#ifdef CESMCOUPLED write(pointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & - trim(pointer_file)//'.',myear,'-',mmonth,'-',mday,'-',msec + 'rpointer.ice'//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec + inquire(file=pointer_file, exist=exist) + if (.not. exist) pointer_file = 'rpointer.ice'//trim(inst_suffix) +#endif open(nu_rst_pointer,file=pointer_file) read(nu_rst_pointer,'(a)') filename0 filename = trim(filename0) @@ -222,8 +228,10 @@ subroutine init_restart_write(filename_spec) ! write pointer (path/file) if (my_task == master_task) then - write(pointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & - trim(pointer_file)//'.',myear,'-',mmonth,'-',mday,'-',msec +#ifdef CESMCOUPLED + write(pointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & + 'rpointer.ice'//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec +#endif open(nu_rst_pointer,file=pointer_file) write(nu_rst_pointer,'(a)') filename close(nu_rst_pointer) From a0d1a9261746e5faae9ed157f2f996703f230a8a Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 21 Oct 2024 07:43:09 -0600 Subject: [PATCH 04/10] response to review --- .../cicedyn/infrastructure/io/io_pio2/ice_restart.F90 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 index 8ebca4b23..8c2342221 100644 --- a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 @@ -59,7 +59,9 @@ subroutine init_restart_read(ice_ic) integer (kind=int_kind) :: status logical (kind=log_kind), save :: first_call = .true. - logical :: exist +#ifdef CESMCOUPLED + logical :: file_exist +#endif character(len=*), parameter :: subname = '(init_restart_read)' if (present(ice_ic)) then @@ -69,8 +71,8 @@ subroutine init_restart_read(ice_ic) #ifdef CESMCOUPLED write(pointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & 'rpointer.ice'//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec - inquire(file=pointer_file, exist=exist) - if (.not. exist) pointer_file = 'rpointer.ice'//trim(inst_suffix) + inquire(file=pointer_file, file_exist=exist) + if (.not. file_exist) pointer_file = 'rpointer.ice'//trim(inst_suffix) #endif open(nu_rst_pointer,file=pointer_file) read(nu_rst_pointer,'(a)') filename0 From 6074f273513cd74270efd918da32e967da29bd96 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 21 Oct 2024 15:02:50 -0600 Subject: [PATCH 05/10] correct exist and file_exist --- cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 index 8c2342221..9fc5715ee 100644 --- a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 @@ -71,7 +71,7 @@ subroutine init_restart_read(ice_ic) #ifdef CESMCOUPLED write(pointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & 'rpointer.ice'//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec - inquire(file=pointer_file, file_exist=exist) + inquire(file=pointer_file, exist=file_exist) if (.not. file_exist) pointer_file = 'rpointer.ice'//trim(inst_suffix) #endif open(nu_rst_pointer,file=pointer_file) From 1cf126869c1305e8858e8b59b84cd6a5b7677fbb Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 21 Oct 2024 17:15:39 -0600 Subject: [PATCH 06/10] get pointer file name root from ice_in namelist and append timestamp for cesm --- .../infrastructure/io/io_pio2/ice_restart.F90 | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 index 9fc5715ee..40c0ae010 100644 --- a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 @@ -54,8 +54,8 @@ subroutine init_restart_read(ice_ic) ! local variables character(len=char_len_long) :: & - filename, filename0 - + filename, filename0, lpointer_file + integer (kind=int_kind) :: status logical (kind=log_kind), save :: first_call = .true. @@ -69,16 +69,18 @@ subroutine init_restart_read(ice_ic) else if (my_task == master_task) then #ifdef CESMCOUPLED - write(pointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & - 'rpointer.ice'//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec - inquire(file=pointer_file, exist=file_exist) - if (.not. file_exist) pointer_file = 'rpointer.ice'//trim(inst_suffix) + write(lpointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & + trim(pointer_file)//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec + inquire(file=lpointer_file, exist=file_exist) + if (.not. file_exist) lpointer_file = trim(pointer_file)//trim(inst_suffix) +#else + lpointer_file = pointer_file #endif - open(nu_rst_pointer,file=pointer_file) + open(nu_rst_pointer,file=lpointer_file) read(nu_rst_pointer,'(a)') filename0 filename = trim(filename0) close(nu_rst_pointer) - write(nu_diag,*) 'Read ',pointer_file(1:lenstr(pointer_file)) + write(nu_diag,*) 'Read ',lpointer_file(1:lenstr(pointer_file)) endif call broadcast_scalar(filename, master_task) endif @@ -184,6 +186,7 @@ subroutine init_restart_write(filename_spec) integer (kind=int_kind) :: nbtrcr character(len=char_len_long) :: filename + character(len=char_len_long) :: lpointer_file integer (kind=int_kind) :: & dimid_ncat, dimid_nilyr, dimid_nslyr, dimid_naero @@ -231,10 +234,12 @@ subroutine init_restart_write(filename_spec) ! write pointer (path/file) if (my_task == master_task) then #ifdef CESMCOUPLED - write(pointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & - 'rpointer.ice'//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec + write(lpointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & + trim(pointer_file)//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec +#else + lpointer_file = pointer_file #endif - open(nu_rst_pointer,file=pointer_file) + open(nu_rst_pointer,file=lpointer_file) write(nu_rst_pointer,'(a)') filename close(nu_rst_pointer) endif From 3a77e79f6805f101746ab5710a42db7f8b5135fd Mon Sep 17 00:00:00 2001 From: "David A. Bailey" Date: Wed, 23 Oct 2024 15:44:40 -0600 Subject: [PATCH 07/10] Update cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 Co-authored-by: Anton Steketee <79179784+anton-seaice@users.noreply.github.com> --- cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 index 8ebca4b23..18815ecf8 100644 --- a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 @@ -59,7 +59,11 @@ subroutine init_restart_read(ice_ic) integer (kind=int_kind) :: status logical (kind=log_kind), save :: first_call = .true. - logical :: exist + +#ifdef CESMCOUPLED + logical (kind=log_kind) :: file_exist +#endif + character(len=*), parameter :: subname = '(init_restart_read)' if (present(ice_ic)) then From e0b59fcc5ed7de15b85c244576fe2175cfe0d6ba Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 24 Oct 2024 10:17:55 -0600 Subject: [PATCH 08/10] the pointer_file name is set in namelist, no need to modify here --- .../infrastructure/io/io_pio2/ice_restart.F90 | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 index 40c0ae010..f6735855b 100644 --- a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 @@ -54,7 +54,7 @@ subroutine init_restart_read(ice_ic) ! local variables character(len=char_len_long) :: & - filename, filename0, lpointer_file + filename, filename0 integer (kind=int_kind) :: status @@ -68,19 +68,11 @@ subroutine init_restart_read(ice_ic) filename = trim(ice_ic) else if (my_task == master_task) then -#ifdef CESMCOUPLED - write(lpointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & - trim(pointer_file)//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec - inquire(file=lpointer_file, exist=file_exist) - if (.not. file_exist) lpointer_file = trim(pointer_file)//trim(inst_suffix) -#else - lpointer_file = pointer_file -#endif - open(nu_rst_pointer,file=lpointer_file) + open(nu_rst_pointer,file=pointer_file) read(nu_rst_pointer,'(a)') filename0 filename = trim(filename0) close(nu_rst_pointer) - write(nu_diag,*) 'Read ',lpointer_file(1:lenstr(pointer_file)) + write(nu_diag,*) 'Read ',pointer_file(1:lenstr(pointer_file)) endif call broadcast_scalar(filename, master_task) endif From 66b4bbf90ae5dbf4670d3ae10c409d91dbd75946 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 24 Oct 2024 10:20:41 -0600 Subject: [PATCH 09/10] cleanup whitespace --- cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 index f6735855b..4d5bbf6f3 100644 --- a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 @@ -55,13 +55,10 @@ subroutine init_restart_read(ice_ic) character(len=char_len_long) :: & filename, filename0 - + integer (kind=int_kind) :: status logical (kind=log_kind), save :: first_call = .true. -#ifdef CESMCOUPLED - logical :: file_exist -#endif character(len=*), parameter :: subname = '(init_restart_read)' if (present(ice_ic)) then From f7552bc273bfe40b566876f4fbb5856e0abd6a80 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 24 Oct 2024 10:48:22 -0600 Subject: [PATCH 10/10] need to use default cesm pointer name for write and not read from ice_in namelist --- cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 index 4d5bbf6f3..d659d89e6 100644 --- a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 @@ -224,7 +224,7 @@ subroutine init_restart_write(filename_spec) if (my_task == master_task) then #ifdef CESMCOUPLED write(lpointer_file,'(a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & - trim(pointer_file)//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec + 'rpointer.ice'//trim(inst_suffix)//'.',myear,'-',mmonth,'-',mday,'-',msec #else lpointer_file = pointer_file #endif