From 39ea702ff05df05be5972227e9f48aec752e6ab6 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 6 Sep 2024 10:31:38 -0600 Subject: [PATCH 1/2] add shr_get_rpointer_name --- src/nuopc_shr_methods.F90 | 54 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/src/nuopc_shr_methods.F90 b/src/nuopc_shr_methods.F90 index eeac540..e6bcfba 100644 --- a/src/nuopc_shr_methods.F90 +++ b/src/nuopc_shr_methods.F90 @@ -18,6 +18,7 @@ module nuopc_shr_methods use ESMF , only : ESMF_Time, ESMF_TimeGet, ESMF_TimeSet, ESMF_ClockGetAlarm use ESMF , only : ESMF_TimeInterval, ESMF_TimeIntervalSet, ESMF_TimeIntervalGet use ESMF , only : ESMF_VM, ESMF_VMGet, ESMF_VMBroadcast, ESMF_VMGetCurrent + use ESMF , only : ESMF_ClockGetNextTime use NUOPC , only : NUOPC_CompAttributeGet use NUOPC_Model , only : NUOPC_ModelGet use shr_kind_mod , only : r8 => shr_kind_r8, cl=>shr_kind_cl, cs=>shr_kind_cs @@ -37,10 +38,10 @@ module nuopc_shr_methods public :: alarmInit public :: get_minimum_timestep public :: chkerr - + public :: shr_get_rpointer_name private :: timeInit private :: field_getfldptr - + ! Module data ! Clock and alarm options shared with esm_time_mod along with dtime_driver which is initialized there. @@ -875,7 +876,54 @@ integer function get_minimum_timestep(gcomp, rc) endif end function get_minimum_timestep -!=============================================================================== + subroutine shr_get_rpointer_name(gcomp, compname, ymd, time, rpfile, mode, rc) + type(ESMF_GRIDCOMP), intent(in) :: gcomp + character(len=3), intent(in) :: compname + integer, intent(in) :: ymd + integer, intent(in) :: time + character(len=*), intent(out) :: rpfile + character(len=*), intent(in) :: mode + integer, intent(out) :: rc + + ! local vars + integer :: yr, mon, day + character(len=16) timestr + logical :: isPresent + character(len=ESMF_MAXSTR) :: inst_suffix + + character(len=*), parameter :: subname='shr_get_rpointer_name' + + rc = ESMF_SUCCESS + + inst_suffix = "" + call NUOPC_CompAttributeGet(gcomp, name='inst_suffix', isPresent=isPresent, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if(ispresent) call NUOPC_CompAttributeGet(gcomp, name='inst_suffix', value=inst_suffix, rc=rc) + + yr = ymd/10000 + mon = (ymd - yr*10000)/100 + day = (ymd - yr*10000 - mon*100) + write(timestr,'(i4.4,a,i2.2,a,i2.2,a,i5.5)') yr,'-',mon,'-',day,'-',time + + rpfile = "rpointer."//compname + if (trim(inst_suffix) .ne. "") then + write(rpfile,*) trim(rpfile),".",trim(inst_suffix) + endif + write(rpfile,*) trim(rpfile),".",timestr + if (mode.eq.'read') then + inquire(file=trim(rpfile), exist=isPresent) + if(.not. isPresent) then + rpfile = "rpointer."//compname + if (inst_suffix .ne. "") then + rpfile = trim(rpfile)//"."//trim(inst_suffix) + endif + inquire(file=trim(rpfile), exist=isPresent) + if(.not. isPresent) then + call shr_sys_abort( subname//'ERROR no rpointer file found in '//rpfile//' or in '//rpfile//'.'//timestr ) + endif + endif + endif + end subroutine shr_get_rpointer_name logical function chkerr(rc, line, file) From 4aafe199921d13978b1a2f3746df3de10576546f Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 12 Sep 2024 07:22:15 -0600 Subject: [PATCH 2/2] improve rpointer naming --- src/nuopc_shr_methods.F90 | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/nuopc_shr_methods.F90 b/src/nuopc_shr_methods.F90 index e6bcfba..02de842 100644 --- a/src/nuopc_shr_methods.F90 +++ b/src/nuopc_shr_methods.F90 @@ -905,18 +905,11 @@ subroutine shr_get_rpointer_name(gcomp, compname, ymd, time, rpfile, mode, rc) day = (ymd - yr*10000 - mon*100) write(timestr,'(i4.4,a,i2.2,a,i2.2,a,i5.5)') yr,'-',mon,'-',day,'-',time - rpfile = "rpointer."//compname - if (trim(inst_suffix) .ne. "") then - write(rpfile,*) trim(rpfile),".",trim(inst_suffix) - endif - write(rpfile,*) trim(rpfile),".",timestr + write(rpfile,*) "rpointer."//compname//trim(inst_suffix)//'.'//trim(timestr) if (mode.eq.'read') then inquire(file=trim(rpfile), exist=isPresent) if(.not. isPresent) then - rpfile = "rpointer."//compname - if (inst_suffix .ne. "") then - rpfile = trim(rpfile)//"."//trim(inst_suffix) - endif + rpfile = "rpointer."//compname//trim(inst_suffix) inquire(file=trim(rpfile), exist=isPresent) if(.not. isPresent) then call shr_sys_abort( subname//'ERROR no rpointer file found in '//rpfile//' or in '//rpfile//'.'//timestr )