From 7ea7866de7ec6056f6c8012a3cc7189f3a6f14b5 Mon Sep 17 00:00:00 2001 From: Nicholas Szapiro <149816583+NickSzapiro-NOAA@users.noreply.github.com> Date: Tue, 11 Jun 2024 12:01:37 -0400 Subject: [PATCH 01/68] Create cplhist mode for dice (#62) * Adapt docn_datamode_cplhist for dice_datamode_cplhist * Fix .or. and local variables have different names in docn and dice * Add Si_imask. Decide whether to have flds_i2o_per_cat for cplhist method. * Copy sea ice stream fields to export state fields via dshr_dfield_add * Switches So_t from C to K. Decide on which/add switch * Overwrite missing value of 0 K in Si_t * Handle So_t in C and K in docn_datamode_cplhist_mod.F90 Need model SST to be in K if (minval(So_t) .LT. 100.0_r8), convert C-->K * Only fill docn_datamode_cplhist export variables if associated. Handle units of So_t based on namelist input * Default convert SST C to K (as currently). Then switch based on optional sst_constant_value * Allow null return for taux too in dice/dice_datamode_cplhist_mod.F90 * Add doc for dice cplhist mode to dice.rst --- dice/CMakeLists.txt | 1 + dice/dice_datamode_cplhist_mod.F90 | 195 +++++++++++++++++++++++++++++ dice/ice_comp_nuopc.F90 | 89 +++++++++++-- doc/source/dice.rst | 3 + docn/docn_datamode_cplhist_mod.F90 | 27 +++- docn/ocn_comp_nuopc.F90 | 2 +- 6 files changed, 301 insertions(+), 16 deletions(-) create mode 100644 dice/dice_datamode_cplhist_mod.F90 diff --git a/dice/CMakeLists.txt b/dice/CMakeLists.txt index acfc26d47..aabb44312 100644 --- a/dice/CMakeLists.txt +++ b/dice/CMakeLists.txt @@ -1,6 +1,7 @@ project(dice Fortran) set(SRCFILES ice_comp_nuopc.F90 dice_datamode_ssmi_mod.F90 + dice_datamode_cplhist_mod.F90 dice_flux_atmice_mod.F90) foreach(FILE ${SRCFILES}) diff --git a/dice/dice_datamode_cplhist_mod.F90 b/dice/dice_datamode_cplhist_mod.F90 new file mode 100644 index 000000000..1d1eb28a0 --- /dev/null +++ b/dice/dice_datamode_cplhist_mod.F90 @@ -0,0 +1,195 @@ +module dice_datamode_cplhist_mod + + use ESMF , only : ESMF_State, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_SUCCESS + use NUOPC , only : NUOPC_Advertise + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_const_mod , only : shr_const_TkFrzsw + use shr_sys_mod , only : shr_sys_abort + use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr + use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add + use dshr_mod , only : dshr_restart_read, dshr_restart_write + use dshr_strdata_mod , only : shr_strdata_type + + implicit none + private ! except + + public :: dice_datamode_cplhist_advertise + public :: dice_datamode_cplhist_init_pointers + public :: dice_datamode_cplhist_advance + public :: dice_datamode_cplhist_restart_read + public :: dice_datamode_cplhist_restart_write + + ! export fields + ! ice to atm in CMEPS/mediator/esmFldsExchange_ufs_mod.F90 + real(r8), pointer :: Si_ifrac(:) => null() + real(r8), pointer :: Si_imask(:) => null() + real(r8), pointer :: Faii_taux(:) => null() + real(r8), pointer :: Faii_tauy(:) => null() + real(r8), pointer :: Faii_lat(:) => null() + real(r8), pointer :: Faii_sen(:) => null() + real(r8), pointer :: Faii_lwup(:) => null() + real(r8), pointer :: Faii_evap(:) => null() + real(r8), pointer :: Si_vice(:) => null() + real(r8), pointer :: Si_vsno(:) => null() + real(r8), pointer :: Si_t(:) => null() + real(r8), pointer :: Si_avsdr(:) => null() + real(r8), pointer :: Si_avsdf(:) => null() + real(r8), pointer :: Si_anidr(:) => null() + real(r8), pointer :: Si_anidf(:) => null() + + character(*) , parameter :: nullstr = 'null' + character(*) , parameter :: rpfile = 'rpointer.ice' + character(*) , parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine dice_datamode_cplhist_advertise(exportState, fldsexport, flds_scalar_name, rc) + + ! input/output variables + type(esmf_State) , intent(inout) :: exportState + type(fldlist_type) , pointer :: fldsexport + character(len=*) , intent(in) :: flds_scalar_name + integer , intent(out) :: rc + + ! local variables + type(fldlist_type), pointer :: fldList + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Advertise export fields + call dshr_fldList_add(fldsExport, trim(flds_scalar_name)) + call dshr_fldList_add(fldsExport, 'Si_ifrac' ) + call dshr_fldList_add(fldsExport, 'Si_imask' ) + call dshr_fldList_add(fldsExport, 'Faii_taux' ) + call dshr_fldList_add(fldsExport, 'Faii_tauy' ) + call dshr_fldList_add(fldsExport, 'Faii_lat' ) + call dshr_fldList_add(fldsExport, 'Faii_sen' ) + call dshr_fldList_add(fldsExport, 'Faii_lwup' ) + call dshr_fldList_add(fldsExport, 'Faii_evap' ) + call dshr_fldList_add(fldsExport, 'Si_vice' ) + call dshr_fldList_add(fldsExport, 'Si_vsno' ) + call dshr_fldList_add(fldsExport, 'Si_t' ) + call dshr_fldList_add(fldsExport, 'Si_avsdr' ) + call dshr_fldList_add(fldsExport, 'Si_avsdf' ) + call dshr_fldList_add(fldsExport, 'Si_anidr' ) + call dshr_fldList_add(fldsExport, 'Si_anidf' ) + + fldlist => fldsExport ! the head of the linked list + do while (associated(fldlist)) + call NUOPC_Advertise(exportState, standardName=fldlist%stdname, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_LogWrite('(dice_comp_advertise): Fr_ice'//trim(fldList%stdname), ESMF_LOGMSG_INFO) + fldList => fldList%next + enddo + + end subroutine dice_datamode_cplhist_advertise + + !=============================================================================== + subroutine dice_datamode_cplhist_init_pointers(importState, exportState,sdat,rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: importState + type(ESMF_State) , intent(inout) :: exportState + type(shr_strdata_type) , intent(in) :: sdat + integer , intent(out) :: rc + + ! local variables + character(len=*), parameter :: subname='(dice_init_pointers): ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + ! initialize pointers to export fields + call dshr_state_getfldptr(exportState, 'Si_ifrac' , fldptr1=Si_ifrac , rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Si_imask' , fldptr1=Si_imask , rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Faii_taux' , fldptr1=Faii_taux , allowNullReturn=.true., rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Faii_tauy' , fldptr1=Faii_tauy , allowNullReturn=.true., rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Faii_lat' , fldptr1=Faii_lat , allowNullReturn=.true., rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Faii_sen', fldptr1=Faii_sen, allowNullReturn=.true., rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Faii_lwup', fldptr1=Faii_lwup, allowNullReturn=.true., rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Faii_evap', fldptr1=Faii_evap, allowNullReturn=.true., rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Si_vice', fldptr1=Si_vice, allowNullReturn=.true., rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Si_vsno', fldptr1=Si_vsno, allowNullReturn=.true., rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Si_t', fldptr1=Si_t, allowNullReturn=.true., rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Si_avsdr', fldptr1=Si_avsdr, allowNullReturn=.true., rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Si_avsdf', fldptr1=Si_avsdf, allowNullReturn=.true., rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Si_anidr', fldptr1=Si_anidr, allowNullReturn=.true., rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Si_anidf', fldptr1=Si_anidf, allowNullReturn=.true., rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !Initialize (e.g., =0)? + + end subroutine dice_datamode_cplhist_init_pointers + + !=============================================================================== + subroutine dice_datamode_cplhist_advance(rc) + + ! input/output variables + integer, intent(out) :: rc + + ! local variables + character(len=*), parameter :: subname='(dice_datamode_cplhist_advance): ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + !Unit conversions, calculations,.... + !Where aice=0, Si_t=0K (as missing value). Interpolation in time between ice that comes or goes then has issues + where(Si_t .LT. 10) Si_t = shr_const_TkFrzsw + + end subroutine dice_datamode_cplhist_advance + + !=============================================================================== + subroutine dice_datamode_cplhist_restart_write(case_name, inst_suffix, ymd, tod, & + logunit, my_task, sdat) + + ! input/output variables + character(len=*) , intent(in) :: case_name + character(len=*) , intent(in) :: inst_suffix + integer , intent(in) :: ymd ! model date + integer , intent(in) :: tod ! model sec into model date + integer , intent(in) :: logunit + integer , intent(in) :: my_task + type(shr_strdata_type) , intent(inout) :: sdat + !------------------------------------------------------------------------------- + + call dshr_restart_write(rpfile, case_name, 'dice', inst_suffix, ymd, tod, & + logunit, my_task, sdat) + + end subroutine dice_datamode_cplhist_restart_write + + !=============================================================================== + subroutine dice_datamode_cplhist_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) + + ! input/output arguments + character(len=*) , intent(inout) :: rest_filem + character(len=*) , intent(in) :: inst_suffix + integer , intent(in) :: logunit + integer , intent(in) :: my_task + integer , intent(in) :: mpicom + type(shr_strdata_type) , intent(inout) :: sdat + !------------------------------------------------------------------------------- + + call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + + end subroutine dice_datamode_cplhist_restart_read + +end module dice_datamode_cplhist_mod diff --git a/dice/ice_comp_nuopc.F90 b/dice/ice_comp_nuopc.F90 index 63539e812..4f9b52729 100644 --- a/dice/ice_comp_nuopc.F90 +++ b/dice/ice_comp_nuopc.F90 @@ -16,7 +16,7 @@ module cdeps_dice_comp use ESMF , only : ESMF_AlarmIsRinging, ESMF_METHOD_INITIALIZE use ESMF , only : ESMF_ClockGet, ESMF_TimeGet, ESMF_MethodRemove, ESMF_MethodAdd use ESMF , only : ESMF_GridCompSetEntryPoint, operator(+), ESMF_AlarmRingerOff - use ESMF , only : ESMF_ClockGetAlarm, ESMF_StateGet, ESMF_Field, ESMF_FieldGet + use ESMF , only : ESMF_ClockGetAlarm, ESMF_StateGet, ESMF_Field, ESMF_FieldGet, ESMF_MAXSTR use NUOPC , only : NUOPC_CompDerive, NUOPC_CompSetEntryPoint, NUOPC_CompSpecialize use NUOPC , only : NUOPC_CompAttributeGet, NUOPC_Advertise use NUOPC_Model , only : model_routine_SS => SetServices @@ -41,6 +41,12 @@ module cdeps_dice_comp use dice_datamode_ssmi_mod , only : dice_datamode_ssmi_advance use dice_datamode_ssmi_mod , only : dice_datamode_ssmi_restart_read use dice_datamode_ssmi_mod , only : dice_datamode_ssmi_restart_write + ! + use dice_datamode_cplhist_mod , only : dice_datamode_cplhist_advertise + use dice_datamode_cplhist_mod , only : dice_datamode_cplhist_init_pointers + use dice_datamode_cplhist_mod , only : dice_datamode_cplhist_advance + use dice_datamode_cplhist_mod , only : dice_datamode_cplhist_restart_read + use dice_datamode_cplhist_mod , only : dice_datamode_cplhist_restart_write implicit none private ! except @@ -176,6 +182,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) integer :: bcasttmp(4) real(r8) :: rbcasttmp(3) type(ESMF_VM) :: vm + logical :: isPresent, isSet character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' character(*) ,parameter :: F00 = "('(" // trim(modName) // ") ',8a)" character(*) ,parameter :: F01 = "('(" // trim(modName) // ") ',a,2x,i8)" @@ -265,22 +272,28 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) flux_Qacc0 = rbcasttmp(3) ! Validate datamode - if ( trim(datamode) == 'ssmi' .or. trim(datamode) == 'ssmi_iaf') then + if ( trim(datamode) == 'ssmi' .or. trim(datamode) == 'ssmi_iaf' .or. trim(datamode) == 'cplhist') then if (my_task == main_task) write(logunit,*) ' dice datamode = ',trim(datamode) else call shr_sys_abort(' ERROR illegal dice datamode = '//trim(datamode)) endif ! Advertise import and export fields - call NUOPC_CompAttributeGet(gcomp, name='flds_i2o_per_cat', value=cvalue, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) flds_i2o_per_cat ! module variable + if ( trim(datamode) == 'ssmi' .or. trim(datamode) == 'ssmi_iaf') then + call NUOPC_CompAttributeGet(gcomp, name='flds_i2o_per_cat', value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) read(cvalue,*) flds_i2o_per_cat ! module variable + endif + !datamode already validated select case (trim(datamode)) - case('ssmi', 'ssmi_iaf') + case('ssmi','ssmi_iaf') call dice_datamode_ssmi_advertise(importState, exportState, fldsimport, fldsexport, & flds_scalar_name, flds_i2o_per_cat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('cplhist') + call dice_datamode_cplhist_advertise(exportState, fldsexport, flds_scalar_name, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return end select end subroutine InitializeAdvertise @@ -488,16 +501,25 @@ subroutine dice_comp_run(importstate, exportstate, target_ymd, target_tod, cosar if (first_time) then - ! Initialize dfields with export state data that has corresponding stream field - call dshr_dfield_add(dfields, sdat, state_fld='Si_ifrac', strm_fld='Si_ifrac', & + ! Initialize dfields with export state data that has corresponding stream fieldi + select case (trim(datamode)) + case('ssmi','ssmi_iaf') + call dshr_dfield_add(dfields, sdat, state_fld='Si_ifrac', strm_fld='Si_ifrac', & state=exportState, logunit=logunit, mainproc=mainproc, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + if (chkerr(rc,__LINE__,u_FILE_u)) return + case('cplhist') + call dice_init_dfields(importState, exportState, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end select ! Initialize datamode module ponters select case (trim(datamode)) case('ssmi', 'ssmi_iaf') call dice_datamode_ssmi_init_pointers(importState, exportState, sdat, flds_i2o_per_cat, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + case('cplhist') + call dice_datamode_cplhist_init_pointers(importState,exportState,sdat,rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return end select ! read restart if needed @@ -505,6 +527,8 @@ subroutine dice_comp_run(importstate, exportstate, target_ymd, target_tod, cosar select case (trim(datamode)) case('ssmi', 'ssmi_iaf') call dice_datamode_ssmi_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + case('cplhist') + call dice_datamode_cplhist_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) end select end if @@ -545,15 +569,22 @@ subroutine dice_comp_run(importstate, exportstate, target_ymd, target_tod, cosar call dice_datamode_ssmi_advance(exportState, importState, cosarg, flds_i2o_per_cat, & flux_swpf, flux_Qmin, flux_Qacc, flux_Qacc0, dt, logunit, restart_read, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + case ('cplhist') + call dice_datamode_cplhist_advance(rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return end select ! Write restarts if needed + ! TODO - no rc returned if (restart_write) then select case (trim(datamode)) case('ssmi', 'ssmi_iaf') call dice_datamode_ssmi_restart_write(case_name, inst_suffix, target_ymd, target_tod, & logunit, my_task, sdat) if (ChkErr(rc,__LINE__,u_FILE_u)) return + case ('cplhist') + call dice_datamode_cplhist_restart_write(case_name, inst_suffix, target_ymd, target_tod, logunit, my_task, sdat) + if (ChkErr(rc,__LINE__,u_FILE_u)) return end select end if @@ -566,6 +597,46 @@ subroutine dice_comp_run(importstate, exportstate, target_ymd, target_tod, cosar call ESMF_TraceRegionExit('dice_datamode') call ESMF_TraceRegionExit('DICE_RUN') + contains + subroutine dice_init_dfields(importState, exportState, rc) + ! ----------------------------- + ! Initialize dfields arrays + ! ----------------------------- + + ! input/output variables + type(ESMF_State) , intent(inout) :: importState + type(ESMF_State) , intent(inout) :: exportState + integer , intent(out) :: rc + + ! local variables + integer :: n + integer :: fieldcount + type(ESMF_Field) :: lfield + character(ESMF_MAXSTR) ,pointer :: lfieldnamelist(:) + character(*), parameter :: subName = "(dice_init_dfields) " + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Initialize dfields data type (to map streams to export state fields) + ! Create dfields linked list - used for copying stream fields to export + ! state fields + call ESMF_StateGet(exportState, itemCount=fieldCount, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + allocate(lfieldnamelist(fieldCount)) + call ESMF_StateGet(exportState, itemNameList=lfieldnamelist, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + do n = 1, fieldCount + call ESMF_StateGet(exportState, itemName=trim(lfieldNameList(n)), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (trim(lfieldnamelist(n)) /= flds_scalar_name) then + call dshr_dfield_add( dfields, sdat, trim(lfieldnamelist(n)), trim(lfieldnamelist(n)), exportState, & + logunit, mainproc, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end if + end do + end subroutine dice_init_dfields + end subroutine dice_comp_run !=============================================================================== diff --git a/doc/source/dice.rst b/doc/source/dice.rst index ebd5084b2..5abd2b5bb 100644 --- a/doc/source/dice.rst +++ b/doc/source/dice.rst @@ -27,6 +27,9 @@ ssmi (``dice_datamode_ssmi_mod.F90``) ssmi_iaf (``dice_datamode_ssmi_mod.F90``) - `ssmi_iaf` is the interannually varying version of `ssmi`. +cplhist (``dice_datamode_cplhist_mod.F90``) + - It provides mediator history variables from ice component of previous simulation. + .. _dice-cime-vars: --------------------------------------- diff --git a/docn/docn_datamode_cplhist_mod.F90 b/docn/docn_datamode_cplhist_mod.F90 index 3ff9e65c5..730879364 100644 --- a/docn/docn_datamode_cplhist_mod.F90 +++ b/docn/docn_datamode_cplhist_mod.F90 @@ -96,10 +96,11 @@ subroutine docn_datamode_cplhist_init_pointers(exportState, ocn_fraction, rc) call dshr_state_getfldptr(exportState, 'So_bldepth', fldptr1=So_bldepth, allowNullReturn=.true., rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - So_u(:) = 0.0_r8 - So_v(:) = 0.0_r8 - So_t(:) = TkFrz - So_bldepth(:) = 0.0_r8 + !Allocation depends on exchanged fields, so check before filling arrays with values here + if (associated(So_u)) So_u(:) = 0.0_r8 + if (associated(So_v)) So_v(:) = 0.0_r8 + if (associated(So_t)) So_t(:) = TkFrz + if (associated(So_bldepth)) So_bldepth(:) = 0.0_r8 ! Set export state ocean fraction (So_omask) So_omask(:) = ocn_fraction(:) @@ -107,18 +108,32 @@ subroutine docn_datamode_cplhist_init_pointers(exportState, ocn_fraction, rc) end subroutine docn_datamode_cplhist_init_pointers !=============================================================================== - subroutine docn_datamode_cplhist_advance(rc) + subroutine docn_datamode_cplhist_advance(sst_constant_value, rc) ! input/output variables + real(r8), optional, intent(in) :: sst_constant_value integer, intent(out) :: rc ! local variables + logical :: units_CToK = .true. ! true => convert SST in C to K character(len=*), parameter :: subname='(docn_datamode_cplhist_advance): ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - So_t(:) = So_t(:) + TkFrz + !If need unit conversion for So_t (C-->K), + !use existing nml variable sst_constant_value to signal units of input + !i.e., 0-->Celsius, 273.15-->K + + if (present(sst_constant_value)) then + if(sst_constant_value .GT. 230.0_r8) then !interpret input SST in K + units_CToK = .false. !in K already, don't convert + endif + endif + + if (units_CToK) then + So_t(:) = So_t(:) + TkFrz + endif end subroutine docn_datamode_cplhist_advance diff --git a/docn/ocn_comp_nuopc.F90 b/docn/ocn_comp_nuopc.F90 index f15ed9ec2..fc55ed2cf 100644 --- a/docn/ocn_comp_nuopc.F90 +++ b/docn/ocn_comp_nuopc.F90 @@ -630,7 +630,7 @@ subroutine docn_comp_run(importState, exportState, clock, target_ymd, target_tod call docn_datamode_aquaplanet_advance(exportState, model_mesh, sst_constant_value=sst_constant_value, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return case('cplhist') - call docn_datamode_cplhist_advance(rc=rc) + call docn_datamode_cplhist_advance(sst_constant_value=sst_constant_value, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return case('multilev') call docn_datamode_multilev_advance(sdat, logunit, mainproc, rc=rc) From cf09feba8f12c382bf1a2b1db5b0f9b6a42fd692 Mon Sep 17 00:00:00 2001 From: Nicholas Szapiro <149816583+NickSzapiro-NOAA@users.noreply.github.com> Date: Fri, 2 Aug 2024 13:13:23 -0400 Subject: [PATCH 02/68] remove the test for rc after the restart_write calls in ice_comp_nuopc.F90 errors are handled internally in that subroutine and do not return --- dice/ice_comp_nuopc.F90 | 3 --- 1 file changed, 3 deletions(-) diff --git a/dice/ice_comp_nuopc.F90 b/dice/ice_comp_nuopc.F90 index 4f9b52729..4fefa28fa 100644 --- a/dice/ice_comp_nuopc.F90 +++ b/dice/ice_comp_nuopc.F90 @@ -575,16 +575,13 @@ subroutine dice_comp_run(importstate, exportstate, target_ymd, target_tod, cosar end select ! Write restarts if needed - ! TODO - no rc returned if (restart_write) then select case (trim(datamode)) case('ssmi', 'ssmi_iaf') call dice_datamode_ssmi_restart_write(case_name, inst_suffix, target_ymd, target_tod, & logunit, my_task, sdat) - if (ChkErr(rc,__LINE__,u_FILE_u)) return case ('cplhist') call dice_datamode_cplhist_restart_write(case_name, inst_suffix, target_ymd, target_tod, logunit, my_task, sdat) - if (ChkErr(rc,__LINE__,u_FILE_u)) return end select end if From 0a7940ba566ce2baf972cf86aa8a3d32589d6065 Mon Sep 17 00:00:00 2001 From: Nick Szapiro Date: Thu, 29 Aug 2024 14:30:14 +0000 Subject: [PATCH 03/68] Remove datm_datamode_cfsr --- datm/CMakeLists.txt | 1 - datm/atm_comp_nuopc.F90 | 21 --- datm/datm_datamode_cfsr_mod.F90 | 256 -------------------------------- doc/source/datm.rst | 6 +- 4 files changed, 2 insertions(+), 282 deletions(-) delete mode 100644 datm/datm_datamode_cfsr_mod.F90 diff --git a/datm/CMakeLists.txt b/datm/CMakeLists.txt index 522a68761..892bed23d 100644 --- a/datm/CMakeLists.txt +++ b/datm/CMakeLists.txt @@ -5,7 +5,6 @@ set(SRCFILES atm_comp_nuopc.F90 datm_datamode_core2_mod.F90 datm_datamode_jra_mod.F90 datm_datamode_gefs_mod.F90 - datm_datamode_cfsr_mod.F90 datm_datamode_era5_mod.F90 datm_datamode_simple_mod.F90) diff --git a/datm/atm_comp_nuopc.F90 b/datm/atm_comp_nuopc.F90 index 7a2a41c7b..d9cdfe048 100644 --- a/datm/atm_comp_nuopc.F90 +++ b/datm/atm_comp_nuopc.F90 @@ -76,12 +76,6 @@ module cdeps_datm_comp use datm_datamode_gefs_mod , only : datm_datamode_gefs_restart_write use datm_datamode_gefs_mod , only : datm_datamode_gefs_restart_read - use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_advertise - use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_init_pointers - use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_advance - use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_restart_write - use datm_datamode_cfsr_mod , only : datm_datamode_cfsr_restart_read - use datm_datamode_simple_mod , only : datm_datamode_simple_advertise use datm_datamode_simple_mod , only : datm_datamode_simple_init_pointers use datm_datamode_simple_mod , only : datm_datamode_simple_advance @@ -391,9 +385,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) case ('GEFS') call datm_datamode_gefs_advertise(exportState, fldsExport, flds_scalar_name, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - case ('CFSR') - call datm_datamode_cfsr_advertise(exportState, fldsExport, flds_scalar_name, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return case ('SIMPLE') call datm_datamode_simple_advertise(exportState, fldsExport, flds_scalar_name, & nlfilename, my_task, vm, rc) @@ -638,9 +629,6 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe case('GEFS') call datm_datamode_gefs_init_pointers(exportState, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('CFSR') - call datm_datamode_cfsr_init_pointers(exportState, sdat, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return case('SIMPLE') call datm_datamode_simple_init_pointers(exportState, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -661,8 +649,6 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe call datm_datamode_era5_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) case('GEFS') call datm_datamode_gefs_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) - case('CFSR') - call datm_datamode_cfsr_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) case('SIMPLE') call datm_datamode_simple_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) end select @@ -715,9 +701,6 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe case('GEFS') call datm_datamode_gefs_advance(exportstate, mainproc, logunit, mpicom, target_ymd, & target_tod, sdat%model_calendar, rc) - case('CFSR') - call datm_datamode_cfsr_advance(exportstate, mainproc, logunit, mpicom, target_ymd, & - target_tod, sdat%model_calendar, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return case('SIMPLE') call datm_datamode_simple_advance(target_ymd, target_tod, target_mon, & @@ -747,10 +730,6 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe call datm_datamode_gefs_restart_write(case_name, inst_suffix, target_ymd, target_tod, & logunit, my_task, sdat) if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('CFSR') - call datm_datamode_cfsr_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - if (ChkErr(rc,__LINE__,u_FILE_u)) return case('SIMPLE') call datm_datamode_simple_restart_write(case_name, inst_suffix, target_ymd, target_tod, & logunit, my_task, sdat) diff --git a/datm/datm_datamode_cfsr_mod.F90 b/datm/datm_datamode_cfsr_mod.F90 deleted file mode 100644 index 8ad8cd3d6..000000000 --- a/datm/datm_datamode_cfsr_mod.F90 +++ /dev/null @@ -1,256 +0,0 @@ -module datm_datamode_cfsr_mod - - use ESMF , only : ESMF_State, ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO - use NUOPC , only : NUOPC_Advertise - use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort - use shr_precip_mod , only : shr_precip_partition_rain_snow_ramp - use shr_const_mod , only : shr_const_tkfrz, shr_const_rhofw, shr_const_rdair - use dshr_methods_mod , only : dshr_state_getfldptr, chkerr - use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_get_stream_pointer - use dshr_mod , only : dshr_restart_read, dshr_restart_write - use dshr_strdata_mod , only : shr_strdata_type - use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add - - implicit none - private ! except - - public :: datm_datamode_cfsr_advertise - public :: datm_datamode_cfsr_init_pointers - public :: datm_datamode_cfsr_advance - public :: datm_datamode_cfsr_restart_write - public :: datm_datamode_cfsr_restart_read - - ! export state data - real(r8), pointer :: Sa_z(:) => null() - real(r8), pointer :: Sa_u(:) => null() - real(r8), pointer :: Sa_v(:) => null() - real(r8), pointer :: Sa_tbot(:) => null() - real(r8), pointer :: Sa_shum(:) => null() - real(r8), pointer :: Sa_pbot(:) => null() - real(r8), pointer :: Sa_u10m(:) => null() - real(r8), pointer :: Sa_v10m(:) => null() - real(r8), pointer :: Sa_t2m(:) => null() - real(r8), pointer :: Sa_q2m(:) => null() - real(r8), pointer :: Sa_pslv(:) => null() - real(r8), pointer :: Faxa_lwdn(:) => null() - real(r8), pointer :: Faxa_rain(:) => null() - real(r8), pointer :: Faxa_snow(:) => null() - real(r8), pointer :: Faxa_swndr(:) => null() - real(r8), pointer :: Faxa_swndf(:) => null() - real(r8), pointer :: Faxa_swvdr(:) => null() - real(r8), pointer :: Faxa_swvdf(:) => null() - - ! stream data - real(r8), pointer :: strm_mask(:) => null() - - real(r8) :: tbotmax ! units detector - real(r8) :: maskmax ! units detector - - real(r8) , parameter :: tKFrz = SHR_CONST_TKFRZ - real(r8) , parameter :: rdair = SHR_CONST_RDAIR ! dry air gas constant ~ J/K/kg - real(r8) , parameter :: rhofw = SHR_CONST_RHOFW ! density of fresh water ~ kg/m^3 - - character(*), parameter :: nullstr = 'undefined' - character(*), parameter :: rpfile = 'rpointer.atm' - character(*), parameter :: u_FILE_u = & - __FILE__ - -!=============================================================================== -contains -!=============================================================================== - - subroutine datm_datamode_cfsr_advertise(exportState, fldsexport, & - flds_scalar_name, rc) - - ! input/output variables - type(esmf_State) , intent(inout) :: exportState - type(fldlist_type) , pointer :: fldsexport - character(len=*) , intent(in) :: flds_scalar_name - integer , intent(out) :: rc - - ! local variables - type(fldlist_type), pointer :: fldList - !------------------------------------------------------------------------------- - - rc = ESMF_SUCCESS - - call dshr_fldList_add(fldsExport, trim(flds_scalar_name)) - call dshr_fldList_add(fldsExport, 'Sa_z' ) - call dshr_fldList_add(fldsExport, 'Sa_u' ) - call dshr_fldList_add(fldsExport, 'Sa_v' ) - call dshr_fldList_add(fldsExport, 'Sa_tbot' ) - call dshr_fldList_add(fldsExport, 'Sa_pbot' ) - call dshr_fldList_add(fldsExport, 'Sa_shum' ) - call dshr_fldList_add(fldsExport, 'Sa_u10m' ) - call dshr_fldList_add(fldsExport, 'Sa_v10m' ) - call dshr_fldList_add(fldsExport, 'Sa_t2m' ) - call dshr_fldList_add(fldsExport, 'Sa_q2m' ) - call dshr_fldList_add(fldsExport, 'Sa_pslv' ) - call dshr_fldList_add(fldsExport, 'Faxa_rain' ) - call dshr_fldList_add(fldsExport, 'Faxa_snow' ) - call dshr_fldList_add(fldsExport, 'Faxa_swndr' ) - call dshr_fldList_add(fldsExport, 'Faxa_swvdr' ) - call dshr_fldList_add(fldsExport, 'Faxa_swndf' ) - call dshr_fldList_add(fldsExport, 'Faxa_swvdf' ) - call dshr_fldList_add(fldsExport, 'Faxa_lwdn' ) - - fldlist => fldsExport ! the head of the linked list - do while (associated(fldlist)) - call NUOPC_Advertise(exportState, standardName=fldlist%stdname, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_LogWrite('(datm_comp_advertise): Fr_atm '//trim(fldList%stdname), ESMF_LOGMSG_INFO) - fldList => fldList%next - enddo - - end subroutine datm_datamode_cfsr_advertise - - !=============================================================================== - subroutine datm_datamode_cfsr_init_pointers(exportState, sdat, rc) - - ! input/output variables - type(ESMF_State) , intent(inout) :: exportState - type(shr_strdata_type) , intent(in) :: sdat - integer , intent(out) :: rc - - ! local variables - character(len=*), parameter :: subname='(datm_init_pointers): ' - !------------------------------------------------------------------------------- - - rc = ESMF_SUCCESS - - ! initialize pointers for module level stream arrays - call shr_strdata_get_stream_pointer( sdat, 'Sa_mask' , strm_mask , rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! get export state pointers - call dshr_state_getfldptr(exportState, 'Sa_z' , fldptr1=Sa_z , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Sa_u' , fldptr1=Sa_u , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Sa_v' , fldptr1=Sa_v , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Sa_tbot' , fldptr1=Sa_tbot , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Sa_pbot' , fldptr1=Sa_pbot , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Sa_shum' , fldptr1=Sa_shum , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Sa_u10m' , fldptr1=Sa_u10m , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Sa_v10m' , fldptr1=Sa_v10m , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Sa_t2m' , fldptr1=Sa_t2m , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Sa_q2m' , fldptr1=Sa_q2m , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Sa_pslv' , fldptr1=Sa_pslv , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Faxa_rain' , fldptr1=Faxa_rain , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Faxa_snow' , fldptr1=Faxa_snow, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Faxa_swvdr' , fldptr1=Faxa_swvdr , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Faxa_swvdf' , fldptr1=Faxa_swvdf , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Faxa_swndr' , fldptr1=Faxa_swndr , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Faxa_swndf' , fldptr1=Faxa_swndf , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_getfldptr(exportState, 'Faxa_lwdn' , fldptr1=Faxa_lwdn , rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - end subroutine datm_datamode_cfsr_init_pointers - - !=============================================================================== - subroutine datm_datamode_cfsr_advance(exportstate, mainproc, logunit, mpicom, target_ymd, target_tod, model_calendar, rc) - use ESMF, only: ESMF_VMGetCurrent, ESMF_VMAllReduce, ESMF_REDUCE_MAX, ESMF_VM - - ! input/output variables - type(ESMF_State) , intent(inout) :: exportState - logical , intent(in) :: mainproc - integer , intent(in) :: logunit - integer , intent(in) :: mpicom - integer , intent(in) :: target_ymd - integer , intent(in) :: target_tod - character(len=*) , intent(in) :: model_calendar - integer , intent(out) :: rc - - ! local variables - logical :: first_time = .true. - integer :: n ! indices - integer :: lsize ! size of attr vect - real(r8) :: rtmp(2) - type(ESMF_VM) :: vm - character(len=*), parameter :: subname='(datm_datamode_cfsr_advance): ' - !------------------------------------------------------------------------------- - - rc = ESMF_SUCCESS - - lsize = size(strm_mask) - - if (first_time) then - call ESMF_VMGetCurrent(vm, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! determine tbotmax (see below for use) - rtmp(1) = maxval(Sa_tbot(:)) - call ESMF_VMAllReduce(vm, rtmp, rtmp(2:), 1, ESMF_REDUCE_MAX, rc=rc) - tbotmax = rtmp(2) - if (mainproc) write(logunit,*) trim(subname),' tbotmax = ',tbotmax - - ! determine maskmax (see below for use) - rtmp(1) = maxval(strm_mask(:)) - call ESMF_VMAllReduce(vm, rtmp, rtmp(2:), 1, ESMF_REDUCE_MAX, rc=rc) - maskmax = rtmp(2) - if (mainproc) write(logunit,*) trim(subname),' maskmax = ',maskmax - - ! reset first_time - first_time = .false. - end if - - do n = 1, lsize - !--- temperature --- - if (tbotmax < 50.0_r8) Sa_tbot(n) = Sa_tbot(n) + tkFrz - ! Limit very cold forcing to 180K - Sa_tbot(n) = max(180._r8, Sa_tbot(n)) - end do - - end subroutine datm_datamode_cfsr_advance - - !=============================================================================== - subroutine datm_datamode_cfsr_restart_write(case_name, inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - ! input/output variables - character(len=*) , intent(in) :: case_name - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: ymd ! model date - integer , intent(in) :: tod ! model sec into model date - integer , intent(in) :: logunit - integer , intent(in) :: my_task - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_write(rpfile, case_name, 'datm', inst_suffix, ymd, tod, & - logunit, my_task, sdat) - - end subroutine datm_datamode_cfsr_restart_write - - !=============================================================================== - subroutine datm_datamode_cfsr_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) - - ! input/output arguments - character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix - integer , intent(in) :: logunit - integer , intent(in) :: my_task - integer , intent(in) :: mpicom - type(shr_strdata_type) , intent(inout) :: sdat - !------------------------------------------------------------------------------- - - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) - - end subroutine datm_datamode_cfsr_restart_read - -end module datm_datamode_cfsr_mod diff --git a/doc/source/datm.rst b/doc/source/datm.rst index d731bc689..0f716b380 100644 --- a/doc/source/datm.rst +++ b/doc/source/datm.rst @@ -64,11 +64,9 @@ ERA5 (``datm_datamode_era5_mod.F90``) `$CESMDATAROOT/inputdata/atm/datm7/ERA5` .. note:: - In addition to the exiting DATM data modes, the `CDEPS fork `_ + Using the GEFS data mode, the `CDEPS fork `_ used by `NOAA's UFS Weather Model `_ - also includes additional data modes such as CFSR, GEFS and GFS. These data modes are not - merged with the NCAR's authoritative repository yet but it is tested under UFS Weather - model. + supports CFSR, GEFS and GFS data inputs. .. _datm-cime-vars: From f87f18d2989514c34d5983f5c1b7da21a211a037 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 17 Oct 2024 13:10:17 -0600 Subject: [PATCH 04/68] refactor alarm code for endofrun restart writes --- dglc/glc_comp_nuopc.F90 | 64 +++--- dshr/dshr_mod.F90 | 392 +++--------------------------------- share/nuopc_shr_methods.F90 | 126 +++--------- 3 files changed, 87 insertions(+), 495 deletions(-) diff --git a/dglc/glc_comp_nuopc.F90 b/dglc/glc_comp_nuopc.F90 index 39c6620fa..9066448df 100644 --- a/dglc/glc_comp_nuopc.F90 +++ b/dglc/glc_comp_nuopc.F90 @@ -37,11 +37,11 @@ module cdeps_dglc_comp #endif use dshr_methods_mod , only : dshr_state_diagnose, chkerr, memcheck use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_advance, shr_strdata_init_from_config - use dshr_mod , only : dshr_model_initphase, dshr_init, dshr_mesh_init, dshr_alarm_init + use dshr_mod , only : dshr_model_initphase, dshr_init, dshr_mesh_init use dshr_mod , only : dshr_state_setscalar, dshr_set_runclock, dshr_check_restart_alarm use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_realize - use nuopc_shr_methods, only : shr_get_rpointer_name + use nuopc_shr_methods, only : shr_get_rpointer_name, alarmInit ! Datamode specialized modules use dglc_datamode_noevolve_mod, only : dglc_datamode_noevolve_advertise use dglc_datamode_noevolve_mod, only : dglc_datamode_noevolve_init_pointers @@ -736,18 +736,18 @@ subroutine ModelSetRunClock(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (trim(glc_avg_period) == 'hour') then - call dshr_alarm_init(mclock, valid_alarm, 'nhours', opt_n=1, alarmname='alarm_valid_inputs', rc=rc) + call alarmInit(mclock, valid_alarm, 'nhours', opt_n=1, alarmname='alarm_valid_inputs', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else if (trim(glc_avg_period) == 'day') then - call dshr_alarm_init(mclock, valid_alarm, 'ndays' , opt_n=1, alarmname='alarm_valid_inputs', rc=rc) + call alarmInit(mclock, valid_alarm, 'ndays' , opt_n=1, alarmname='alarm_valid_inputs', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else if (trim(glc_avg_period) == 'yearly') then - call dshr_alarm_init(mclock, valid_alarm, 'yearly', alarmname='alarm_valid_inputs', rc=rc) + call alarmInit(mclock, valid_alarm, 'yearly', alarmname='alarm_valid_inputs', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else if (trim(glc_avg_period) == 'glc_coupling_period') then call ESMF_TimeIntervalGet(mtimestep, s=dtime, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_alarm_init(mclock, valid_alarm, 'nseconds', opt_n=dtime, alarmname='alarm_valid_inputs', rc=rc) + call alarmInit(mclock, valid_alarm, 'nseconds', opt_n=dtime, alarmname='alarm_valid_inputs', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else call ESMF_LogWrite(trim(subname)// ": ERROR glc_avg_period = "//trim(glc_avg_period)//" not supported", & @@ -760,55 +760,55 @@ subroutine ModelSetRunClock(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return !---------------- - ! Restart alarm + ! Stop alarm !---------------- - call ESMF_LogWrite(subname//'setting restart alarm for dglc' , ESMF_LOGMSG_INFO) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - call NUOPC_CompAttributeGet(gcomp, name="restart_option", value=restart_option, rc=rc) + call ESMF_LogWrite(subname//'setting stop alarm for dglc' , ESMF_LOGMSG_INFO) + 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 dshr_alarm_init(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 ESMF_LogWrite(subname//'setting stop alarm for dglc' , ESMF_LOGMSG_INFO) - call NUOPC_CompAttributeGet(gcomp, name="stop_option", value=stop_option, rc=rc) + call ESMF_LogWrite(subname//'setting restart alarm for dglc' , ESMF_LOGMSG_INFO) 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_option", value=restart_option, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) stop_n - call NUOPC_CompAttributeGet(gcomp, name="stop_ymd", 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_ymd + read(cvalue,*) restart_n - call dshr_alarm_init(mclock, stop_alarm, stop_option, & - opt_n = stop_n, & - opt_ymd = stop_ymd, & + call NUOPC_CompAttributeGet(gcomp, name="restart_ymd", value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) restart_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/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index 7d6bd71f8..be8c34482 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -44,6 +44,7 @@ module dshr_mod use dshr_strdata_mod , only : shr_strdata_type, SHR_STRDATA_GET_STREAM_COUNT use shr_string_mod , only : shr_string_toLower use dshr_methods_mod , only : chkerr + use nuopc_shr_methods, only : alarmInit use pio implicit none @@ -60,7 +61,6 @@ module dshr_mod public :: dshr_state_setscalar public :: dshr_orbital_update public :: dshr_orbital_init - public :: dshr_alarm_init ! initialize alarms private :: dshr_mesh_create_scol ! create mesh for single column mode private :: dshr_time_init ! initialize time @@ -509,6 +509,29 @@ subroutine dshr_set_runclock(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (alarmCount == 0) then + !---------------- + ! Stop alarm + !---------------- + 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="stop_n", value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) stop_n + + call NUOPC_CompAttributeGet(gcomp, name="stop_ymd", value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) stop_ymd + + call alarmInit(mclock, stop_alarm, stop_option, & + opt_n = stop_n, & + opt_ymd = stop_ymd, & + RefTime = mcurrTime, & + alarmname = 'alarm_stop', rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call ESMF_AlarmSet(stop_alarm, clock=mclock, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return call ESMF_GridCompGet(gcomp, name=name, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -525,7 +548,7 @@ subroutine dshr_set_runclock(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return read(cvalue,*) restart_ymd - call dshr_alarm_init(mclock, restart_alarm, restart_option, & + call alarmInit(mclock, restart_alarm, restart_option, & opt_n = restart_n, & opt_ymd = restart_ymd, & RefTime = mcurrTime, & @@ -535,30 +558,6 @@ subroutine dshr_set_runclock(gcomp, rc) call ESMF_AlarmSet(restart_alarm, clock=mclock, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - !---------------- - ! Stop alarm - !---------------- - 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="stop_n", value=cvalue, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) stop_n - - call NUOPC_CompAttributeGet(gcomp, name="stop_ymd", value=cvalue, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) stop_ymd - - call dshr_alarm_init(mclock, stop_alarm, stop_option, & - opt_n = stop_n, & - opt_ymd = stop_ymd, & - RefTime = mcurrTime, & - alarmname = 'alarm_stop', rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - call ESMF_AlarmSet(stop_alarm, clock=mclock, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - end if ! Advance model clock to trigger alarms then reset model clock back to currtime @@ -570,347 +569,6 @@ subroutine dshr_set_runclock(gcomp, rc) end subroutine dshr_set_runclock - !=============================================================================== - subroutine dshr_alarm_init( clock, alarm, option, & - opt_n, opt_ymd, opt_tod, RefTime, alarmname, rc) - - ! Setup an alarm in a clock - ! Notes: The ringtime sent to AlarmCreate MUST be the next alarm - ! time. If you send an arbitrary but proper ringtime from the - ! past and the ring interval, the alarm will always go off on the - ! next clock advance and this will cause serious problems. Even - ! if it makes sense to initialize an alarm with some reference - ! time and the alarm interval, that reference time has to be - ! advance forward to be >= the current time. In the logic below - ! we set an appropriate "NextAlarm" and then we make sure to - ! advance it properly based on the ring interval. - - ! input/output variables - type(ESMF_Clock) , intent(inout) :: clock ! clock - type(ESMF_Alarm) , intent(inout) :: alarm ! alarm - character(len=*) , intent(in) :: option ! alarm option - integer , optional , intent(in) :: opt_n ! alarm freq - integer , optional , intent(in) :: opt_ymd ! alarm ymd - integer , optional , intent(in) :: opt_tod ! alarm tod (sec) - type(ESMF_Time) , optional , intent(in) :: RefTime ! ref time - character(len=*) , optional , intent(in) :: alarmname ! alarm name - integer , intent(inout) :: rc ! Return code - - ! local variables - type(ESMF_Calendar) :: cal ! calendar - integer :: lymd ! local ymd - integer :: ltod ! local tod - integer :: cyy,cmm,cdd,csec ! time info - character(len=64) :: lalarmname ! local alarm name - logical :: update_nextalarm ! update next alarm - type(ESMF_Time) :: CurrTime ! Current Time - type(ESMF_Time) :: NextAlarm ! Next restart alarm time - type(ESMF_TimeInterval) :: AlarmInterval ! Alarm interval - character(len=*), parameter :: & ! Clock and alarm options - optNONE = "none" , & - optNever = "never" , & - optNSteps = "nsteps" , & - optNStep = "nstep" , & - optNSeconds = "nseconds" , & - optNSecond = "nsecond" , & - optNMinutes = "nminutes" , & - optNMinute = "nminute" , & - optNHours = "nhours" , & - optNHour = "nhour" , & - optNDays = "ndays" , & - optNDay = "nday" , & - optNMonths = "nmonths" , & - optNMonth = "nmonth" , & - optNYears = "nyears" , & - optNYear = "nyear" , & - optMonthly = "monthly" , & - optYearly = "yearly" , & - optDate = "date" , & - optEnd = "end" , & - optIfdays0 = "ifdays0" - character(len=*), parameter :: subname = '(dshr_alarm_init): ' - !------------------------------------------------------------------------------- - - rc = ESMF_SUCCESS - update_nextalarm = .false. - - lalarmname = 'alarm_unknown' - if (present(alarmname)) lalarmname = trim(alarmname) - ltod = 0 - if (present(opt_tod)) ltod = opt_tod - lymd = -1 - if (present(opt_ymd)) lymd = opt_ymd - - call ESMF_ClockGet(clock, CurrTime=CurrTime, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - call ESMF_TimeGet(CurrTime, yy=cyy, mm=cmm, dd=cdd, s=csec, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - ! initial guess of next alarm, this will be updated below - if (present(RefTime)) then - NextAlarm = RefTime - else - NextAlarm = CurrTime - endif - - ! Determine calendar - call ESMF_ClockGet(clock, calendar=cal) - - ! Determine inputs for call to create alarm - selectcase (trim(option)) - - case (optNONE) - call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeSet( NextAlarm, yy=9999, mm=12, dd=1, s=0, calendar=cal, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - update_nextalarm = .false. - - case (optNever) - call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeSet( NextAlarm, yy=9999, mm=12, dd=1, s=0, calendar=cal, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - update_nextalarm = .false. - - case (optEnd) - call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeSet( NextAlarm, yy=9999, mm=12, dd=1, s=0, calendar=cal, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - update_nextalarm = .false. - - case (optDate) - if (.not. present(opt_ymd)) then - call shr_sys_abort(subname//trim(option)//' requires opt_ymd') - end if - if (lymd < 0 .or. ltod < 0) then - call shr_sys_abort(subname//trim(option)//'opt_ymd, opt_tod invalid') - end if - call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call dshr_time_init(NextAlarm, lymd, cal, ltod, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - update_nextalarm = .false. - - case (optIfdays0) - if (.not. present(opt_ymd)) then - call shr_sys_abort(subname//trim(option)//' requires opt_ymd') - end if - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeSet( NextAlarm, yy=cyy, mm=cmm, dd=opt_n, s=0, calendar=cal, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - update_nextalarm = .true. - - case (optNSteps) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNStep) - if (.not.present(opt_n)) call shr_sys_abort(subname//trim(option)//' requires opt_n') - if (opt_n <= 0) call shr_sys_abort(subname//trim(option)//' invalid opt_n') - call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNSeconds) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNSecond) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNMinutes) - call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNMinute) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNHours) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNHour) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNDays) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNDay) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNMonths) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNMonth) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optMonthly) - call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeSet( NextAlarm, yy=cyy, mm=cmm, dd=1, s=0, calendar=cal, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - update_nextalarm = .true. - - case (optNYears) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNYear) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optYearly) - call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeSet( NextAlarm, yy=cyy, mm=1, dd=1, s=0, calendar=cal, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - update_nextalarm = .true. - - case default - call shr_sys_abort(subname//'unknown option '//trim(option)) - end select - - ! -------------------------------------------------------------------------------- - ! --- AlarmInterval and NextAlarm should be set --- - ! -------------------------------------------------------------------------------- - - ! --- advance Next Alarm so it won't ring on first timestep for - ! --- most options above. go back one alarminterval just to be careful - - if (update_nextalarm) then - NextAlarm = NextAlarm - AlarmInterval - do while (NextAlarm <= CurrTime) - NextAlarm = NextAlarm + AlarmInterval - enddo - endif - - alarm = ESMF_AlarmCreate( name=lalarmname, clock=clock, ringTime=NextAlarm, & - ringInterval=AlarmInterval, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - end subroutine dshr_alarm_init - !=============================================================================== subroutine dshr_time_init( Time, ymd, cal, tod, rc) diff --git a/share/nuopc_shr_methods.F90 b/share/nuopc_shr_methods.F90 index 02de842f9..7023467cf 100644 --- a/share/nuopc_shr_methods.F90 +++ b/share/nuopc_shr_methods.F90 @@ -501,7 +501,7 @@ end subroutine field_getfldptr subroutine alarmInit( clock, alarm, option, & opt_n, opt_ymd, opt_tod, RefTime, alarmname, advance_clock, rc) - use ESMF, only : ESMF_AlarmPrint + use ESMF, only : ESMF_AlarmPrint, ESMF_ClockGetAlarm ! Setup an alarm in a clock ! Notes: The ringtime sent to AlarmCreate MUST be the next alarm ! time. If you send an arbitrary but proper ringtime from the @@ -595,27 +595,23 @@ subroutine alarmInit( clock, alarm, option, & return end if end if + call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return ! Determine inputs for call to create alarm selectcase (trim(option)) case (optNONE) - call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return call ESMF_TimeSet( NextAlarm, yy=9999, mm=12, dd=1, s=0, calendar=cal, rc=rc ) if (chkerr(rc,__LINE__,u_FILE_u)) return update_nextalarm = .false. case (optNever) - call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return call ESMF_TimeSet( NextAlarm, yy=9999, mm=12, dd=1, s=0, calendar=cal, rc=rc ) if (chkerr(rc,__LINE__,u_FILE_u)) return update_nextalarm = .false. case (optDate) - call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return call timeInit(NextAlarm, lymd, cal, ltod, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return update_nextalarm = .false. @@ -682,6 +678,13 @@ subroutine alarmInit( clock, alarm, option, & call ESMF_TimeSet( NextAlarm, yy=cyy, mm=1, dd=1, s=0, calendar=cal, rc=rc ) if (ChkErr(rc,__LINE__,u_FILE_u)) return update_nextalarm = .true. + + case (optEnd) + 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 ESMF_LogWrite(subname//'unknown option '//trim(option), ESMF_LOGMSG_ERROR) rc = ESMF_FAILURE @@ -762,114 +765,45 @@ end subroutine timeInit !=============================================================================== - integer function get_minimum_timestep(gcomp, rc) + integer function get_minimum_timestep(gcomp, rc) ! Get the minimum timestep interval in seconds based on the nuopc.config variables *_cpl_dt, ! if none of these variables are defined this routine will throw an error type(ESMF_GridComp), intent(in) :: gcomp integer, intent(out) :: rc - character(len=CS) :: cvalue - integer :: atm_cpl_dt ! Atmosphere coupling interval - integer :: lnd_cpl_dt ! Land coupling interval - integer :: ice_cpl_dt ! Sea-Ice coupling interval - integer :: ocn_cpl_dt ! Ocean coupling interval - integer :: glc_cpl_dt ! Glc coupling interval - integer :: rof_cpl_dt ! Runoff coupling interval - integer :: wav_cpl_dt ! Wav coupling interval - logical :: is_present, is_set ! determine if these variables are used - integer :: esp_cpl_dt ! Esp coupling interval - + character(len=CS) :: cvalue + integer :: comp_dt ! coupling interval of component + integer, parameter :: ncomps = 8 + character(len=3),dimension(ncomps) :: compname + character(len=10) :: comp + logical :: is_present, is_set ! determine if these variables are used + integer :: i !--------------------------------------------------------------------------- ! Determine driver clock timestep !--------------------------------------------------------------------------- + compname = (/"atm", "lnd", "ice", "ocn", "rof", "glc", "wav", "esp"/) get_minimum_timestep = huge(1) - - call NUOPC_CompAttributeGet(gcomp, name="atm_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - if (is_present .and. is_set) then - call NUOPC_CompAttributeGet(gcomp, name="atm_cpl_dt", value=cvalue, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) atm_cpl_dt - get_minimum_timestep = min(atm_cpl_dt, get_minimum_timestep) - endif - - call NUOPC_CompAttributeGet(gcomp, name="lnd_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - if (is_present .and. is_set) then - call NUOPC_CompAttributeGet(gcomp, name="lnd_cpl_dt", value=cvalue, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) lnd_cpl_dt - get_minimum_timestep = min(lnd_cpl_dt, get_minimum_timestep) - endif - - call NUOPC_CompAttributeGet(gcomp, name="ice_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - if (is_present .and. is_set) then - call NUOPC_CompAttributeGet(gcomp, name="ice_cpl_dt", value=cvalue, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) ice_cpl_dt - get_minimum_timestep = min(ice_cpl_dt, get_minimum_timestep) - endif - - call NUOPC_CompAttributeGet(gcomp, name="ocn_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - if (is_present .and. is_set) then - call NUOPC_CompAttributeGet(gcomp, name="ocn_cpl_dt", value=cvalue, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) ocn_cpl_dt - get_minimum_timestep = min(ocn_cpl_dt, get_minimum_timestep) - endif - - call NUOPC_CompAttributeGet(gcomp, name="glc_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - if (is_present .and. is_set) then - call NUOPC_CompAttributeGet(gcomp, name="glc_cpl_dt", value=cvalue, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) glc_cpl_dt - get_minimum_timestep = min(glc_cpl_dt, get_minimum_timestep) - endif - - call NUOPC_CompAttributeGet(gcomp, name="rof_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - if (is_present .and. is_set) then - call NUOPC_CompAttributeGet(gcomp, name="rof_cpl_dt", value=cvalue, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) rof_cpl_dt - get_minimum_timestep = min(rof_cpl_dt, get_minimum_timestep) - endif - - call NUOPC_CompAttributeGet(gcomp, name="wav_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - if (is_present .and. is_set) then - call NUOPC_CompAttributeGet(gcomp, name="wav_cpl_dt", value=cvalue, rc=rc) + do i=1,ncomps + comp = compname(i)//"_cpl_dt" + + call NUOPC_CompAttributeGet(gcomp, name=comp, isPresent=is_present, isSet=is_set, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) wav_cpl_dt - get_minimum_timestep = min(wav_cpl_dt, get_minimum_timestep) - endif - call NUOPC_CompAttributeGet(gcomp, name="esp_cpl_dt", isPresent=is_present, isSet=is_set, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (is_present .and. is_set) then + call NUOPC_CompAttributeGet(gcomp, name=comp, value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) comp_dt + get_minimum_timestep = min(comp_dt, get_minimum_timestep) + endif + enddo - if (is_present .and. is_set) then - call NUOPC_CompAttributeGet(gcomp, name="esp_cpl_dt", value=cvalue, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) esp_cpl_dt - get_minimum_timestep = min(esp_cpl_dt, get_minimum_timestep) - endif if(get_minimum_timestep == huge(1)) then call ESMF_LogWrite('minimum_timestep_error: this option is not supported ', ESMF_LOGMSG_ERROR) rc = ESMF_FAILURE return endif if(get_minimum_timestep <= 0) then - print *,__FILE__,__LINE__,atm_cpl_dt, lnd_cpl_dt, ocn_cpl_dt, ice_cpl_dt, glc_cpl_dt, rof_cpl_dt, wav_cpl_dt call ESMF_LogWrite('minimum_timestep_error ERROR ', ESMF_LOGMSG_ERROR) rc = ESMF_FAILURE return From d2fa455b411febf58e3a76e1b58b93e4fdae267b Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 17 Oct 2024 14:05:35 -0600 Subject: [PATCH 05/68] remove unused dshr_time_init --- dshr/dshr_mod.F90 | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index be8c34482..b929f8761 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -63,7 +63,6 @@ module dshr_mod public :: dshr_orbital_init private :: dshr_mesh_create_scol ! create mesh for single column mode - private :: dshr_time_init ! initialize time ! Note that gridTofieldMap = 2, therefore the ungridded dimension is innermost @@ -569,44 +568,6 @@ subroutine dshr_set_runclock(gcomp, rc) end subroutine dshr_set_runclock - !=============================================================================== - subroutine dshr_time_init( Time, ymd, cal, tod, rc) - - ! Create the ESMF_Time object corresponding to the given input time, - ! given in YMD (Year Month Day) and TOD (Time-of-day) format. - ! Set the time by an integer as YYYYMMDD and integer seconds in the day - - ! input/output parameters: - type(ESMF_Time) , intent(inout) :: Time ! ESMF time - integer , intent(in) :: ymd ! year, month, day YYYYMMDD - type(ESMF_Calendar) , intent(in) :: cal ! ESMF calendar - integer , intent(in) :: tod ! time of day in seconds - integer , intent(out) :: rc - - ! local variables - integer :: year, mon, day ! year, month, day as integers - integer :: tdate - integer , parameter :: SecPerDay = 86400 ! Seconds per day - character(len=*), parameter :: subname='(dshr_time_init)' - !------------------------------------------------------------------------------- - - rc = ESMF_SUCCESS - - if ( (ymd < 0) .or. (tod < 0) .or. (tod > SecPerDay) )then - call shr_sys_abort( subname//'ERROR yymmdd is a negative number or time-of-day out of bounds' ) - end if - - tdate = abs(ymd) - year = int(tdate/10000) - if (ymd < 0) year = -year - mon = int( mod(tdate,10000)/ 100) - day = mod(tdate, 100) - - call ESMF_TimeSet( Time, yy=year, mm=mon, dd=day, s=tod, calendar=cal, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - end subroutine dshr_time_init - !=============================================================================== subroutine dshr_restart_read(rest_filem, rpfile, & logunit, my_task, mpicom, sdat, rc, fld, fldname) From 7ca8548f9ec40fa71517b2a2145b4f85c58ef281 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 31 Oct 2024 07:57:52 -0600 Subject: [PATCH 06/68] remove extra instance append in dglc --- dglc/dglc_datamode_noevolve_mod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dglc/dglc_datamode_noevolve_mod.F90 b/dglc/dglc_datamode_noevolve_mod.F90 index a7ed13592..d91a1383d 100644 --- a/dglc/dglc_datamode_noevolve_mod.F90 +++ b/dglc/dglc_datamode_noevolve_mod.F90 @@ -548,7 +548,7 @@ subroutine dglc_datamode_noevolve_restart_write(model_meshes, case_name, & write(rest_file_model ,"(7a)") trim(case_name),'.','dglc',trim(inst_suffix),'.r.',trim(date_str),'.nc' ! write restart info to rpointer file if (my_task == main_task) then - open(newunit=nu, file=trim(rpfile)//trim(inst_suffix), form='formatted') + open(newunit=nu, file=trim(rpfile), form='formatted') write(nu,'(a)') rest_file_model close(nu) write(logunit,'(a,2x,i0,2x,i0)')' writing with no streams '//trim(rest_file_model), ymd, tod From 4a34e46764b512a0f7beb41180855a8f2dbf2e48 Mon Sep 17 00:00:00 2001 From: Denise Worthen Date: Wed, 18 Dec 2024 12:35:21 -0500 Subject: [PATCH 07/68] add restart_fh mod to share to enable github testing of ufs build --- share/shr_is_restart_fh_mod.F90 | 137 ++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 share/shr_is_restart_fh_mod.F90 diff --git a/share/shr_is_restart_fh_mod.F90 b/share/shr_is_restart_fh_mod.F90 new file mode 100644 index 000000000..42739bbe8 --- /dev/null +++ b/share/shr_is_restart_fh_mod.F90 @@ -0,0 +1,137 @@ +module shr_is_restart_fh_mod + + ! Common methods for components to check if it's time to write forecast hour-based restarts + + !use dshr_methods_mod , only : chkerr + use ESMF, only : ESMF_ConfigCreate, ESMF_ConfigDestroy, ESMF_ConfigLoadFile, & + ESMF_ConfigGetLen, ESMF_ConfigGetAttribute, ESMF_TimePrint, & + ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_TimeInterval, & + ESMF_Time, ESMF_KIND_R8, ESMF_Config, ESMF_Clock, & + ESMF_TimeIntervalSet, ESMF_TimePrint, operator(+), operator(==), & + ESMF_LogFoundError, ESMF_LOGERR_PASSTHRU + + implicit none + private + + type :: is_restart_fh_type + logical :: write_restartfh = .false. + type(ESMF_Time), allocatable :: restartFhTimes(:) + end type is_restart_fh_type + + public :: init_is_restart_fh, is_restart_fh, finalize_restart_fh, is_restart_fh_type + +contains + + !----------------------------------------------------------------------- + subroutine init_is_restart_fh(currentTime, dtime, lLog, restartfh_info) + ! + ! !DESCRIPTION: + ! Process restart_fh attribute from model_configure in UFS + ! + ! !USES: + ! + ! !ARGUMENTS: + type(ESMF_Time), intent(in) :: currentTime + integer, intent(in) :: dtime ! time step (s) + logical, intent(in) :: lLog ! If true, this task logs restart_fh info + type(is_restart_fh_type), intent(out) :: restartfh_info !restart_fh info for each task + ! + ! !LOCAL VARIABLES: + character(len=256) :: timestr + integer :: n, nfh, fh_s, rc + logical :: isPresent + real(kind=ESMF_KIND_R8), allocatable :: restart_fh(:) + type(ESMF_TimeInterval) :: fhInterval + type(ESMF_Config) :: CF_mc + !----------------------------------------------------------------------- + + ! set up Times to write non-interval restarts + inquire(FILE='model_configure', EXIST=isPresent) + if (isPresent) then !model_configure exists. this is ufs run + CF_mc = ESMF_ConfigCreate(rc=rc) + call ESMF_ConfigLoadFile(config=CF_mc,filename='model_configure' ,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + nfh = ESMF_ConfigGetLen(config=CF_mc, label ='restart_fh:',rc=rc) + if (nfh .gt. 0) then + allocate(restart_fh(1:nfh)) + allocate(restartfh_info%restartFhTimes(1:nfh)) !not deallocated here + + call ESMF_ConfigGetAttribute(CF_mc,valueList=restart_fh,label='restart_fh:', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + ! create a list of times at each restart_fh + do n = 1,nfh + fh_s = NINT(3600*restart_fh(n)) + call ESMF_TimeIntervalSet(fhInterval, s=fh_s, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + restartfh_info%restartFhTimes(n) = currentTime + fhInterval + call ESMF_TimePrint(restartfh_info%restartFhTimes(n), options="string", & + preString="restart_fh at ", unit=timestr, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (lLog) then + if (mod(fh_s,dtime) /= 0) then + call ESMF_LogWrite('restart time NOT to be written for '//trim(timestr), ESMF_LOGMSG_INFO) + else + call ESMF_LogWrite('restart time to be written for '//trim(timestr), ESMF_LOGMSG_INFO) + end if + end if + end do + deallocate(restart_fh) + end if !nfh>0 + call ESMF_ConfigDestroy(CF_mc, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + end if !model_configure + + end subroutine init_is_restart_fh + + subroutine is_restart_fh(clock, restartfh_info, lWrite) + ! + ! !DESCRIPTION: + ! True/false if time to write restart + ! + ! !USES: + use ESMF, only : ESMF_ClockGetNextTime + + ! + ! !ARGUMENTS: + type(ESMF_Clock), intent(in) :: clock + type(is_restart_fh_type), intent(inout) :: restartfh_info + logical, intent(out) :: lWrite ! time to write? + ! + ! !LOCAL VARIABLES: + integer :: nfh, rc + type(ESMF_Time) :: nextTime + !----------------------------------------------------------------------- + + restartfh_info%write_restartfh = .false. + if (allocated(restartfh_info%restartFhTimes)) then + ! check if next time is == to any restartfhtime + do nfh = 1,size(restartfh_info%restartFhTimes) + call ESMF_ClockGetNextTime(clock, nextTime=nexttime, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (nextTime == restartfh_info%restartFhTimes(nfh)) restartfh_info%write_restartfh = .true. + end do + end if + + lWrite = restartfh_info%write_restartfh + + end subroutine is_restart_fh + + subroutine finalize_restart_fh(restartfh_info) + ! + ! !DESCRIPTION: + ! Clean-up...release allocated memory + ! + ! !USES: + ! + ! !ARGUMENTS: + type(is_restart_fh_type), intent(inout) :: restartfh_info + ! + ! !LOCAL VARIABLES: + !----------------------------------------------------------------------- + + if (allocated(restartfh_info%restartFhTimes)) deallocate(restartfh_info%restartFhTimes) + + end subroutine finalize_restart_fh + +end module shr_is_restart_fh_mod From 5c715db17308f78ba1ec4805266d223803f9efe1 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 23 Jan 2025 12:28:48 -0700 Subject: [PATCH 08/68] replace calls to esmf_logmsg_error with shr_abort --- docn/docn_import_data_mod.F90 | 5 +-- dshr/dshr_mod.F90 | 4 +-- share/nuopc_shr_methods.F90 | 62 ++++++++++------------------------- share/shr_abort_mod.F90 | 23 +++++++++---- streams/dshr_methods_mod.F90 | 53 ++++++++++-------------------- 5 files changed, 56 insertions(+), 91 deletions(-) diff --git a/docn/docn_import_data_mod.F90 b/docn/docn_import_data_mod.F90 index cb7d95136..150d15e46 100644 --- a/docn/docn_import_data_mod.F90 +++ b/docn/docn_import_data_mod.F90 @@ -1,7 +1,6 @@ module docn_import_data_mod use ESMF , only : ESMF_State, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_SUCCESS - use ESMF , only : ESMF_LOGMSG_ERROR, ESMF_FAILURE use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add @@ -99,9 +98,7 @@ subroutine docn_get_import_fields(str, flds, rc) valid = .false. end if if (.not. valid) then - call ESMF_LogWrite("ERROR: invalid list = "//trim(str), ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort("ERROR: invalid list = "//trim(str)) end if ! get number of fields in a colon delimited string list nflds = 0 diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index fb5010ace..7230e35a9 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -89,6 +89,7 @@ module dshr_mod subroutine dshr_model_initphase(gcomp, importState, exportState, clock, rc) use ESMF, only : ESMF_ClockIsCreated, ESMF_StateIsCreated + use shr_sys_mod, only : shr_sys_abort ! input/output variables type(ESMF_GridComp) :: gcomp type(ESMF_State) :: importState, exportState @@ -100,8 +101,7 @@ subroutine dshr_model_initphase(gcomp, importState, exportState, clock, rc) rc = ESMF_SUCCESS ! To prevent an unused variable warning if(.not. (ESMF_StateIsCreated(importState) .or. ESMF_StateIsCreated(exportState) .or. ESMF_ClockIsCreated(clock))) then - call ESMF_LogWrite(trim(subname)//' state or clock not created', ESMF_LOGMSG_ERROR) - + call shr_sys_abort(trim(subname)//' state or clock not created', ESMF_LOGMSG_ERROR) endif ! Switch to IPDv01 by filtering all other phaseMap entries diff --git a/share/nuopc_shr_methods.F90 b/share/nuopc_shr_methods.F90 index 7055cc83c..6d542e546 100644 --- a/share/nuopc_shr_methods.F90 +++ b/share/nuopc_shr_methods.F90 @@ -2,7 +2,7 @@ module nuopc_shr_methods use ESMF , only : operator(<), operator(/=), operator(+) use ESMF , only : operator(-), operator(*) , operator(>=) use ESMF , only : operator(<=), operator(>), operator(==), MOD - use ESMF , only : ESMF_LOGERR_PASSTHRU, ESMF_LogFoundError, ESMF_LOGMSG_ERROR, ESMF_MAXSTR + use ESMF , only : ESMF_LOGERR_PASSTHRU, ESMF_LogFoundError, ESMF_MAXSTR use ESMF , only : ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_FAILURE use ESMF , only : ESMF_State, ESMF_StateGet use ESMF , only : ESMF_Field, ESMF_FieldGet @@ -373,9 +373,7 @@ subroutine state_diagnose(State, string, rc) call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) endif else - call ESMF_LogWrite(trim(subname)//": ERROR rank not supported ", ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort(trim(subname)//": ERROR rank not supported ") endif enddo @@ -411,10 +409,8 @@ subroutine field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) ! ---------------------------------------------- if (.not.present(rc)) then - call ESMF_LogWrite(trim(subname)//": ERROR rc not present ", & - ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE - return + call shr_sys_abort(trim(subname)//": ERROR rc not present ", & + line=__LINE__, file=u_FILE_u) endif rc = ESMF_SUCCESS @@ -465,27 +461,21 @@ subroutine field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) ESMF_LOGMSG_INFO) elseif (lrank == 1) then if (.not.present(fldptr1)) then - call ESMF_LogWrite(trim(subname)//": ERROR missing rank=1 array ", & - ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE - return + call shr_abort_mod(trim(subname)//": ERROR missing rank=1 array ", & + line=__LINE__, file=u_FILE_u) endif call ESMF_FieldGet(field, farrayPtr=fldptr1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return elseif (lrank == 2) then if (.not.present(fldptr2)) then - call ESMF_LogWrite(trim(subname)//": ERROR missing rank=2 array ", & - ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE - return + call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array ", & + line=__LINE__, file=u_FILE_u) endif call ESMF_FieldGet(field, farrayPtr=fldptr2, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return else - call ESMF_LogWrite(trim(subname)//": ERROR in rank ", & - ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE - return + call shr_sys_abort(trim(subname)//": ERROR in rank ", & + line=__LINE__, file=u_FILE_u) endif endif ! status @@ -566,14 +556,10 @@ subroutine alarmInit( clock, alarm, option, & ! Error checks if (trim(option) == optdate) then if (.not. present(opt_ymd)) then - call ESMF_LogWrite(trim(subname)//trim(option)//' requires opt_ymd', ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort(trim(subname)//trim(option)//' requires opt_ymd') end if if (lymd < 0 .or. ltod < 0) then - call ESMF_LogWrite(subname//trim(option)//'opt_ymd, opt_tod invalid', ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort(subname//trim(option)//'opt_ymd, opt_tod invalid') end if else if (& trim(option) == optNSteps .or. trim(option) == trim(optNSteps)//'s' .or. & @@ -584,14 +570,10 @@ subroutine alarmInit( clock, alarm, option, & trim(option) == optNMonths .or. trim(option) == trim(optNMonths)//'s' .or. & trim(option) == optNYears .or. trim(option) == trim(optNYears)//'s' ) then if (.not.present(opt_n)) then - call ESMF_LogWrite(subname//trim(option)//' requires opt_n', ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort(subname//trim(option)//' requires opt_n') end if if (opt_n <= 0) then - call ESMF_LogWrite(subname//trim(option)//' invalid opt_n', ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort(subname//trim(option)//' invalid opt_n') end if end if call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) @@ -629,9 +611,7 @@ subroutine alarmInit( clock, alarm, option, & AlarmInterval = AlarmInterval * opt_n ! timestepinterval*0 is 0 of kind ESMF_TimeStepInterval if (mod(AlarmInterval, TimestepInterval) /= (TimestepInterval*0)) then - call ESMF_LogWrite(subname//'illegal Alarm setting for '//trim(alarmname), ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort(subname//'illegal Alarm setting for '//trim(alarmname)) endif update_nextalarm = .true. @@ -691,9 +671,7 @@ subroutine alarmInit( clock, alarm, option, & if (ChkErr(rc,__LINE__,u_FILE_u)) return case default - call ESMF_LogWrite(subname//'unknown option '//trim(option), ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort(subname//'unknown option '//trim(option)) end select @@ -804,14 +782,10 @@ integer function get_minimum_timestep(gcomp, rc) enddo if(get_minimum_timestep == huge(1)) then - call ESMF_LogWrite('minimum_timestep_error: this option is not supported ', ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort('minimum_timestep_error: this option is not supported ') endif if(get_minimum_timestep <= 0) then - call ESMF_LogWrite('minimum_timestep_error ERROR ', ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort('minimum_timestep_error ERROR ') endif end function get_minimum_timestep diff --git a/share/shr_abort_mod.F90 b/share/shr_abort_mod.F90 index 230cb61e2..a8d422f34 100644 --- a/share/shr_abort_mod.F90 +++ b/share/shr_abort_mod.F90 @@ -8,8 +8,9 @@ module shr_abort_mod ! when these routines were defined in shr_sys_mod.) use, intrinsic :: iso_fortran_env, only: output_unit, error_unit - use ESMF, only : ESMF_Finalize, ESMF_END_ABORT, ESMF_LOGMSG_ERROR, ESMF_LogWrite + use shr_kind_mod, only : shr_kind_in, shr_kind_cx + use shr_mpi_mod , only : shr_mpi_initialized, shr_mpi_abort use shr_log_mod , only : s_logunit => shr_log_Unit #ifdef CPRNAG @@ -34,14 +35,18 @@ module shr_abort_mod contains !=============================================================================== - subroutine shr_abort_abort(string,rc) + subroutine shr_abort_abort(string,rc, line, file) + use esmf, only : ESMF_LOGWRITE, ESMF_LOGMSG_ERROR ! Consistent stopping mechanism !----- arguments ----- character(len=*) , intent(in), optional :: string ! error message string integer(shr_kind_in), intent(in), optional :: rc ! error code + integer(shr_kind_in), intent(in), optional :: line + character(len=*), intent(in), optional :: file !----- local ----- + logical :: flag ! Local version of the string. ! (Gets a default value if string is not present.) @@ -56,13 +61,19 @@ subroutine shr_abort_abort(string,rc) call print_error_to_logs("ERROR", local_string) + call ESMF_LogWrite(local_string, ESMF_LOGMSG_ERROR, line=line, file=file) + call shr_abort_backtrace() - if(present(rc)) then - write(local_string, *) trim(local_string), ' rc=',rc + call shr_mpi_initialized(flag) + + if (flag) then + if (present(rc)) then + call shr_mpi_abort(trim(local_string),rc) + else + call shr_mpi_abort(trim(local_string)) + endif endif - call ESMF_LogWrite(local_string, ESMF_LOGMSG_ERROR) - call ESMF_Finalize(endflag=ESMF_END_ABORT) ! A compiler's abort method may print a backtrace or do other nice ! things, but in fact we can rarely leverage this, because MPI_Abort diff --git a/streams/dshr_methods_mod.F90 b/streams/dshr_methods_mod.F90 index 0ce787596..c5aa946d1 100644 --- a/streams/dshr_methods_mod.F90 +++ b/streams/dshr_methods_mod.F90 @@ -6,14 +6,15 @@ module dshr_methods_mod use ESMF , only : ESMF_LogWrite, ESMF_SUCCESS, ESMF_FAILURE use ESMF , only : ESMF_StateRemove, ESMF_StateGet, ESMF_RouteHandle use ESMF , only : ESMF_Region_Flag, ESMF_FieldStatus_Flag, ESMF_LOGMSG_INFO - use ESMF , only : ESMF_MAXSTR, ESMF_LOGMSG_ERROR, ESMF_LOGERR_PASSTHRU + use ESMF , only : ESMF_MAXSTR, ESMF_LOGERR_PASSTHRU use ESMF , only : ESMF_FieldBundleGet, ESMF_FieldBundleAdd, ESMF_FieldGet use ESMF , only : ESMF_REGION_TOTAL, ESMF_END_ABORT, ESMF_ITEMORDER_ADDORDER use ESMF , only : ESMF_LogFoundError, ESMF_FieldRegrid, ESMF_Finalize, ESMF_FIELDSTATUS_COMPLETE use ESMF , only : ESMF_TERMORDER_SRCSEQ, operator(/=) use ESMF , only : ESMF_TraceRegionEnter, ESMF_TraceRegionExit use shr_kind_mod , only : r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl - + use shr_sys_mod , only : shr_sys_abort + implicit none public @@ -139,9 +140,7 @@ subroutine dshr_state_diagnose(State, flds_scalar_name, string, rc) write(msgString,'(A,a)') trim(string)//': '//trim(lfieldnamelist(n))," no data" endif else - call ESMF_LogWrite(trim(subname)//": ERROR rank not supported ", ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort(trim(subname)//": ERROR rank not supported ") endif call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) end if @@ -177,9 +176,7 @@ subroutine dshr_fldbun_GetFldPtr(FB, fldname, fldptr1, fldptr2, rank, field, rc) rc = ESMF_SUCCESS if (.not. dshr_fldbun_FldChk(FB, trim(fldname), rc=rc)) then - call ESMF_LogWrite(trim(subname)//": ERROR field "//trim(fldname)//" not in FB ", ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort(trim(subname)//": ERROR field "//trim(fldname)//" not in FB ") endif call ESMF_FieldBundleGet(FB, fieldName=trim(fldname), field=lfield, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -187,20 +184,16 @@ subroutine dshr_fldbun_GetFldPtr(FB, fldname, fldptr1, fldptr2, rank, field, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (ungriddedUBound(1) > 0) then if (.not.present(fldptr2)) then - call ESMF_LogWrite(trim(subname)//": ERROR missing rank=2 array ", & - ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE - return + call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array ", & + line=__LINE__, file=u_FILE_u) endif call ESMF_FieldGet(lfield, farrayptr=fldptr2, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return lrank = 2 else if (.not.present(fldptr1)) then - call ESMF_LogWrite(trim(subname)//": ERROR missing rank=1 array ", & - ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE - return + call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array ", & + line=__LINE__, file=u_FILE_u) endif call ESMF_FieldGet(lfield, farrayptr=fldptr1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -339,9 +332,7 @@ subroutine dshr_fldbun_getNameN(FB, fieldnum, fieldname, rc) call ESMF_FieldBundleGet(FB, fieldCount=fieldCount, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (fieldnum > fieldCount) then - call ESMF_LogWrite(trim(subname)//": ERROR fieldnum > fieldCount ", ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort(trim(subname)//": ERROR fieldnum > fieldCount ") endif allocate(lfieldnamelist(fieldCount)) @@ -377,9 +368,7 @@ logical function dshr_fldbun_FldChk(FB, fldname, rc) call ESMF_FieldBundleGet(FB, fieldName=trim(fldname), isPresent=isPresent, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) then - call ESMF_LogWrite(trim(subname)//" Error checking field: "//trim(fldname), ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort(trim(subname)//" Error checking field: "//trim(fldname)) endif if (isPresent) then @@ -434,9 +423,7 @@ subroutine dshr_fldbun_Field_diagnose(FB, fieldname, string, rc) write(msgString,'(A,a)') trim(subname)//' '//trim(lstring)//': '//trim(fieldname)," no data" endif else - call ESMF_LogWrite(trim(subname)//": ERROR rank not supported ", ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort(trim(subname)//": ERROR rank not supported ") endif call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) @@ -505,9 +492,7 @@ subroutine dshr_fldbun_diagnose(FB, string, rc) endif else - call ESMF_LogWrite(trim(subname)//": ERROR rank not supported ", ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + call shr_sys_abort(trim(subname)//": ERROR rank not supported ") endif call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) enddo @@ -557,9 +542,7 @@ subroutine dshr_field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) if (labort) then call ESMF_FieldGet(field, name=name, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_LogWrite(trim(subname)//": field "//trim(name)//" has no data not allocated ", ESMF_LOGMSG_ERROR, rc=rc) - rc = ESMF_FAILURE - return + call shr_sys_abort(trim(subname)//": field "//trim(name)//" has no data not allocated ", rc=rc) else call ESMF_LogWrite(trim(subname)//": WARNING data not allocated ", ESMF_LOGMSG_INFO, rc=rc) endif @@ -568,8 +551,8 @@ subroutine dshr_field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (ungriddedUBound(1) > 0) then if (.not.present(fldptr2)) then - call ESMF_LogWrite(trim(subname)//": ERROR missing rank=2 array for "//trim(name), & - ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) + call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array for "//trim(name), & + line=__LINE__, file=u_FILE_u) rc = ESMF_FAILURE return endif @@ -578,8 +561,8 @@ subroutine dshr_field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) lrank = 2 else if (.not.present(fldptr1)) then - call ESMF_LogWrite(trim(subname)//": ERROR missing rank=1 array for "//trim(name), & - ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) + call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array for "//trim(name), & + line=__LINE__, file=u_FILE_u) rc = ESMF_FAILURE return endif From a4de12dcfa74442226adb8dce568fefee8d9fbfc Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 23 Jan 2025 12:57:03 -0700 Subject: [PATCH 09/68] use ESMF_FINALIZE here --- share/shr_abort_mod.F90 | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/share/shr_abort_mod.F90 b/share/shr_abort_mod.F90 index a8d422f34..f3fe018c8 100644 --- a/share/shr_abort_mod.F90 +++ b/share/shr_abort_mod.F90 @@ -10,7 +10,6 @@ module shr_abort_mod use, intrinsic :: iso_fortran_env, only: output_unit, error_unit use shr_kind_mod, only : shr_kind_in, shr_kind_cx - use shr_mpi_mod , only : shr_mpi_initialized, shr_mpi_abort use shr_log_mod , only : s_logunit => shr_log_Unit #ifdef CPRNAG @@ -36,7 +35,7 @@ module shr_abort_mod !=============================================================================== subroutine shr_abort_abort(string,rc, line, file) - use esmf, only : ESMF_LOGWRITE, ESMF_LOGMSG_ERROR + use esmf, only : ESMF_LOGWRITE, ESMF_LOGMSG_ERROR, ESMF_FINALIZE, ESMF_END_ABORT ! Consistent stopping mechanism !----- arguments ----- @@ -58,6 +57,9 @@ subroutine shr_abort_abort(string,rc, line, file) else local_string = "Unknown error submitted to shr_abort_abort." end if + if(present(rc)) then + write(local_string, *) trim(local_string), ' rc=',rc + endif call print_error_to_logs("ERROR", local_string) @@ -65,15 +67,7 @@ subroutine shr_abort_abort(string,rc, line, file) call shr_abort_backtrace() - call shr_mpi_initialized(flag) - - if (flag) then - if (present(rc)) then - call shr_mpi_abort(trim(local_string),rc) - else - call shr_mpi_abort(trim(local_string)) - endif - endif + call ESMF_Finalize(endflag=ESMF_END_ABORT) ! A compiler's abort method may print a backtrace or do other nice ! things, but in fact we can rarely leverage this, because MPI_Abort From 0e3a3cab0c5fe5334439ab1d784d3e90bd2e93b5 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 23 Jan 2025 13:18:37 -0700 Subject: [PATCH 10/68] remove unused variable --- share/shr_abort_mod.F90 | 3 --- 1 file changed, 3 deletions(-) diff --git a/share/shr_abort_mod.F90 b/share/shr_abort_mod.F90 index f3fe018c8..6e3a90680 100644 --- a/share/shr_abort_mod.F90 +++ b/share/shr_abort_mod.F90 @@ -44,9 +44,6 @@ subroutine shr_abort_abort(string,rc, line, file) integer(shr_kind_in), intent(in), optional :: line character(len=*), intent(in), optional :: file - !----- local ----- - logical :: flag - ! Local version of the string. ! (Gets a default value if string is not present.) character(len=shr_kind_cx) :: local_string From 3539203d74d16f4b2cfd58588113b1c9f3197ee1 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 23 Jan 2025 13:31:33 -0700 Subject: [PATCH 11/68] fix typo --- share/nuopc_shr_methods.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/nuopc_shr_methods.F90 b/share/nuopc_shr_methods.F90 index 6d542e546..f67e08f5f 100644 --- a/share/nuopc_shr_methods.F90 +++ b/share/nuopc_shr_methods.F90 @@ -461,7 +461,7 @@ subroutine field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) ESMF_LOGMSG_INFO) elseif (lrank == 1) then if (.not.present(fldptr1)) then - call shr_abort_mod(trim(subname)//": ERROR missing rank=1 array ", & + call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array ", & line=__LINE__, file=u_FILE_u) endif call ESMF_FieldGet(field, farrayPtr=fldptr1, rc=rc) From 27c145ba9c13e557c34a999d116f98607140d9f3 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 23 Jan 2025 13:43:14 -0700 Subject: [PATCH 12/68] fix syntax error --- dshr/dshr_mod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index 7230e35a9..7073ea923 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -101,7 +101,7 @@ subroutine dshr_model_initphase(gcomp, importState, exportState, clock, rc) rc = ESMF_SUCCESS ! To prevent an unused variable warning if(.not. (ESMF_StateIsCreated(importState) .or. ESMF_StateIsCreated(exportState) .or. ESMF_ClockIsCreated(clock))) then - call shr_sys_abort(trim(subname)//' state or clock not created', ESMF_LOGMSG_ERROR) + call shr_sys_abort(trim(subname)//' state or clock not created') endif ! Switch to IPDv01 by filtering all other phaseMap entries From c492b6add3a2ddf2707917fa098c5020003199ed Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 24 Jan 2025 11:45:50 -0700 Subject: [PATCH 13/68] add missing module import --- docn/docn_import_data_mod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docn/docn_import_data_mod.F90 b/docn/docn_import_data_mod.F90 index 150d15e46..ff4ba7d68 100644 --- a/docn/docn_import_data_mod.F90 +++ b/docn/docn_import_data_mod.F90 @@ -69,7 +69,7 @@ end subroutine docn_import_data_advertise !=============================================================================== subroutine docn_get_import_fields(str, flds, rc) - + use shr_sys_mod , only : shr_sys_abort ! input/output variables character(len=*) , intent(in) :: str ! colon deliminted string to search character(len=*) , allocatable , intent(out) :: flds(:) ! memory will be allocate for flds From 4aa602b05b63c96830af2bba2a066fe714cfdab8 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 30 Jan 2025 15:08:51 -0700 Subject: [PATCH 14/68] use shr_log_error and pass up stack --- datm/atm_comp_nuopc.F90 | 31 +++--- datm/datm_datamode_cfsr_mod.F90 | 1 - datm/datm_datamode_clmncep_mod.F90 | 17 ++-- datm/datm_datamode_core2_mod.F90 | 8 +- datm/datm_datamode_cplhist_mod.F90 | 1 - datm/datm_datamode_era5_mod.F90 | 1 - datm/datm_datamode_gefs_mod.F90 | 1 - datm/datm_datamode_jra_mod.F90 | 4 +- datm/datm_datamode_simple_mod.F90 | 7 +- dglc/dglc_datamode_noevolve_mod.F90 | 9 +- dglc/glc_comp_nuopc.F90 | 17 ++-- dice/dice_datamode_ssmi_mod.F90 | 1 - dice/ice_comp_nuopc.F90 | 11 ++- dlnd/lnd_comp_nuopc.F90 | 11 ++- docn/docn_datamode_aquaplanet_mod.F90 | 7 +- docn/docn_datamode_copyall_mod.F90 | 1 - docn/docn_datamode_cplhist_mod.F90 | 1 - docn/docn_datamode_iaf_mod.F90 | 2 - docn/docn_datamode_multilev_dom_mod.F90 | 8 +- docn/docn_datamode_multilev_mod.F90 | 5 +- docn/docn_datamode_som_mod.F90 | 1 - docn/ocn_comp_nuopc.F90 | 12 ++- drof/rof_comp_nuopc.F90 | 11 ++- dshr/dshr_dfield_mod.F90 | 26 +++-- dshr/dshr_mod.F90 | 124 ++++++++++++++++-------- dwav/wav_comp_nuopc.F90 | 9 +- streams/dshr_strdata_mod.F90 | 108 +++++++++++++-------- 27 files changed, 268 insertions(+), 167 deletions(-) diff --git a/datm/atm_comp_nuopc.F90 b/datm/atm_comp_nuopc.F90 index cfd25a782..174b5fd47 100644 --- a/datm/atm_comp_nuopc.F90 +++ b/datm/atm_comp_nuopc.F90 @@ -27,9 +27,8 @@ module cdeps_datm_comp use NUOPC_Model , only : NUOPC_ModelGet, setVM use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : shr_const_cday - use shr_sys_mod , only : shr_sys_abort use shr_cal_mod , only : shr_cal_ymd2date - use shr_log_mod , only : shr_log_setLogUnit + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use dshr_methods_mod , only : dshr_state_diagnose, chkerr, memcheck use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_init_from_config, shr_strdata_advance use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_setOrbs @@ -267,14 +266,16 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) open (newunit=nu,file=trim(nlfilename),status="old",action="read") call shr_nl_find_group_name(nu, 'datm_nml', status=ierr) if (ierr > 0) then - write(logunit,*) 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + rc = ierr + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if read (nu,nml=datm_nml,iostat=ierr) close(nu) if (ierr > 0) then - write(logunit,*) 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + rc = ierr + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if bcasttmp = 0 bcasttmp(1) = nx_global @@ -327,7 +328,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) else if (nextsw_cday_calc == 'cam6') then nextsw_cday_calc_cam7 = .false. else - call shr_sys_abort(' ERROR illegal datm nextsw_cday_calc = '//trim(nextsw_cday_calc)) + call shr_log_error(' ERROR illegal datm nextsw_cday_calc = '//trim(nextsw_cday_calc), rc=rc) + return end if ! write namelist input to standard out @@ -364,7 +366,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) trim(datamode) == 'ERA5' .or. & trim(datamode) == 'SIMPLE') then else - call shr_sys_abort(' ERROR illegal datm datamode = '//trim(datamode)) + call shr_log_error(' ERROR illegal datm datamode = '//trim(datamode), rc=rc) + return endif ! Advertise datm fields @@ -495,7 +498,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (isPresent .and. isSet) then read (cvalue,*) flds_scalar_index_nextsw_cday else - call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxNextSwCday') + call shr_log_error(subname//'Need to set attribute ScalarFieldIdxNextSwCday', rc=rc) + return endif nextsw_cday = getNextRadCDay(dayofYear, current_tod, stepno, idt, iradsw) @@ -656,7 +660,8 @@ subroutine datm_comp_run(gcomp, importState, exportState, target_ymd, target_tod call dshr_restart_read(restfilm, rpfile, logunit, my_task, mpicom, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return case default - call shr_sys_abort(subName//'datamode '//trim(datamode)//' not recognized') + call shr_log_error(subName//'datamode '//trim(datamode)//' not recognized', rc=rc) + return end select end if @@ -727,7 +732,8 @@ subroutine datm_comp_run(gcomp, importState, exportState, target_ymd, target_tod my_task, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return case default - call shr_sys_abort(subName//'datamode '//trim(datamode)//' not recognized') + call shr_log_error(subName//'datamode '//trim(datamode)//' not recognized', rc=rc) + return end select end if @@ -830,7 +836,8 @@ subroutine datm_init_dfields(rc) case('cpl_scalars') continue case default - call shr_sys_abort(subName//'field '//trim(lfieldnames(n))//' not recognized') + call shr_log_error(subName//'field '//trim(lfieldnames(n))//' not recognized', rc=rc) + return end select end if end do diff --git a/datm/datm_datamode_cfsr_mod.F90 b/datm/datm_datamode_cfsr_mod.F90 index ec1ab7a89..9f704425a 100644 --- a/datm/datm_datamode_cfsr_mod.F90 +++ b/datm/datm_datamode_cfsr_mod.F90 @@ -3,7 +3,6 @@ module datm_datamode_cfsr_mod use ESMF , only : ESMF_State, ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_precip_mod , only : shr_precip_partition_rain_snow_ramp use shr_const_mod , only : shr_const_tkfrz, shr_const_rhofw, shr_const_rdair use dshr_methods_mod , only : dshr_state_getfldptr, chkerr diff --git a/datm/datm_datamode_clmncep_mod.F90 b/datm/datm_datamode_clmncep_mod.F90 index 78b3bf4db..ccd75f4e3 100644 --- a/datm/datm_datamode_clmncep_mod.F90 +++ b/datm/datm_datamode_clmncep_mod.F90 @@ -4,7 +4,7 @@ module datm_datamode_clmncep_mod use ESMF , only : ESMF_STATEITEM_NOTFOUND, ESMF_LOGMSG_INFO, ESMF_StateGet, operator(/=) use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use shr_precip_mod , only : shr_precip_partition_rain_snow_ramp use shr_const_mod , only : shr_const_spval, shr_const_tkfrz, shr_const_pi use shr_const_mod , only : shr_const_pstd, shr_const_stebol, shr_const_rdair @@ -319,7 +319,8 @@ subroutine datm_datamode_clmncep_init_pointers(importState, exportState, sdat, r ! error check if (.not. associated(strm_wind) .or. .not. associated(strm_tbot)) then - call shr_sys_abort(trim(subname)//' ERROR: wind and tbot must be in streams for CLMNCEP') + call shr_log_error(trim(subname)//' ERROR: wind and tbot must be in streams for CLMNCEP', rc=rc) + return endif ! determine anidrmax (see below for use) @@ -380,7 +381,8 @@ subroutine datm_datamode_clmncep_advance(mainproc, logunit, mpicom, rc) tbotmax = rtmp(2) if (mainproc) write(logunit,*) trim(subname),' tbotmax = ',tbotmax if(tbotmax <= 0) then - call shr_sys_abort(subname//'ERROR: bad value in tbotmax') + call shr_log_error(subname//'ERROR: bad value in tbotmax', rc=rc) + return endif ! determine anidrmax (see below for use) @@ -456,7 +458,8 @@ subroutine datm_datamode_clmncep_advance(mainproc, logunit, mpicom, rc) qsat = (0.622_r8 * e)/(pbot - 0.378_r8 * e) Sa_shum(n) = qsat else - call shr_sys_abort(subname//'ERROR: cannot compute shum') + call shr_log_error(subname//'ERROR: cannot compute shum', rc=rc) + return endif !--- density --- vp = (Sa_shum(n)*pbot) / (0.622_r8 + 0.378_r8 * Sa_shum(n)) @@ -493,7 +496,8 @@ subroutine datm_datamode_clmncep_advance(mainproc, logunit, mpicom, rc) swvdf = strm_swdn(n) * 0.50_r8 Faxa_swvdf(n) = (1._r8 - ratio_rvrf)*swvdf else - call shr_sys_abort(subName//'ERROR: cannot compute short-wave down') + call shr_log_error(subName//'ERROR: cannot compute short-wave down', rc=rc) + return endif !--- swnet: a diagnostic quantity --- @@ -517,7 +521,8 @@ subroutine datm_datamode_clmncep_advance(mainproc, logunit, mpicom, rc) Faxa_rainc(n) = strm_precn(n)*0.1_r8 Faxa_rainl(n) = strm_precn(n)*0.9_r8 else - call shr_sys_abort(subName//'ERROR: cannot compute rain and snow') + call shr_log_error(subName//'ERROR: cannot compute rain and snow', rc=rc) + return endif !--- split precip between rain & snow --- diff --git a/datm/datm_datamode_core2_mod.F90 b/datm/datm_datamode_core2_mod.F90 index 8b041f084..b874dcf98 100644 --- a/datm/datm_datamode_core2_mod.F90 +++ b/datm/datm_datamode_core2_mod.F90 @@ -17,7 +17,7 @@ module datm_datamode_core2_mod use pio , only : pio_closefile use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use shr_cal_mod , only : shr_cal_date2julian use shr_const_mod , only : shr_const_tkfrz, shr_const_pi use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type @@ -262,12 +262,14 @@ subroutine datm_datamode_core2_init_pointers(exportState, sdat, datamode, factor end if if (.not. associated(strm_prec) .or. .not. associated(strm_swdn)) then - call shr_sys_abort(trim(subname)//'ERROR: prec and swdn must be in streams for CORE2') + call shr_log_error(trim(subname)//'ERROR: prec and swdn must be in streams for CORE2', rc=rc) + return endif if (trim(datamode) == 'CORE2_IAF' ) then if (.not. associated(strm_tarcf)) then - call shr_sys_abort(trim(subname)//'tarcf must be in an input stream for CORE2_IAF') + call shr_log_error(trim(subname)//'tarcf must be in an input stream for CORE2_IAF', rc=rc) + return endif endif diff --git a/datm/datm_datamode_cplhist_mod.F90 b/datm/datm_datamode_cplhist_mod.F90 index ca53ed78d..c73b51efc 100644 --- a/datm/datm_datamode_cplhist_mod.F90 +++ b/datm/datm_datamode_cplhist_mod.F90 @@ -4,7 +4,6 @@ module datm_datamode_cplhist_mod use ESMF , only : ESMF_StateItem_Flag use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use dshr_methods_mod , only : dshr_state_getfldptr, chkerr use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_get_stream_pointer use dshr_strdata_mod , only : shr_strdata_type diff --git a/datm/datm_datamode_era5_mod.F90 b/datm/datm_datamode_era5_mod.F90 index 187c3b5d7..dad08baf9 100644 --- a/datm/datm_datamode_era5_mod.F90 +++ b/datm/datm_datamode_era5_mod.F90 @@ -3,7 +3,6 @@ module datm_datamode_era5_mod use ESMF , only : ESMF_State, ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_precip_mod , only : shr_precip_partition_rain_snow_ramp use shr_const_mod , only : shr_const_tkfrz, shr_const_rhofw, shr_const_rdair use dshr_methods_mod , only : dshr_state_getfldptr, chkerr diff --git a/datm/datm_datamode_gefs_mod.F90 b/datm/datm_datamode_gefs_mod.F90 index fb7a0b4dc..80d5716d8 100644 --- a/datm/datm_datamode_gefs_mod.F90 +++ b/datm/datm_datamode_gefs_mod.F90 @@ -3,7 +3,6 @@ module datm_datamode_gefs_mod use ESMF , only : ESMF_State, ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_precip_mod , only : shr_precip_partition_rain_snow_ramp use shr_const_mod , only : shr_const_tkfrz, shr_const_rhofw, shr_const_rdair use dshr_methods_mod , only : dshr_state_getfldptr, chkerr diff --git a/datm/datm_datamode_jra_mod.F90 b/datm/datm_datamode_jra_mod.F90 index 2e0e5ee67..6563bc3d8 100644 --- a/datm/datm_datamode_jra_mod.F90 +++ b/datm/datm_datamode_jra_mod.F90 @@ -5,7 +5,7 @@ module datm_datamode_jra_mod use ESMF , only : ESMF_StateItem_Flag, ESMF_STATEITEM_NOTFOUND, operator(/=) use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use shr_cal_mod , only : shr_cal_date2julian use shr_const_mod , only : shr_const_tkfrz, shr_const_pi, shr_const_rdair use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type @@ -226,7 +226,7 @@ subroutine datm_datamode_jra_init_pointers(exportState, sdat, rc) ! erro check if (.not. associated(strm_prec) .or. .not. associated(strm_swdn)) then - call shr_sys_abort(trim(subname)//'ERROR: prec and swdn must be in streams for CORE_IAF_JRA') + call shr_log_error(trim(subname)//'ERROR: prec and swdn must be in streams for CORE_IAF_JRA', rc=rc) endif end subroutine datm_datamode_jra_init_pointers diff --git a/datm/datm_datamode_simple_mod.F90 b/datm/datm_datamode_simple_mod.F90 index 454bceeac..ddd9e5a1c 100644 --- a/datm/datm_datamode_simple_mod.F90 +++ b/datm/datm_datamode_simple_mod.F90 @@ -25,7 +25,8 @@ module datm_datamode_simple_mod use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, dshr_fldbun_regrid, chkerr use dshr_strdata_mod , only : shr_strdata_type use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add - + use shr_log_mod , only : shr_log_error + implicit none private ! except @@ -117,7 +118,9 @@ subroutine datm_datamode_simple_advertise(exportState, fldsexport, flds_scalar_n read (nu,nml=const_forcing_nml,iostat=ierr) close(nu) if (ierr > 0) then - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + rc = ierr + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if bcasttmp = 0 diff --git a/dglc/dglc_datamode_noevolve_mod.F90 b/dglc/dglc_datamode_noevolve_mod.F90 index a7ed13592..608192a16 100644 --- a/dglc/dglc_datamode_noevolve_mod.F90 +++ b/dglc/dglc_datamode_noevolve_mod.F90 @@ -9,7 +9,7 @@ module dglc_datamode_noevolve_mod use ESMF , only : ESMF_VMGetCurrent, ESMF_VMBroadCast use NUOPC , only : NUOPC_Advertise, NUOPC_IsConnected use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use shr_const_mod , only : SHR_CONST_RHOICE, SHR_CONST_RHOSW, SHR_CONST_REARTH, SHR_CONST_TKFRZ use shr_const_mod , only : SHR_CONST_SPVAL use shr_cal_mod , only : shr_cal_datetod2string @@ -204,7 +204,8 @@ subroutine dglc_datamode_noevolve_init_pointers(NStateExp, NstateImp, rc) if (.not. NUOPC_IsConnected(NStateImp(ns), fieldName=field_in_tsrf)) then ! NOTE: the field is connected ONLY if the MED->GLC entry is in the nuopc.runconfig file ! This restriction occurs even if the field was advertised - call shr_sys_abort(trim(subname)//": MED->GLC must appear in run sequence") + call shr_log_error(trim(subname)//": MED->GLC must appear in run sequence", rc=rc) + return end if call dshr_state_getfldptr(NStateImp(ns), field_in_tsrf, fldptr1=Sl_tsrf(ns)%ptr, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -309,8 +310,8 @@ subroutine dglc_datamode_noevolve_advance(gcomp, pio_subsystem, io_type, io_form ! Create pioid and pio_iodesc at the module level inquire(file=trim(model_datafiles(ns)), exist=exists) if (.not.exists) then - write(6,'(a)')' ERROR: model input file '//trim(model_datafiles(ns))//' does not exist' - call shr_sys_abort() + call shr_log_error(' ERROR: model input file '//trim(model_datafiles(ns))//' does not exist', rc=rc) + return end if rcode = pio_openfile(pio_subsystem, pioid, io_type, trim(model_datafiles(ns)), pio_nowrite) call pio_seterrorhandling(pioid, PIO_BCAST_ERROR) diff --git a/dglc/glc_comp_nuopc.F90 b/dglc/glc_comp_nuopc.F90 index 39c6620fa..71b4583c0 100644 --- a/dglc/glc_comp_nuopc.F90 +++ b/dglc/glc_comp_nuopc.F90 @@ -28,9 +28,8 @@ module cdeps_dglc_comp use NUOPC_Model , only : model_label_Finalize => label_Finalize use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_cal_mod , only : shr_cal_ymd2date - use shr_log_mod , only : shr_log_setLogUnit + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use shr_string_mod , only : shr_string_listGetNum, shr_string_listGetName #ifdef CESMCOUPLED use shr_pio_mod , only : shr_pio_getiosys, shr_pio_getiotype, shr_pio_getioformat @@ -225,8 +224,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) read (nu,nml=dglc_nml,iostat=ierr) close(nu) if (ierr > 0) then - write(logunit,'(a,i8)') 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if ! Determine number of ice sheets @@ -284,7 +283,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if ( trim(datamode) == 'noevolve') then ! read stream, no import data ! do nothing else - call shr_sys_abort(' ERROR illegal dglc datamode = '//trim(datamode)) + call shr_log_error(' ERROR illegal dglc datamode = '//trim(datamode), rc=rc) + return endif ! Allocate module variables @@ -362,7 +362,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (isPresent .and. isSet) then read(cvalue,*) restart_read else - call shr_sys_abort(subname//' ERROR: read restart flag must be present') + call shr_log_error(subname//' ERROR: read restart flag must be present', rc=rc) + return end if ! Get the time to interpolate the stream data to @@ -390,8 +391,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (my_task == main_task) then inquire(file=trim(model_meshfiles(ns)), exist=exists) if (.not.exists) then - write(logunit,'(a)')' ERROR: model_meshfile '//trim(model_meshfiles(ns))//' does not exist' - call shr_sys_abort(trim(subname)//' ERROR: model_meshfile '//trim(model_meshfiles(ns))//' does not exist') + call shr_log_error(trim(subname)//' ERROR: model_meshfile '//trim(model_meshfiles(ns))//' does not exist', rc=rc) + return end if endif diff --git a/dice/dice_datamode_ssmi_mod.F90 b/dice/dice_datamode_ssmi_mod.F90 index 79c4ac372..20976c236 100644 --- a/dice/dice_datamode_ssmi_mod.F90 +++ b/dice/dice_datamode_ssmi_mod.F90 @@ -5,7 +5,6 @@ module dice_datamode_ssmi_mod use ESMF , only : ESMF_ArrayCreate, ESMF_ArrayDestroy, ESMF_GridComp use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_const_mod , only : shr_const_pi, shr_const_spval, shr_const_tkfrz, shr_const_latice use shr_frz_mod , only : shr_frz_freezetemp use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type diff --git a/dice/ice_comp_nuopc.F90 b/dice/ice_comp_nuopc.F90 index ad01ffdd0..fb204ed67 100644 --- a/dice/ice_comp_nuopc.F90 +++ b/dice/ice_comp_nuopc.F90 @@ -26,8 +26,7 @@ module cdeps_dice_comp use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_kind_mod , only : r8=>shr_kind_r8, cxx=>shr_kind_cxx, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : shr_const_pi - use shr_log_mod , only : shr_log_setLogUnit - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use shr_cal_mod , only : shr_cal_ymd2date, shr_cal_ymd2julian use dshr_mod , only : dshr_model_initphase, dshr_init, dshr_mesh_init, dshr_check_restart_alarm use dshr_mod , only : dshr_state_setscalar, dshr_set_runclock, dshr_log_clock_advance @@ -212,8 +211,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) read (nu,nml=dice_nml,iostat=ierr) close(nu) if (ierr > 0) then - write(logunit,*) 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + rc = ierr + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if ! write namelist input to standard out @@ -268,7 +268,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if ( trim(datamode) == 'ssmi' .or. trim(datamode) == 'ssmi_iaf') then if (my_task == main_task) write(logunit,*) ' dice datamode = ',trim(datamode) else - call shr_sys_abort(' ERROR illegal dice datamode = '//trim(datamode)) + call shr_log_error(' ERROR illegal dice datamode = '//trim(datamode), rc=rc) + return endif ! Advertise import and export fields diff --git a/dlnd/lnd_comp_nuopc.F90 b/dlnd/lnd_comp_nuopc.F90 index a40685bc7..3ad783862 100644 --- a/dlnd/lnd_comp_nuopc.F90 +++ b/dlnd/lnd_comp_nuopc.F90 @@ -23,9 +23,8 @@ module cdeps_dlnd_comp use NUOPC_Model , only : model_label_Finalize => label_Finalize use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_cal_mod , only : shr_cal_ymd2date - use shr_log_mod , only : shr_log_setLogUnit + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use dshr_methods_mod , only : dshr_state_getfldptr, dshr_state_diagnose, chkerr, memcheck use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_advance, shr_strdata_get_stream_domain use dshr_strdata_mod , only : shr_strdata_init_from_config @@ -204,8 +203,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) read (nu,nml=dlnd_nml,iostat=ierr) close(nu) if (ierr > 0) then - write(logunit,*) 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + rc = ierr + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if bcasttmp = 0 bcasttmp(1) = nx_global @@ -248,7 +248,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (trim(datamode) == 'copyall') then if (my_task == main_task) write(logunit,*) 'dlnd datamode = ',trim(datamode) else - call shr_sys_abort(' ERROR illegal dlnd datamode = '//trim(datamode)) + call shr_log_error(' ERROR illegal dlnd datamode = '//trim(datamode), rc=rc) + return end if call NUOPC_CompAttributeGet(gcomp, name='glc_nec', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return diff --git a/docn/docn_datamode_aquaplanet_mod.F90 b/docn/docn_datamode_aquaplanet_mod.F90 index e851e6d31..2ed8b7826 100644 --- a/docn/docn_datamode_aquaplanet_mod.F90 +++ b/docn/docn_datamode_aquaplanet_mod.F90 @@ -4,7 +4,7 @@ module docn_datamode_aquaplanet_mod use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : shr_const_TkFrz, shr_const_pi - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add @@ -167,7 +167,8 @@ subroutine docn_datamode_aquaplanet_advance(exportState, model_mesh, sst_option, ! Error checks if (sst_option < 1 .or. sst_option > 10) then - call shr_sys_abort ('docn_prescribed_sst: ERROR: sst_option must be between 1 and 10') + call shr_log_error ('docn_prescribed_sst: ERROR: sst_option must be between 1 and 10', rc=rc) + return end if ! Determine So_t in degrees C @@ -305,7 +306,7 @@ subroutine docn_datamode_aquaplanet_advance(exportState, model_mesh, sst_option, So_t(:) = So_t(:) + TkFrz else - call shr_sys_abort("ERROR: either sst_constant value or sst_option must be input") + call shr_log_error("ERROR: either sst_constant value or sst_option must be input", rc=rc) end if end subroutine docn_datamode_aquaplanet_advance diff --git a/docn/docn_datamode_copyall_mod.F90 b/docn/docn_datamode_copyall_mod.F90 index 1c447677d..a6628f56d 100644 --- a/docn/docn_datamode_copyall_mod.F90 +++ b/docn/docn_datamode_copyall_mod.F90 @@ -4,7 +4,6 @@ module docn_datamode_copyall_mod use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : shr_const_TkFrz, shr_const_pi, shr_const_ocn_ref_sal - use shr_sys_mod , only : shr_sys_abort use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add use dshr_strdata_mod , only : shr_strdata_type diff --git a/docn/docn_datamode_cplhist_mod.F90 b/docn/docn_datamode_cplhist_mod.F90 index f913ad467..f22b9650c 100644 --- a/docn/docn_datamode_cplhist_mod.F90 +++ b/docn/docn_datamode_cplhist_mod.F90 @@ -4,7 +4,6 @@ module docn_datamode_cplhist_mod use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : shr_const_TkFrz, shr_const_pi, shr_const_ocn_ref_sal - use shr_sys_mod , only : shr_sys_abort use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add use dshr_strdata_mod , only : shr_strdata_type diff --git a/docn/docn_datamode_iaf_mod.F90 b/docn/docn_datamode_iaf_mod.F90 index 7e56afd47..a4d0dc5ae 100644 --- a/docn/docn_datamode_iaf_mod.F90 +++ b/docn/docn_datamode_iaf_mod.F90 @@ -3,13 +3,11 @@ module docn_datamode_iaf_mod use ESMF , only : ESMF_SUCCESS, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_State use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_const_mod , only : shr_const_TkFrz, shr_const_pi, shr_const_ocn_ref_sal use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_strdata_mod , only : shr_strdata_type use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add - use pio implicit none private ! except diff --git a/docn/docn_datamode_multilev_dom_mod.F90 b/docn/docn_datamode_multilev_dom_mod.F90 index c6413f018..e292b8ade 100644 --- a/docn/docn_datamode_multilev_dom_mod.F90 +++ b/docn/docn_datamode_multilev_dom_mod.F90 @@ -4,7 +4,7 @@ module docn_datamode_multilev_dom_mod use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : shr_const_TkFrz, shr_const_pi, shr_const_ocn_ref_sal, shr_const_spval - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type, shr_strdata_get_stream_count @@ -168,7 +168,8 @@ subroutine docn_datamode_multilev_dom_advance(sdat, logunit, mainproc, rc) if (nlev_stream > 1) exit end do if (nlev_stream == 0) then - call shr_sys_abort(trim(subname)//" could not find vertical levels greater than 0") + call shr_log_error(trim(subname)//" could not find vertical levels greater than 0", rc=rc) + return end if allocate(stream_vlevs(nlev_stream)) stream_vlevs(:) = sdat%pstrm(stream_index)%stream_vlevs(:) @@ -210,7 +211,8 @@ subroutine docn_datamode_multilev_dom_advance(sdat, logunit, mainproc, rc) end if end do if (.not. level_found) then - call shr_sys_abort(trim(subname)//" could not find level bounds for vertical interpolation") + call shr_log_error(trim(subname)//" could not find level bounds for vertical interpolation", rc=rc) + return end if end do diff --git a/docn/docn_datamode_multilev_mod.F90 b/docn/docn_datamode_multilev_mod.F90 index 11f9dc43f..c3949a702 100644 --- a/docn/docn_datamode_multilev_mod.F90 +++ b/docn/docn_datamode_multilev_mod.F90 @@ -3,7 +3,7 @@ module docn_datamode_multilev_mod use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : shr_const_TkFrz, shr_const_pi, shr_const_ocn_ref_sal, shr_const_spval - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type @@ -175,7 +175,8 @@ subroutine docn_datamode_multilev_advance(sdat, logunit, mainproc, rc) end if end do if (.not. level_found) then - call shr_sys_abort("ERROR: could not find level bounds for vertical interpolation") + call shr_log_error("ERROR: could not find level bounds for vertical interpolation", rc=rc) + return end if end do diff --git a/docn/docn_datamode_som_mod.F90 b/docn/docn_datamode_som_mod.F90 index 92e51c0f8..b3947d697 100644 --- a/docn/docn_datamode_som_mod.F90 +++ b/docn/docn_datamode_som_mod.F90 @@ -6,7 +6,6 @@ module docn_datamode_som_mod use ESMF , only : ESMF_LogWrite use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_const_mod , only : shr_const_cpsw, shr_const_rhosw, shr_const_TkFrz use shr_const_mod , only : shr_const_TkFrzSw, shr_const_latice, shr_const_ocn_ref_sal use shr_const_mod , only : shr_const_zsrflyr, shr_const_pi diff --git a/docn/ocn_comp_nuopc.F90 b/docn/ocn_comp_nuopc.F90 index bb0d3e78b..7a94cd0f4 100644 --- a/docn/ocn_comp_nuopc.F90 +++ b/docn/ocn_comp_nuopc.F90 @@ -24,9 +24,8 @@ module cdeps_docn_comp use NUOPC_Model , only : model_label_Finalize => label_Finalize use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_cal_mod , only : shr_cal_ymd2date - use shr_log_mod , only : shr_log_setLogUnit + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use dshr_methods_mod , only : dshr_state_diagnose, chkerr, memcheck use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_advance, shr_strdata_init_from_config use dshr_mod , only : dshr_model_initphase, dshr_init, dshr_mesh_init, dshr_restart_read @@ -232,7 +231,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) close(nu) if (ierr > 0) then write(logunit,F00) 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if ! write namelist input to standard out @@ -308,7 +308,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) trim(datamode) == 'multilev_dom') then ! multilevel ocean input and sst export ! success do nothing else - call shr_sys_abort(' ERROR illegal docn datamode = '//trim(datamode)) + call shr_log_error(' ERROR illegal docn datamode = '//trim(datamode), rc=rc) + return endif ! Advertise docn fields @@ -653,7 +654,8 @@ subroutine docn_comp_run(gcomp, importState, exportState, clock, target_ymd, tar case('sst_aquap_analytic', 'sst_aquap_constant') ! Do nothing case default - call shr_sys_abort(subName//'datamode '//trim(datamode)//' not recognized') + call shr_log_error(subName//'datamode '//trim(datamode)//' not recognized', rc=rc) + return end select endif diff --git a/drof/rof_comp_nuopc.F90 b/drof/rof_comp_nuopc.F90 index 520057d90..739bc1490 100644 --- a/drof/rof_comp_nuopc.F90 +++ b/drof/rof_comp_nuopc.F90 @@ -25,9 +25,8 @@ module cdeps_drof_comp use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : SHR_CONST_SPVAL - use shr_sys_mod , only : shr_sys_abort use shr_cal_mod , only : shr_cal_ymd2date - use shr_log_mod , only : shr_log_setLogUnit + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use dshr_methods_mod , only : dshr_state_getfldptr, dshr_state_diagnose, chkerr, memcheck use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_advance, shr_strdata_get_stream_domain use dshr_strdata_mod , only : shr_strdata_init_from_config @@ -199,8 +198,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) read (nu,nml=drof_nml,iostat=ierr) close(nu) if (ierr > 0) then - write(logunit,*) 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + rc = ierr + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if ! write namelist input to standard out @@ -242,7 +242,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (trim(datamode) == 'copyall') then if (mainproc) write(logunit,*) 'drof datamode = ',trim(datamode) else - call shr_sys_abort(' ERROR illegal drof datamode = '//trim(datamode)) + call shr_log_error(' ERROR illegal drof datamode = '//trim(datamode), rc=rc) + return end if call dshr_fldList_add(fldsExport, trim(flds_scalar_name)) diff --git a/dshr/dshr_dfield_mod.F90 b/dshr/dshr_dfield_mod.F90 index 2f3b33d69..bbd411572 100644 --- a/dshr/dshr_dfield_mod.F90 +++ b/dshr/dshr_dfield_mod.F90 @@ -3,7 +3,7 @@ module dshr_dfield_mod use ESMF , only : ESMF_State, ESMF_FieldBundle, ESMF_MAXSTR, ESMF_SUCCESS use ESMF , only : ESMF_FieldBundleGet, ESMF_ITEMORDER_ADDORDER, ESMF_Field, ESMF_FieldGet use shr_kind_mod , only : r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl, cxx=>shr_kind_cxx - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_get_stream_count, shr_strdata_get_stream_fieldbundle use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfieldn, dshr_field_getfldptr, dshr_fldbun_getFldPtr use dshr_methods_mod , only : chkerr @@ -77,7 +77,8 @@ subroutine dshr_dfield_add_1d(dfields, sdat, state_fld, strm_fld, state, logunit allocate(dfield_new, stat=status) if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif dfield_new%next => dfields dfields => dfield_new @@ -154,7 +155,8 @@ subroutine dshr_dfield_add_1d_stateptr(dfields, sdat, state_fld, strm_fld, state allocate(dfield_new, stat=status) if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif dfield_new%next => dfields dfields => dfield_new @@ -253,7 +255,8 @@ subroutine dshr_dfield_add_2d(dfields, sdat, state_fld, strm_flds, state, & endif if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif ! determine stream fldnames array @@ -261,12 +264,14 @@ subroutine dshr_dfield_add_2d(dfields, sdat, state_fld, strm_flds, state, & allocate(dfield_new%stream_indices(nflds), stat=status) if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif allocate(dfield_new%fldbun_indices(nflds), stat=status) if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif dfield_new%stream_indices(:) = 0 dfield_new%fldbun_indices(:) = 0 @@ -358,7 +363,8 @@ subroutine dshr_dfield_add_2d_stateptr(dfields, sdat, state_fld, strm_flds, stat endif if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif ! determine stream fldnames array @@ -367,12 +373,14 @@ subroutine dshr_dfield_add_2d_stateptr(dfields, sdat, state_fld, strm_flds, stat allocate(dfield_new%stream_indices(nflds), stat=status) if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif allocate(dfield_new%fldbun_indices(nflds), stat=status) if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif ! loop through the field names in strm_flds diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index 7073ea923..ba3d12bfc 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -32,8 +32,7 @@ module dshr_mod use ESMF , only : ESMF_Region_Flag, ESMF_REGION_TOTAL, ESMF_MAXSTR, ESMF_RC_NOT_VALID use ESMF , only : ESMF_UtilStringUpperCase use shr_kind_mod , only : r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl, cx=>shr_kind_cx, cxx=>shr_kind_cxx, i8=>shr_kind_i8 - use shr_sys_mod , only : shr_sys_abort - use shr_log_mod , only : shr_log_setLogUnit + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use shr_cal_mod , only : shr_cal_noleap, shr_cal_gregorian, shr_cal_calendarname use shr_cal_mod , only : shr_cal_datetod2string, shr_cal_date2julian use shr_const_mod , only : shr_const_spval, shr_const_cday @@ -300,7 +299,8 @@ subroutine dshr_mesh_init(gcomp, sdat, nullstr, logunit, compname, model_nxg, mo if (isPresent .and. isSet) then read(cvalue,*) read_restart else - call shr_sys_abort(subname//' ERROR: read restart flag must be present') + call shr_log_error(subname//' ERROR: read restart flag must be present', rc=rc) + return end if ! obtain the single column lon and lat @@ -332,12 +332,14 @@ subroutine dshr_mesh_init(gcomp, sdat, nullstr, logunit, compname, model_nxg, mo inquire(file=trim(model_meshfile), exist=exists) if (.not.exists) then write(logunit, *)' ERROR: model_meshfile '//trim(model_meshfile)//' does not exist' - call shr_sys_abort(trim(subname)//' ERROR: model_meshfile '//trim(model_meshfile)//' does not exist') + call shr_log_error(trim(subname)//' ERROR: model_meshfile '//trim(model_meshfile)//' does not exist', rc=rc) + return end if inquire(file=trim(model_maskfile), exist=exists) if (.not.exists) then write(logunit, *)' ERROR: model_maskfile '//trim(model_maskfile)//' does not exist' - call shr_sys_abort(trim(subname)//' ERROR: model_maskfile '//trim(model_maskfile)//' does not exist') + call shr_log_error(trim(subname)//' ERROR: model_maskfile '//trim(model_maskfile)//' does not exist', rc=rc) + return end if endif @@ -438,7 +440,8 @@ subroutine dshr_mesh_create_scol(gcomp, compname, scol_lon, scol_lat, & if (ChkErr(rc,__LINE__,u_FILE_u)) return read(cvalue,*) model_frac(1) else - call shr_sys_abort('ERROR: currently component '//trim(compname)//' is not supported for single column') + call shr_log_error('ERROR: currently component '//trim(compname)//' is not supported for single column', rc=rc) + return end if ! Use center and come up with arbitrary area delta lon and lat = .1 degree @@ -683,10 +686,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optDate) if (.not. present(opt_ymd)) then - call shr_sys_abort(subname//trim(option)//' requires opt_ymd') + call shr_log_error(subname//trim(option)//' requires opt_ymd', rc=rc) + return end if if (lymd < 0 .or. ltod < 0) then - call shr_sys_abort(subname//trim(option)//'opt_ymd, opt_tod invalid') + call shr_log_error(subname//trim(option)//'opt_ymd, opt_tod invalid', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -696,13 +701,16 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optIfdays0) if (.not. present(opt_ymd)) then - call shr_sys_abort(subname//trim(option)//' requires opt_ymd') + call shr_log_error(subname//trim(option)//' requires opt_ymd', rc=rc) + return end if if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -712,10 +720,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNSteps) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -723,8 +733,14 @@ subroutine dshr_alarm_init( clock, alarm, option, & update_nextalarm = .true. case (optNStep) - if (.not.present(opt_n)) call shr_sys_abort(subname//trim(option)//' requires opt_n') - if (opt_n <= 0) call shr_sys_abort(subname//trim(option)//' invalid opt_n') + if (.not.present(opt_n)) then + call shr_log_error(subname//trim(option)//' requires opt_n',rc=rc) + return + endif + if (opt_n <= 0) then + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return + endif call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return AlarmInterval = AlarmInterval * opt_n @@ -732,10 +748,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNSeconds) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -744,10 +762,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNSecond) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -757,20 +777,24 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNMinutes) call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if AlarmInterval = AlarmInterval * opt_n update_nextalarm = .true. case (optNMinute) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -779,10 +803,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNHours) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -791,10 +817,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNHour) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -803,10 +831,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNDays) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -815,10 +845,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNDay) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -827,10 +859,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNMonths) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -839,10 +873,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNMonth) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -858,10 +894,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNYears) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -870,10 +908,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNYear) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -888,7 +928,8 @@ subroutine dshr_alarm_init( clock, alarm, option, & update_nextalarm = .true. case default - call shr_sys_abort(subname//'unknown option '//trim(option)) + call shr_log_error(subname//'unknown option '//trim(option), rc=rc) + return end select ! -------------------------------------------------------------------------------- @@ -935,7 +976,8 @@ subroutine dshr_time_init( Time, ymd, cal, tod, rc) rc = ESMF_SUCCESS if ( (ymd < 0) .or. (tod < 0) .or. (tod > SecPerDay) )then - call shr_sys_abort( subname//'ERROR yymmdd is a negative number or time-of-day out of bounds' ) + call shr_log_error( subname//'ERROR yymmdd is a negative number or time-of-day out of bounds', rc=rc ) + return end if tdate = abs(ymd) diff --git a/dwav/wav_comp_nuopc.F90 b/dwav/wav_comp_nuopc.F90 index 61150fedd..07e6dc50e 100644 --- a/dwav/wav_comp_nuopc.F90 +++ b/dwav/wav_comp_nuopc.F90 @@ -23,9 +23,8 @@ module cdeps_dwav_comp use NUOPC_Model , only : model_label_Finalize => label_Finalize use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_cal_mod , only : shr_cal_ymd2date - use shr_log_mod , only : shr_log_setLogUnit + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use dshr_methods_mod , only : dshr_state_getfldptr, chkerr, memcheck, dshr_state_diagnose use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_advance use dshr_strdata_mod , only : shr_strdata_init_from_config @@ -198,7 +197,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) close(nu) if (ierr > 0) then write(logunit,*) 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if ! write namelist input to standard out @@ -240,7 +240,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (trim(datamode) == 'copyall') then if (my_task == main_task) write(logunit,*) 'dwav datamode = ',trim(datamode) else - call shr_sys_abort(' ERROR illegal dwav datamode = '//trim(datamode)) + call shr_log_error(' ERROR illegal dwav datamode = '//trim(datamode), rc=rc) + return end if call dwav_comp_advertise(importState, exportState, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return diff --git a/streams/dshr_strdata_mod.F90 b/streams/dshr_strdata_mod.F90 index c9ba174a2..894afbbb3 100644 --- a/streams/dshr_strdata_mod.F90 +++ b/streams/dshr_strdata_mod.F90 @@ -22,7 +22,7 @@ module dshr_strdata_mod use ESMF , only : ESMF_LOGMSG_INFO, ESMF_LogWrite use shr_kind_mod , only : r8=>shr_kind_r8, r4=>shr_kind_r4, i2=>shr_kind_I2 use shr_kind_mod , only : cs=>shr_kind_cs, cl=>shr_kind_cl, cxx=>shr_kind_cxx, cx=>shr_kind_cx - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use shr_const_mod , only : shr_const_pi, shr_const_cDay, shr_const_spval use shr_cal_mod , only : shr_cal_calendarname, shr_cal_timeSet use shr_cal_mod , only : shr_cal_noleap, shr_cal_gregorian @@ -170,11 +170,14 @@ type(ESMF_FieldBundle) function shr_strdata_get_stream_fieldbundle(sdat, ns, nam else if (trim(name) .eq. 'model_ub') then shr_strdata_get_stream_fieldbundle = sdat%pstrm(ns)%fldbun_data(sdat%pstrm(ns)%stream_ub) else if (trim(name) .eq. 'stream_lb') then - call shr_sys_abort("should not be here") + call shr_log_error("should not be here", rc=rc) + return else if (trim(name) .eq. 'stream_ub') then - call shr_sys_abort("should not be here") + call shr_log_error("should not be here", rc=rc) + return else - call shr_sys_abort(trim(name)//' is not a recognized stream bundle name') + call shr_log_error(trim(name)//' is not a recognized stream bundle name', rc=rc) + return endif end function shr_strdata_get_stream_fieldbundle @@ -426,8 +429,8 @@ subroutine shr_strdata_init(sdat, model_clock, stream_name, rc) if (filename /= 'none' .and. mainproc) then inquire(file=trim(filename),exist=fileExists) if (.not. fileExists) then - write(sdat%stream(1)%logunit,'(a)') "ERROR: file does not exist: "//trim(fileName) - call shr_sys_abort(subName//"ERROR: file does not exist: "//trim(fileName)) + call shr_log_error(subName//"ERROR: file does not exist: "//trim(fileName)) + return end if endif ! @@ -599,7 +602,8 @@ subroutine shr_strdata_init(sdat, model_clock, stream_name, rc) else if (trim(sdat%stream(ns)%mapalgo) == 'none') then ! single point stream data, no action required. else - call shr_sys_abort('ERROR: map algo '//trim(sdat%stream(ns)%mapalgo)//' is not supported') + call shr_log_error('ERROR: map algo '//trim(sdat%stream(ns)%mapalgo)//' is not supported', rc=rc) + return end if end if @@ -616,17 +620,18 @@ subroutine shr_strdata_init(sdat, model_clock, stream_name, rc) ! check that for now u and v are only for single level fields if (stream_nlev > 1) then ! TODO: add support for u and v for multi level fields - call shr_sys_abort(subname//': vector fields are not currently supported for multi-level fields') + call shr_log_error(subname//': vector fields are not currently supported for multi-level fields', rc=rc) + return end if ! check that stream vector names are valid if (.not. shr_string_listIsValid(stream_vector_names)) then - write(sdat%stream(1)%logunit,*) trim(subname),' vec fldlist invalid m=',m,trim(stream_vector_names) - call shr_sys_abort(subname//': vec fldlist invalid:'//trim(stream_vector_names)) + call shr_log_error(subname//': vec fldlist invalid:'//trim(stream_vector_names), rc=rc) + return endif ! check that only 2 fields are contained for any vector pairing if (shr_string_listGetNum(stream_vector_names) /= 2) then - write(sdat%stream(1)%logunit,*) trim(subname),' vec fldlist ne 2 m=',m,trim(stream_vector_names) - call shr_sys_abort(subname//': vec fldlist ne 2:'//trim(stream_vector_names)) + call shr_log_error(subname//': vec fldlist ne 2:'//trim(stream_vector_names), rc=rc) + return endif ! create stream vector field sdat%pstrm(ns)%field_stream_vector = ESMF_FieldCreate(stream_mesh, & @@ -649,7 +654,8 @@ subroutine shr_strdata_init(sdat, model_clock, stream_name, rc) else if (esmf_caltype == ESMF_CALKIND_GREGORIAN) then sdat%model_calendar = trim(shr_cal_gregorian) else - call shr_sys_abort(subname//" ERROR bad ESMF calendar name "//trim(calendar)) + call shr_log_error(subname//" ERROR bad ESMF calendar name "//trim(calendar), rc=rc) + return end if ! print sdat output @@ -788,7 +794,8 @@ subroutine shr_strdata_get_stream_domain(sdat, stream_index, fldname, flddata, r flddata(:) = data_double(:) deallocate(data_double) else - call shr_sys_abort(subName//"ERROR: only real and double types are supported for stream domain read") + call shr_log_error(subName//"ERROR: only real and double types are supported for stream domain read", rc=rc) + return end if ! Free the memory associate with the iodesc and close the file @@ -969,7 +976,8 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) ! TODO: need to put in capability to read all stream data at once case default write(logunit,F00) "ERROR: Unsupported readmode : ", trim(sdat%stream(ns)%readmode) - call shr_sys_abort(subName//"ERROR: Unsupported readmode: "//trim(sdat%stream(ns)%readmode)) + call shr_log_error(subName//"ERROR: Unsupported readmode: "//trim(sdat%stream(ns)%readmode), rc=rc) + return end select if (debug > 0 .and. sdat%mainproc) then @@ -996,7 +1004,7 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) ! case (3), abort write(logunit,*) trim(subname),' ERROR: mismatch calendar ', & trim(sdat%model_calendar),':',trim(sdat%stream(ns)%calendar) - call shr_sys_abort(trim(subname)//' ERROR: mismatch calendar ') + call shr_log_error(trim(subname)//' ERROR: mismatch calendar ') endif else ! calendars are the same if(trim(sdat%model_calendar) == trim(shr_cal_gregorian)) then @@ -1053,7 +1061,8 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) dtime, sdat%pstrm(ns)%dtmax, sdat%pstrm(ns)%dtmin, sdat%stream(ns)%dtlimit write(6,*) trim(subName),' ERROR: ymdLB, todLB, ymdUB, todUB = ', & sdat%pstrm(ns)%ymdLB, sdat%pstrm(ns)%todLB, sdat%pstrm(ns)%ymdUB, sdat%pstrm(ns)%todUB - call shr_sys_abort(trim(subName)//' ERROR dt limit for stream, see atm.log output') + call shr_log_error(trim(subName)//' ERROR dt limit for stream, see atm.log output', rc=rc) + return endif endif endif @@ -1511,8 +1520,8 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & if (sdat%mainproc) then inquire(file=trim(fileName),exist=fileExists) if (.not. fileExists) then - write(sdat%stream(1)%logunit,F00) "ERROR: file does not exist: ", trim(fileName) - call shr_sys_abort(subName//"ERROR: file does not exist: "//trim(fileName)) + call shr_log_error(subName//"ERROR: file does not exist: "//trim(fileName), rc=rc) + return end if endif @@ -1557,7 +1566,8 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & if (stream_nlev == 1) then allocate(dataptr1d(1)) else - call shr_sys_abort("ERROR: multi-level streams always require a stream mesh") + call shr_log_error("ERROR: multi-level streams always require a stream mesh", rc=rc) + return end if end if @@ -1617,11 +1627,15 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & else if (pio_iovartype == PIO_SHORT) then rcode = pio_get_att(pioid, varid, "scale_factor", scale_factor) if(rcode /= PIO_NOERR) then - call shr_sys_abort('DATATYPE PIO_SHORT requires attributes scale_factor') + rc = rcode + call shr_log_error('DATATYPE PIO_SHORT requires attributes scale_factor', rc=rc) + return endif rcode = pio_get_att(pioid, varid, "add_offset", add_offset) if(rcode /= PIO_NOERR) then - call shr_sys_abort('DATATYPE PIO_SHORT requires attributes add_offset') + rc = rcode + call shr_log_error('DATATYPE PIO_SHORT requires attributes add_offset', rc=rc) + return endif rcode = pio_get_att(pioid, varid, "_FillValue", fillvalue_i2) endif @@ -1647,14 +1661,17 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & rcode = pio_get_var(pioid, varid,start=(/1,1,1,nt/),count=(/1,1,1,1/), ival=data_real2d) end if if ( rcode /= PIO_NOERR ) then - call shr_sys_abort(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf))) + rc = rcode + call shr_log_error(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf)), rc=rc) + return end if if (handlefill) then ! Single point streams are not allowed to have missing values if (stream%mapalgo == 'none' .and. any(data_real2d == fillvalue_r4)) then write(errmsg,*) ' ERROR: _Fillvalue found in stream input variable: '// trim(per_stream%fldlist_stream(nf)) if(sdat%mainproc) write(sdat%stream(1)%logunit,*) trim(errmsg) - call shr_sys_abort(errmsg) + call shr_log_error(errmsg, rc=rc) + return endif do lev = 1,stream_nlev do n = 1,size(dataptr2d, dim=2) @@ -1679,14 +1696,17 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & rcode = pio_get_var(pioid, varid,start=(/1,1,nt/),count=(/1,1,1/), ival=data_real1d) endif if ( rcode /= PIO_NOERR ) then - call shr_sys_abort(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf))) + rc = rcode + call shr_log_error(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf)), rc=rc) + return end if if (handlefill) then ! Single point streams are not allowed to have missing values if (stream%mapalgo == 'none' .and. any(data_real1d == fillvalue_r4)) then write(errmsg,*) ' ERROR: _Fillvalue found in stream input variable: '// trim(per_stream%fldlist_stream(nf)) if(sdat%mainproc) write(sdat%stream(1)%logunit,*) trim(errmsg) - call shr_sys_abort(errmsg) + call shr_log_error(errmsg, rc=rc) + return endif do n=1,size(dataptr1d) @@ -1712,14 +1732,16 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & rcode = pio_get_var(pioid, varid,start=(/1,1,1,nt/), count=(/1,1,1,1/), ival=data_dbl2d) end if if ( rcode /= PIO_NOERR ) then - call shr_sys_abort(' ERROR: reading in 2d double variable: '// trim(per_stream%fldlist_stream(nf))) + rc = rcode + call shr_log_error(' ERROR: reading in 2d double variable: '// trim(per_stream%fldlist_stream(nf)), rc=rc) + return end if if (handlefill) then ! Single point streams are not allowed to have missing values if (stream%mapalgo == 'none' .and. any(data_dbl2d == fillvalue_r8)) then write(errmsg,*) ' ERROR: _Fillvalue found in stream input variable: '// trim(per_stream%fldlist_stream(nf)) - if(sdat%mainproc) write(sdat%stream(1)%logunit,*) trim(errmsg) - call shr_sys_abort(errmsg) + call shr_log_error(errmsg, rc=rc) + return endif do lev = 1,stream_nlev do n = 1,size(dataptr2d, dim=2) @@ -1744,14 +1766,16 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & rcode = pio_get_var(pioid, varid,start=(/1,1,nt/), count=(/1,1,1/), ival=data_dbl1d) endif if ( rcode /= PIO_NOERR ) then - call shr_sys_abort(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf))) + rc = rcode + call shr_log_error(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf)), rc=rc) + return end if if (handlefill) then ! Single point streams are not allowed to have missing values if (stream%mapalgo == 'none' .and. any(data_dbl1d == fillvalue_r8)) then write(errmsg,*) ' ERROR: _Fillvalue found in stream input variable: '// trim(per_stream%fldlist_stream(nf)) - if(sdat%mainproc) write(sdat%stream(1)%logunit,*) trim(errmsg) - call shr_sys_abort(errmsg) + call shr_log_error(errmsg, rc=rc) + return endif do n = 1,size(dataptr1d) if (.not. shr_infnan_isnan(data_dbl1d(n)) .and. data_dbl1d(n) .ne. fillvalue_r8) then @@ -1778,7 +1802,9 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & rcode = pio_get_var(pioid, varid,start=(/1,1,1,nt/), count=(/1,1,1,1/), ival=data_short2d) end if if ( rcode /= PIO_NOERR ) then - call shr_sys_abort(' ERROR: reading in 2d short variable: '// trim(per_stream%fldlist_stream(nf))) + rc = rcode + call shr_log_error(' ERROR: reading in 2d short variable: '// trim(per_stream%fldlist_stream(nf)), rc=rc) + return end if if (handlefill) then do lev = 1,stream_nlev @@ -1804,7 +1830,9 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & rcode = pio_get_var(pioid, varid,start=(/1,1,nt/),count=(/1,1,1/), ival=data_short1d) endif if ( rcode /= PIO_NOERR ) then - call shr_sys_abort(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf))) + rc = rcode + call shr_log_error(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf)), rc=rc) + return end if if (handlefill) then do n=1,lsize @@ -1825,7 +1853,8 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & ! ----------------------------- ! pio_iovartype is not supported ! ----------------------------- - call shr_sys_abort(subName//"ERROR: only double, real and short types are supported for stream read") + call shr_log_error(subName//"ERROR: only double, real and short types are supported for stream read", rc=rc) + return end if @@ -1881,7 +1910,8 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & if (chkerr(rc,__LINE__,u_FILE_u)) return if (.not. ESMF_FieldIsCreated(per_stream%field_stream_vector)) then - call shr_sys_abort('ERROR: per_stream%field_stream_vector has not been created') + call shr_log_error('ERROR: per_stream%field_stream_vector has not been created', rc=rc) + return end if call ESMF_FieldRegrid(per_stream%field_stream_vector, field_vector_dst, per_stream%routehandle, & @@ -2052,12 +2082,14 @@ subroutine shr_strdata_set_stream_iodesc(sdat, per_stream, fldname, pioid, rc) per_stream%stream_pio_iodesc) else write(6,*)'ERROR: dimlens= ',dimlens - call shr_sys_abort(trim(subname)//' dimlens = 4 assumes a time dimension') + call shr_log_error(trim(subname)//' dimlens = 4 assumes a time dimension', rc=rc) + return end if else write(6,*)'ERROR: dimlens= ',dimlens - call shr_sys_abort(trim(subname)//' only ndims of 2 and 3 and 4 are currently supported') + call shr_log_error(trim(subname)//' only ndims of 2 and 3 and 4 are currently supported', rc=rc) + return end if ! deallocate memory From 3cd9f5b40fac5d33fb64a0bd73603664849143d9 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 30 Jan 2025 15:11:47 -0700 Subject: [PATCH 15/68] add the updated shr_log_mod and shr_abort_mod files --- share/shr_abort_mod.F90 | 44 ++-------------------------- share/shr_log_mod.F90 | 64 ++++++++++++++++++++++++++++++++++------- 2 files changed, 57 insertions(+), 51 deletions(-) diff --git a/share/shr_abort_mod.F90 b/share/shr_abort_mod.F90 index 6e3a90680..b651db2a2 100644 --- a/share/shr_abort_mod.F90 +++ b/share/shr_abort_mod.F90 @@ -7,10 +7,7 @@ module shr_abort_mod ! (shr_sys_abort, shr_sys_backtrace). (This is for consistency with older code, from ! when these routines were defined in shr_sys_mod.) - use, intrinsic :: iso_fortran_env, only: output_unit, error_unit - use shr_kind_mod, only : shr_kind_in, shr_kind_cx - use shr_log_mod , only : s_logunit => shr_log_Unit #ifdef CPRNAG ! NAG does not provide this as an intrinsic, but it does provide modules @@ -36,11 +33,12 @@ module shr_abort_mod !=============================================================================== subroutine shr_abort_abort(string,rc, line, file) use esmf, only : ESMF_LOGWRITE, ESMF_LOGMSG_ERROR, ESMF_FINALIZE, ESMF_END_ABORT + use shr_log_mod, only : shr_log_error ! Consistent stopping mechanism !----- arguments ----- character(len=*) , intent(in), optional :: string ! error message string - integer(shr_kind_in), intent(in), optional :: rc ! error code + integer(shr_kind_in), intent(inout), optional :: rc ! error code integer(shr_kind_in), intent(in), optional :: line character(len=*), intent(in), optional :: file @@ -58,9 +56,7 @@ subroutine shr_abort_abort(string,rc, line, file) write(local_string, *) trim(local_string), ' rc=',rc endif - call print_error_to_logs("ERROR", local_string) - - call ESMF_LogWrite(local_string, ESMF_LOGMSG_ERROR, line=line, file=file) + call shr_log_error(local_string, rc=rc, line=line, file=file) call shr_abort_backtrace() @@ -120,41 +116,7 @@ end subroutine xl_trbk #endif - flush(error_unit) - end subroutine shr_abort_backtrace !=============================================================================== - !=============================================================================== - subroutine print_error_to_logs(error_type, message) - ! This routine prints error messages to s_logunit (which is standard output - ! for most tasks in CESM) and also to standard error if s_logunit is a - ! file. - ! - ! It also flushes these output units. - - character(len=*), intent(in) :: error_type, message - - integer, allocatable :: log_units(:) - - integer :: i - - if (s_logunit == output_unit .or. s_logunit == error_unit) then - ! If the log unit number is standard output or standard error, just - ! print to that. - allocate(log_units(1), source=[s_logunit]) - else - ! Otherwise print the same message to both the log unit and standard - ! error. - allocate(log_units(2), source=[error_unit, s_logunit]) - end if - - do i = 1, size(log_units) - write(log_units(i),*) trim(error_type), ": ", trim(message) - flush(log_units(i)) - end do - - end subroutine print_error_to_logs - !=============================================================================== - end module shr_abort_mod diff --git a/share/shr_log_mod.F90 b/share/shr_log_mod.F90 index a7e4c70e3..7676294ae 100644 --- a/share/shr_log_mod.F90 +++ b/share/shr_log_mod.F90 @@ -16,7 +16,7 @@ module shr_log_mod use shr_kind_mod, only: shr_kind_in, shr_kind_cx use shr_strconvert_mod, only: toString - use, intrinsic :: iso_fortran_env, only: output_unit + use, intrinsic :: iso_fortran_env, only: output_unit, error_unit implicit none private @@ -31,6 +31,7 @@ module shr_log_mod public :: shr_log_OOBMsg public :: shr_log_setLogUnit public :: shr_log_getLogUnit + public :: shr_log_error ! !PUBLIC DATA MEMBERS: @@ -74,13 +75,13 @@ pure function shr_log_errMsg(file, line) character(len=SHR_KIND_CX) :: shr_log_errMsg character(len=*), intent(in) :: file integer , intent(in) :: line - + !EOP - + shr_log_errMsg = 'ERROR in '//trim(file)//' at line '//toString(line) - + end function shr_log_errMsg - + ! Create a message for an out of bounds error. pure function shr_log_OOBMsg(operation, bounds, idx) result(OOBMsg) @@ -88,19 +89,19 @@ pure function shr_log_OOBMsg(operation, bounds, idx) result(OOBMsg) ! occurred. A string containing the subroutine name is ideal, but more ! generic descriptions such as "read", "modify", or "insert" could be used. character(len=*), intent(in) :: operation - + ! Upper and lower bounds allowed for the operation. integer, intent(in) :: bounds(2) - + ! Index at which access was attempted. integer, intent(in) :: idx - + ! Output message character(len=:), allocatable :: OOBMsg - + allocate(OOBMsg, source=(operation//": "//toString(idx)//" not in range ["//& toString(bounds(1))//", "//toString(bounds(2))//"].")) - + end function shr_log_OOBMsg subroutine shr_log_setLogUnit(unit) @@ -117,4 +118,47 @@ subroutine shr_log_getLogUnit(unit) end subroutine shr_log_getLogUnit + subroutine shr_log_error(string, rc, line, file) + use esmf, only : ESMF_LOGWRITE, ESMF_LOGMSG_ERROR, ESMF_FINALIZE, ESMF_END_ABORT, ESMF_FAILURE, ESMF_SUCCESS + ! Consistent stopping mechanism + + !----- arguments ----- + character(len=*) , intent(in) :: string ! error message string + integer(shr_kind_in), intent(inout), optional :: rc ! error code + integer(shr_kind_in), intent(in), optional :: line + character(len=*), intent(in), optional :: file + + ! Local version of the string. + ! (Gets a default value if string is not present.) + character(len=shr_kind_cx) :: local_string + integer, allocatable :: log_units(:) + integer :: i + !------------------------------------------------------------------------------- + + local_string = trim(string) + if(present(rc)) then + if (rc /= ESMF_SUCCESS) then + write(local_string, *) trim(local_string), ' rc=',rc + endif + rc = ESMF_FAILURE + endif + + call ESMF_LogWrite(local_string, ESMF_LOGMSG_ERROR, line=line, file=file) + if (shr_log_unit == output_unit .or. shr_log_unit == error_unit) then + ! If the log unit number is standard output or standard error, just + ! print to that. + allocate(log_units(1), source=[shr_log_unit]) + else + ! Otherwise print the same message to both the log unit and standard + ! error. + allocate(log_units(2), source=[error_unit, shr_log_unit]) + end if + + do i = 1, size(log_units) + write(log_units(i),*) trim(local_string) + flush(log_units(i)) + end do + + end subroutine shr_log_error + end module shr_log_mod From 28f4aa073b4b1721150c83435d55e0b1a63804e7 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 30 Jan 2025 15:27:13 -0700 Subject: [PATCH 16/68] some need to remain shr_sys_abort (no return code available) --- streams/dshr_stream_mod.F90 | 72 +++++++++++++++++++++++------------- streams/dshr_tinterp_mod.F90 | 30 +++++++++------ 2 files changed, 65 insertions(+), 37 deletions(-) diff --git a/streams/dshr_stream_mod.F90 b/streams/dshr_stream_mod.F90 index e73fb19ca..8df6b9edc 100644 --- a/streams/dshr_stream_mod.F90 +++ b/streams/dshr_stream_mod.F90 @@ -16,7 +16,7 @@ module dshr_stream_mod ! ------------------------------------------------------------------------------- use shr_kind_mod , only : r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl, cxx=>shr_kind_cxx, cx=>shr_kind_cx - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use shr_const_mod , only : shr_const_cday use shr_string_mod , only : shr_string_leftalign_and_convert_tabs, shr_string_parseCFtunit use shr_cal_mod , only : shr_cal_noleap @@ -210,7 +210,8 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu Sdoc => parseFile(streamfilename, iostat=status) if (status /= 0) then - call shr_sys_abort("Could not parse file "//trim(streamfilename)) + call shr_log_error("Could not parse file "//trim(streamfilename), rc=rc) + return endif streamlist => getElementsByTagname(Sdoc, "stream_info") nstrms = getLength(streamlist) @@ -228,7 +229,8 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu if (streamdat(i)%taxmode /= shr_stream_taxis_cycle .and. & streamdat(i)%taxmode /= shr_stream_taxis_extend .and. & streamdat(i)%taxmode /= shr_stream_taxis_limit) then - call shr_sys_abort("tintalgo must have a value of either cycle, extend or limit") + call shr_log_error("tintalgo must have a value of either cycle, extend or limit", rc=rc) + return end if endif @@ -241,7 +243,8 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu streamdat(i)%mapalgo /= shr_stream_mapalgo_consf .and. & streamdat(i)%mapalgo /= shr_stream_mapalgo_consd .and. & streamdat(i)%mapalgo /= shr_stream_mapalgo_none) then - call shr_sys_abort("mapaglo must have a value of either bilinear, redist, nn, consf or consd") + call shr_log_error("mapaglo must have a value of either bilinear, redist, nn, consf or consd", rc=rc) + return end if endif @@ -253,7 +256,8 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu streamdat(i)%tInterpAlgo /= shr_stream_tinterp_nearest .and. & streamdat(i)%tInterpAlgo /= shr_stream_tinterp_linear .and. & streamdat(i)%tInterpAlgo /= shr_stream_tinterp_coszen) then - call shr_sys_abort("tintalgo must have a value of either lower, upper, nearest, linear or coszen") + call shr_log_error("tintalgo must have a value of either lower, upper, nearest, linear or coszen", rc=rc) + return end if endif @@ -266,21 +270,24 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu if(associated(p)) then call extractDataContent(p, streamdat(i)%yearFirst) else - call shr_sys_abort("yearFirst must be provided") + call shr_log_error("yearFirst must be provided", rc=rc) + return endif p=> item(getElementsByTagname(streamnode, "year_last"), 0) if(associated(p)) then call extractDataContent(p, streamdat(i)%yearLast) else - call shr_sys_abort("yearLast must be provided") + call shr_log_error("yearLast must be provided", rc=rc) + return endif p=> item(getElementsByTagname(streamnode, "year_align"), 0) if(associated(p)) then call extractDataContent(p, streamdat(i)%yearAlign) else - call shr_sys_abort("yearAlign must be provided") + call shr_log_error("yearAlign must be provided", rc=rc) + return endif p=> item(getElementsByTagname(streamnode, "dtlimit"), 0) @@ -297,14 +304,16 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu if (associated(p)) then call extractDataContent(p, streamdat(i)%meshfile) else - call shr_sys_abort("mesh file name must be provided") + call shr_log_error("mesh file name must be provided", rc=rc) + return endif p => item(getElementsByTagname(streamnode, "vectors"), 0) if (associated(p)) then call extractDataContent(p, streamdat(i)%stream_vectors) else - call shr_sys_abort("stream vectors must be provided") + call shr_log_error("stream vectors must be provided", rc=rc) + return endif ! Determine name of vertical dimension @@ -312,13 +321,15 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu if (associated(p)) then call extractDataContent(p, streamdat(i)%lev_dimname) else - call shr_sys_abort("stream vertical level dimension name must be provided") + call shr_log_error("stream vertical level dimension name must be provided", rc=rc) + return endif ! Determine input data files p => item(getElementsByTagname(streamnode, "datafiles"), 0) if (.not. associated(p)) then - call shr_sys_abort("stream data files must be provided") + call shr_log_error("stream data files must be provided", rc=rc) + return endif filelist => getElementsByTagname(p,"file") streamdat(i)%nfiles = getLength(filelist) @@ -428,7 +439,8 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu ! Error check if (trim(streamdat(i)%taxmode) == shr_stream_taxis_extend .and. streamdat(i)%dtlimit < 1.e10) then - call shr_sys_abort(trim(subName)//" ERROR: if taxmode value is extend set dtlimit to 1.e30") + call shr_log_error(trim(subName)//" ERROR: if taxmode value is extend set dtlimit to 1.e30", rc=rc) + return end if ! initialize flag that stream has been set streamdat(i)%init = .true. @@ -625,7 +637,8 @@ subroutine shr_stream_init_from_esmfconfig(streamfilename, streamdat, logunit, if( nstrms > 0 ) then allocate(streamdat(nstrms)) else - call shr_sys_abort("no stream_info in config file "//trim(streamfilename)) + call shr_log_error("no stream_info in config file "//trim(streamfilename), rc=rc) + return endif ! fill in non-default values for the streamdat attributes @@ -647,21 +660,24 @@ subroutine shr_stream_init_from_esmfconfig(streamfilename, streamdat, logunit, call ESMF_ConfigGetAttribute(CF,value=streamdat(i)%yearFirst,label="yearFirst"//mystrm//':', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else - call shr_sys_abort("yearFirst must be provided") + call shr_log_error("yearFirst must be provided", rc=rc) + return endif if( ESMF_ConfigGetLen(config=CF, label="yearLast"//mystrm//':', rc=rc) > 0 ) then call ESMF_ConfigGetAttribute(CF,value=streamdat(i)%yearLast,label="yearLast"//mystrm//':', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else - call shr_sys_abort("yearLast must be provided") + call shr_log_error("yearLast must be provided", rc=rc) + return endif if( ESMF_ConfigGetLen(config=CF, label="yearAlign"//mystrm//':', rc=rc) > 0 ) then call ESMF_ConfigGetAttribute(CF,value=streamdat(i)%yearAlign,label="yearAlign"//mystrm//':', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else - call shr_sys_abort("yearAlign must be provided") + call shr_log_error("yearAlign must be provided", rc=rc) + return endif call ESMF_ConfigGetAttribute(CF,value=streamdat(i)%dtlimit,label="dtlimit"//mystrm//':', rc=rc) @@ -674,21 +690,24 @@ subroutine shr_stream_init_from_esmfconfig(streamfilename, streamdat, logunit, call ESMF_ConfigGetAttribute(CF,value=streamdat(i)%meshfile,label="stream_mesh_file"//mystrm//':', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else - call shr_sys_abort("stream_mesh_file must be provided") + call shr_log_error("stream_mesh_file must be provided", rc=rc) + return endif if( ESMF_ConfigGetLen(config=CF, label="stream_vectors"//mystrm//':', rc=rc) > 0 ) then call ESMF_ConfigGetAttribute(CF,value=streamdat(i)%stream_vectors,label="stream_vectors"//mystrm//':', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else - call shr_sys_abort("stream_vectors must be provided") + call shr_log_error("stream_vectors must be provided", rc=rc) + return endif if( ESMF_ConfigGetLen(config=CF, label="stream_lev_dimname"//mystrm//':', rc=rc) > 0 ) then call ESMF_ConfigGetAttribute(CF,value=streamdat(i)%lev_dimname,label="stream_lev_dimname"//mystrm//':', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else - call shr_sys_abort("stream_lev_dimname must be provided") + call shr_log_error("stream_lev_dimname must be provided", rc=rc) + return endif ! Get a list of stream file names @@ -703,7 +722,8 @@ subroutine shr_stream_init_from_esmfconfig(streamfilename, streamdat, logunit, enddo deallocate(strm_tmpstrings) else - call shr_sys_abort("stream data files must be provided") + call shr_log_error("stream data files must be provided", rc=rc) + return endif ! Get name of stream variables in file and model @@ -718,7 +738,8 @@ subroutine shr_stream_init_from_esmfconfig(streamfilename, streamdat, logunit, enddo deallocate(strm_tmpstrings) else - call shr_sys_abort("stream data variables must be provided") + call shr_log_error("stream data variables must be provided", rc=rc) + return endif ! Initialize stream pio @@ -739,7 +760,8 @@ subroutine shr_stream_init_from_esmfconfig(streamfilename, streamdat, logunit, ! Error check if (trim(streamdat(i)%taxmode) == shr_stream_taxis_extend .and. streamdat(i)%dtlimit < 1.e10) then - call shr_sys_abort(trim(subName)//" ERROR: if taxmode value is extend set dtlimit to 1.e30") + call shr_log_error(trim(subName)//" ERROR: if taxmode value is extend set dtlimit to 1.e30", rc=rc) + return end if enddo ! end loop nstrm @@ -826,7 +848,6 @@ subroutine shr_stream_findBounds(strm, mDateIn, secIn, isroot_task, & cycle = .false. limit = .true. else - write(strm%logunit,*) trim(subName),' ERROR: illegal taxMode = ',trim(strm%taxMode) call shr_sys_abort(trim(subName)//' ERROR: illegal taxMode = '//trim(strm%taxMode)) endif @@ -872,7 +893,7 @@ subroutine shr_stream_findBounds(strm, mDateIn, secIn, isroot_task, & if (.not. strm%file(k)%haveData) then call shr_stream_readtCoord(strm, k, isroot_task, rCode) if ( rCode /= 0 )then - call shr_sys_abort(trim(subName)//" ERROR: readtCoord1") + call shr_log_error(trim(subName)//" ERROR: readtCoord1") end if end if do n=1,strm%file(k)%nt @@ -886,7 +907,6 @@ subroutine shr_stream_findBounds(strm, mDateIn, secIn, isroot_task, & end do end do A if (.not. strm%found_lvd) then - write(strm%logunit,F00) "ERROR: LVD not found, all data is before yearFirst" call shr_sys_abort(trim(subName)//" ERROR: LVD not found, all data is before yearFirst") else !--- LVD is in or beyond yearFirst, verify it is not beyond yearLast --- diff --git a/streams/dshr_tinterp_mod.F90 b/streams/dshr_tinterp_mod.F90 index ef634d120..ecaa15efe 100644 --- a/streams/dshr_tinterp_mod.F90 +++ b/streams/dshr_tinterp_mod.F90 @@ -7,7 +7,7 @@ module dshr_tInterp_mod use ESMF , only : ESMF_Time, ESMF_TimeInterval, ESMF_TimeIntervalGet use ESMF , only : ESMF_SUCCESS, operator(<), operator(-), operator(>), operator(==) use shr_kind_mod , only : i8=>shr_kind_i8, r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl, shr_kind_in - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use shr_cal_mod , only : shr_cal_timeSet, shr_cal_advDateInt, shr_cal_date2julian use shr_orb_mod , only : shr_orb_cosz, shr_orb_decl, SHR_ORB_UNDEF_REAL use shr_const_mod , only : SHR_CONST_PI @@ -88,7 +88,8 @@ subroutine shr_tInterp_getFactors(D1,S1,D2,S2,Din,Sin,f1,f2,calendar,logunit,alg ! --- always check that 1 <= 2, although we could relax this requirement --- if (itime2 < itime1) then write(logunit,F01) ' ERROR: itime2 < itime1 D=',D1,S1,D2,S2 - call shr_sys_abort(subName//' itime2 < itime1 ') + call shr_log_error(subName//' itime2 < itime1 ', rc=rc) + return endif f1 = -1.0 @@ -121,7 +122,8 @@ subroutine shr_tInterp_getFactors(D1,S1,D2,S2,Din,Sin,f1,f2,calendar,logunit,alg !--- check that itimein is between itime1 and itime2 --- if (itime2 < itimein .or. itime1 > itimein) then write(logunit,F02) ' ERROR illegal linear times: ',D1,S1,Din,Sin,D2,S2 - call shr_sys_abort(subName//' illegal itimes ') + call shr_log_error(subName//' illegal itimes ', rc=rc) + return endif if (itime2 == itime1) then f1 = 0.5_r8 @@ -135,8 +137,8 @@ subroutine shr_tInterp_getFactors(D1,S1,D2,S2,Din,Sin,f1,f2,calendar,logunit,alg f1 = real(snum,r8)/real(sden,r8) endif else - if (debug > 0) write(logunit,F00) 'ERROR: illegal lalgo option: ',trim(lalgo) - call shr_sys_abort(subName//' illegal algo option '//trim(lalgo)) + call shr_log_error(subName//' illegal algo option '//trim(lalgo), rc=rc) + return endif f2 = c1 - f1 @@ -145,8 +147,8 @@ subroutine shr_tInterp_getFactors(D1,S1,D2,S2,Din,Sin,f1,f2,calendar,logunit,alg if (f1 < c0-eps .or. f1 > c1+eps .or. & f2 < c0-eps .or. f2 > c1+eps .or. & abs(f1+f2-c1) > eps) then - if (debug > 0) write(logunit,F01) 'ERROR: illegal tInterp values ',f1,f2 - call shr_sys_abort(subName//' illegal tInterp values ') + call shr_log_error(subName//' illegal tInterp values ', rc=rc) + return endif if (debug > 0) then @@ -204,9 +206,11 @@ subroutine shr_tInterp_getAvgCosz(tavCosz, lon, lat, & ! error checks if (eccen == SHR_ORB_UNDEF_REAL) then - call shr_sys_abort(subname//' ERROR in orb params for coszen tinterp') + call shr_log_error(subname//' ERROR in orb params for coszen tinterp', rc=rc) + return else if (modeldt < 1) then - call shr_sys_abort(subname//' ERROR: model dt < 1 for coszen tinterp') + call shr_log_error(subname//' ERROR: model dt < 1 for coszen tinterp', rc=rc) + return endif !------------------------------------------------------------------------------- @@ -216,7 +220,10 @@ subroutine shr_tInterp_getAvgCosz(tavCosz, lon, lat, & !--- get LB & UB dates --- call shr_cal_timeSet(reday1,ymd1,tod1,calendar) call shr_cal_timeSet(reday2,ymd2,tod2,calendar) - if (reday1 > reday2) call shr_sys_abort(subname//'ERROR: lower-bound > upper-bound') + if (reday1 > reday2) then + call shr_log_error(subname//'ERROR: lower-bound > upper-bound', rc=rc) + return + endif timeint = reday2-reday1 call ESMF_TimeIntervalGet(timeint, s_i8=dtsec, rc=rc) @@ -299,7 +306,8 @@ subroutine shr_tInterp_getCosz(cosz, lon, lat, ymd, tod, & lsize = size(lon) if (lsize < 1 .or. size(lat) /= lsize .or. size(cosz) /= lsize) then write(6,*)'ERROR: lsize,size(lat),size(cosz) = ',lsize,size(lat),size(cosz) - call shr_sys_abort(subname//' ERROR: lon lat cosz sizes disagree') + call shr_log_error(subname//' ERROR: lon lat cosz sizes disagree', rc=rc) + return endif call shr_cal_date2julian(ymd, tod, calday, calendar) From da2ddae9a33aaa3ecada1f0e0dc0213d52c20d60 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 30 Jan 2025 16:01:18 -0700 Subject: [PATCH 17/68] need a msg here --- streams/dshr_stream_mod.F90 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/streams/dshr_stream_mod.F90 b/streams/dshr_stream_mod.F90 index 8df6b9edc..2e28ba788 100644 --- a/streams/dshr_stream_mod.F90 +++ b/streams/dshr_stream_mod.F90 @@ -1255,6 +1255,7 @@ subroutine shr_stream_readTCoord(strm, k, isroot_task, rc) integer :: old_handle ! previous setting of pio error handling real(R8) :: nsec ! elapsed secs on calendar date real(R8),allocatable :: tvar(:) + character(CX) :: msg character(*),parameter :: subname = '(shr_stream_readTCoord) ' !------------------------------------------------------------------------------- @@ -1334,9 +1335,9 @@ subroutine shr_stream_readTCoord(strm, k, isroot_task, rc) ! if offset is not zero, adjust strm%file(k)%date(n) and strm%file(k)%secs(n) if (strm%offset /= 0) then if (size(strm%file(k)%date) /= size(strm%file(k)%secs)) then - write(strm%logunit,'(a,2i7)') trim(subname)//" Incompatable date and secs sizes",& + write(msg ,'(a,2i7)') trim(subname)//" Incompatable date and secs sizes",& size(strm%file(k)%date), size(strm%file(k)%secs) - call shr_sys_abort() + call shr_sys_abort(trim(msg)) endif num = size(strm%file(k)%date) offin = strm%offset From f45f398a4d1ad3031093b85afaccca264e0dc60a Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 31 Jan 2025 07:58:03 -0700 Subject: [PATCH 18/68] no return code here, use abort --- streams/dshr_tinterp_mod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/streams/dshr_tinterp_mod.F90 b/streams/dshr_tinterp_mod.F90 index ecaa15efe..6f19b5c50 100644 --- a/streams/dshr_tinterp_mod.F90 +++ b/streams/dshr_tinterp_mod.F90 @@ -306,7 +306,7 @@ subroutine shr_tInterp_getCosz(cosz, lon, lat, ymd, tod, & lsize = size(lon) if (lsize < 1 .or. size(lat) /= lsize .or. size(cosz) /= lsize) then write(6,*)'ERROR: lsize,size(lat),size(cosz) = ',lsize,size(lat),size(cosz) - call shr_log_error(subname//' ERROR: lon lat cosz sizes disagree', rc=rc) + call shr_sys_abort(subname//' ERROR: lon lat cosz sizes disagree', file=__FILE__,line=__LINE__) return endif From f529284d46c8d9f13b6beacf0bccb9aa96e1d4eb Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 31 Jan 2025 07:59:39 -0700 Subject: [PATCH 19/68] no return code here, use abort --- streams/dshr_tinterp_mod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/streams/dshr_tinterp_mod.F90 b/streams/dshr_tinterp_mod.F90 index 6f19b5c50..fbc91e931 100644 --- a/streams/dshr_tinterp_mod.F90 +++ b/streams/dshr_tinterp_mod.F90 @@ -12,7 +12,7 @@ module dshr_tInterp_mod use shr_orb_mod , only : shr_orb_cosz, shr_orb_decl, SHR_ORB_UNDEF_REAL use shr_const_mod , only : SHR_CONST_PI use dshr_methods_mod , only : chkerr - + use shr_sys_mod , only : shr_sys_abort implicit none private ! except From 01b4d457d5d7f81bcfc1f69a6750205804b034c3 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 31 Jan 2025 08:07:30 -0700 Subject: [PATCH 20/68] no return code here, use abort --- streams/dshr_strdata_mod.F90 | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/streams/dshr_strdata_mod.F90 b/streams/dshr_strdata_mod.F90 index 894afbbb3..33f289fdb 100644 --- a/streams/dshr_strdata_mod.F90 +++ b/streams/dshr_strdata_mod.F90 @@ -44,7 +44,8 @@ module dshr_strdata_mod use dshr_tinterp_mod , only : shr_tInterp_getCosz, shr_tInterp_getAvgCosz, shr_tInterp_getFactors use dshr_methods_mod , only : dshr_fldbun_getfldptr, dshr_fldbun_getfieldN, dshr_fldbun_fldchk, chkerr use dshr_methods_mod , only : dshr_fldbun_diagnose, dshr_fldbun_regrid, dshr_field_getfldptr - + use shr_sys_mod , only : shr_sys_abort + use pio , only : file_desc_t, iosystem_desc_t, io_desc_t, var_desc_t use pio , only : pio_openfile, pio_closefile, pio_nowrite use pio , only : pio_seterrorhandling, pio_initdecomp, pio_freedecomp @@ -170,14 +171,11 @@ type(ESMF_FieldBundle) function shr_strdata_get_stream_fieldbundle(sdat, ns, nam else if (trim(name) .eq. 'model_ub') then shr_strdata_get_stream_fieldbundle = sdat%pstrm(ns)%fldbun_data(sdat%pstrm(ns)%stream_ub) else if (trim(name) .eq. 'stream_lb') then - call shr_log_error("should not be here", rc=rc) - return + call shr_sys_abort("should not be here") else if (trim(name) .eq. 'stream_ub') then - call shr_log_error("should not be here", rc=rc) - return + call shr_sys_abort("should not be here") else - call shr_log_error(trim(name)//' is not a recognized stream bundle name', rc=rc) - return + call shr_sys_abort(trim(name)//' is not a recognized stream bundle name') endif end function shr_strdata_get_stream_fieldbundle @@ -429,7 +427,7 @@ subroutine shr_strdata_init(sdat, model_clock, stream_name, rc) if (filename /= 'none' .and. mainproc) then inquire(file=trim(filename),exist=fileExists) if (.not. fileExists) then - call shr_log_error(subName//"ERROR: file does not exist: "//trim(fileName)) + call shr_log_error(subName//"ERROR: file does not exist: "//trim(fileName), rc=rc) return end if endif From 7025adbc2663f296db24fcbb7fa24cc5ec33f061 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 31 Jan 2025 08:12:54 -0700 Subject: [PATCH 21/68] clean up --- streams/dshr_strdata_mod.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/streams/dshr_strdata_mod.F90 b/streams/dshr_strdata_mod.F90 index 33f289fdb..9c3dde35e 100644 --- a/streams/dshr_strdata_mod.F90 +++ b/streams/dshr_strdata_mod.F90 @@ -390,7 +390,6 @@ subroutine shr_strdata_init(sdat, model_clock, stream_name, rc) type(ESMF_CalKind_Flag) :: esmf_caltype ! esmf calendar type character(CS) :: calendar ! calendar name integer :: ns ! stream index - integer :: m ! generic index character(CX) :: fileName ! generic file name integer :: nfld ! loop stream field index type(ESMF_Field) :: lfield ! temporary From 5c5514df28b3b3022337b09d82be3f05e255a114 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 31 Jan 2025 08:28:54 -0700 Subject: [PATCH 22/68] more cleanup --- datm/datm_datamode_simple_mod.F90 | 1 - docn/docn_import_data_mod.F90 | 5 ++-- dshr/dshr_mod.F90 | 5 ++-- streams/dshr_methods_mod.F90 | 44 ++++++++++++++++++------------- streams/dshr_stream_mod.F90 | 2 +- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/datm/datm_datamode_simple_mod.F90 b/datm/datm_datamode_simple_mod.F90 index ddd9e5a1c..e9db91118 100644 --- a/datm/datm_datamode_simple_mod.F90 +++ b/datm/datm_datamode_simple_mod.F90 @@ -18,7 +18,6 @@ module datm_datamode_simple_mod use pio , only : pio_closefile use NUOPC , only : NUOPC_Advertise use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_cal_mod , only : shr_cal_date2julian use shr_const_mod , only : shr_const_tkfrz, shr_const_pi use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type diff --git a/docn/docn_import_data_mod.F90 b/docn/docn_import_data_mod.F90 index ff4ba7d68..ea4b423c7 100644 --- a/docn/docn_import_data_mod.F90 +++ b/docn/docn_import_data_mod.F90 @@ -69,7 +69,7 @@ end subroutine docn_import_data_advertise !=============================================================================== subroutine docn_get_import_fields(str, flds, rc) - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error ! input/output variables character(len=*) , intent(in) :: str ! colon deliminted string to search character(len=*) , allocatable , intent(out) :: flds(:) ! memory will be allocate for flds @@ -98,7 +98,8 @@ subroutine docn_get_import_fields(str, flds, rc) valid = .false. end if if (.not. valid) then - call shr_sys_abort("ERROR: invalid list = "//trim(str)) + call shr_log_error("ERROR: invalid list = "//trim(str), rc=rc) + return end if ! get number of fields in a colon delimited string list nflds = 0 diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index ba3d12bfc..39822f051 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -88,7 +88,7 @@ module dshr_mod subroutine dshr_model_initphase(gcomp, importState, exportState, clock, rc) use ESMF, only : ESMF_ClockIsCreated, ESMF_StateIsCreated - use shr_sys_mod, only : shr_sys_abort + ! input/output variables type(ESMF_GridComp) :: gcomp type(ESMF_State) :: importState, exportState @@ -100,7 +100,8 @@ subroutine dshr_model_initphase(gcomp, importState, exportState, clock, rc) rc = ESMF_SUCCESS ! To prevent an unused variable warning if(.not. (ESMF_StateIsCreated(importState) .or. ESMF_StateIsCreated(exportState) .or. ESMF_ClockIsCreated(clock))) then - call shr_sys_abort(trim(subname)//' state or clock not created') + call shr_log_error(trim(subname)//' state or clock not created', rc=rc) + return endif ! Switch to IPDv01 by filtering all other phaseMap entries diff --git a/streams/dshr_methods_mod.F90 b/streams/dshr_methods_mod.F90 index c5aa946d1..59500d11d 100644 --- a/streams/dshr_methods_mod.F90 +++ b/streams/dshr_methods_mod.F90 @@ -13,7 +13,7 @@ module dshr_methods_mod use ESMF , only : ESMF_TERMORDER_SRCSEQ, operator(/=) use ESMF , only : ESMF_TraceRegionEnter, ESMF_TraceRegionExit use shr_kind_mod , only : r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error implicit none public @@ -108,6 +108,7 @@ subroutine dshr_state_diagnose(State, flds_scalar_name, string, rc) character(len=*),parameter :: subname='(dshr_state_diagnose)' ! ---------------------------------------------- + rc = ESMF_SUCCESS call ESMF_StateGet(state, itemCount=fieldCount, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return allocate(lfieldnamelist(fieldCount)) @@ -140,7 +141,8 @@ subroutine dshr_state_diagnose(State, flds_scalar_name, string, rc) write(msgString,'(A,a)') trim(string)//': '//trim(lfieldnamelist(n))," no data" endif else - call shr_sys_abort(trim(subname)//": ERROR rank not supported ") + call shr_log_error(trim(subname)//": ERROR rank not supported ", rc=rc) + return endif call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) end if @@ -176,7 +178,8 @@ subroutine dshr_fldbun_GetFldPtr(FB, fldname, fldptr1, fldptr2, rank, field, rc) rc = ESMF_SUCCESS if (.not. dshr_fldbun_FldChk(FB, trim(fldname), rc=rc)) then - call shr_sys_abort(trim(subname)//": ERROR field "//trim(fldname)//" not in FB ") + call shr_log_error(trim(subname)//": ERROR field "//trim(fldname)//" not in FB ", rc=rc) + return endif call ESMF_FieldBundleGet(FB, fieldName=trim(fldname), field=lfield, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -184,16 +187,18 @@ subroutine dshr_fldbun_GetFldPtr(FB, fldname, fldptr1, fldptr2, rank, field, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (ungriddedUBound(1) > 0) then if (.not.present(fldptr2)) then - call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array ", & - line=__LINE__, file=u_FILE_u) + call shr_log_error(trim(subname)//": ERROR missing rank=2 array ", & + line=__LINE__, file=u_FILE_u, rc=rc) + return endif call ESMF_FieldGet(lfield, farrayptr=fldptr2, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return lrank = 2 else if (.not.present(fldptr1)) then - call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array ", & - line=__LINE__, file=u_FILE_u) + call shr_log_error(trim(subname)//": ERROR missing rank=1 array ", & + line=__LINE__, file=u_FILE_u, rc=rc) + return endif call ESMF_FieldGet(lfield, farrayptr=fldptr1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -332,7 +337,8 @@ subroutine dshr_fldbun_getNameN(FB, fieldnum, fieldname, rc) call ESMF_FieldBundleGet(FB, fieldCount=fieldCount, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (fieldnum > fieldCount) then - call shr_sys_abort(trim(subname)//": ERROR fieldnum > fieldCount ") + call shr_log_error(trim(subname)//": ERROR fieldnum > fieldCount ", rc=rc) + return endif allocate(lfieldnamelist(fieldCount)) @@ -368,7 +374,8 @@ logical function dshr_fldbun_FldChk(FB, fldname, rc) call ESMF_FieldBundleGet(FB, fieldName=trim(fldname), isPresent=isPresent, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) then - call shr_sys_abort(trim(subname)//" Error checking field: "//trim(fldname)) + call shr_log_error(trim(subname)//" Error checking field: "//trim(fldname), rc=rc) + return endif if (isPresent) then @@ -423,7 +430,8 @@ subroutine dshr_fldbun_Field_diagnose(FB, fieldname, string, rc) write(msgString,'(A,a)') trim(subname)//' '//trim(lstring)//': '//trim(fieldname)," no data" endif else - call shr_sys_abort(trim(subname)//": ERROR rank not supported ") + call shr_log_error(trim(subname)//": ERROR rank not supported ", rc=rc) + return endif call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) @@ -492,7 +500,8 @@ subroutine dshr_fldbun_diagnose(FB, string, rc) endif else - call shr_sys_abort(trim(subname)//": ERROR rank not supported ") + call shr_log_error(trim(subname)//": ERROR rank not supported ", rc=rc) + return endif call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) enddo @@ -542,7 +551,8 @@ subroutine dshr_field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) if (labort) then call ESMF_FieldGet(field, name=name, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call shr_sys_abort(trim(subname)//": field "//trim(name)//" has no data not allocated ", rc=rc) + call shr_log_error(trim(subname)//": field "//trim(name)//" has no data not allocated ", rc=rc) + return else call ESMF_LogWrite(trim(subname)//": WARNING data not allocated ", ESMF_LOGMSG_INFO, rc=rc) endif @@ -551,9 +561,8 @@ subroutine dshr_field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (ungriddedUBound(1) > 0) then if (.not.present(fldptr2)) then - call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array for "//trim(name), & - line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE + call shr_log_error(trim(subname)//": ERROR missing rank=2 array for "//trim(name), & + line=__LINE__, file=u_FILE_u, rc=rc) return endif call ESMF_FieldGet(field, farrayptr=fldptr2, rc=rc) @@ -561,9 +570,8 @@ subroutine dshr_field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) lrank = 2 else if (.not.present(fldptr1)) then - call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array for "//trim(name), & - line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE + call shr_log_error(trim(subname)//": ERROR missing rank=1 array for "//trim(name), & + line=__LINE__, file=u_FILE_u, rc=rc) return endif call ESMF_FieldGet(field, farrayptr=fldptr1, rc=rc) diff --git a/streams/dshr_stream_mod.F90 b/streams/dshr_stream_mod.F90 index 2e28ba788..3ab2d586b 100644 --- a/streams/dshr_stream_mod.F90 +++ b/streams/dshr_stream_mod.F90 @@ -893,7 +893,7 @@ subroutine shr_stream_findBounds(strm, mDateIn, secIn, isroot_task, & if (.not. strm%file(k)%haveData) then call shr_stream_readtCoord(strm, k, isroot_task, rCode) if ( rCode /= 0 )then - call shr_log_error(trim(subName)//" ERROR: readtCoord1") + call shr_sys_abort(trim(subName)//" ERROR: readtCoord1") end if end if do n=1,strm%file(k)%nt From 2684ab76fe9f8e136b9336b757cd4226e323b6ef Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 3 Feb 2025 15:26:57 -0700 Subject: [PATCH 23/68] fix ref to shr_sys_abort --- streams/dshr_stream_mod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/streams/dshr_stream_mod.F90 b/streams/dshr_stream_mod.F90 index 3ab2d586b..64c7f542b 100644 --- a/streams/dshr_stream_mod.F90 +++ b/streams/dshr_stream_mod.F90 @@ -34,7 +34,7 @@ module dshr_stream_mod #ifdef CESMCOUPLED use shr_pio_mod , only : shr_pio_getiosys, shr_pio_getiotype, shr_pio_getioformat #endif - + use shr_sys_mod , only : shr_sys_abort implicit none private ! default private From 2385f03a9ebc45f58310073ff314e1d34e71b66d Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 7 Feb 2025 09:24:56 -0700 Subject: [PATCH 24/68] Make CRUJRA2024 the default datm input for clm6 --- datm/cime_config/config_component.xml | 27 ++++- datm/cime_config/namelist_definition_datm.xml | 3 + datm/cime_config/stream_definition_datm.xml | 109 ++++++++++++++++++ datm/cime_config/testdefs/testlist_datm.xml | 17 ++- doc/source/datm.rst | 8 +- 5 files changed, 156 insertions(+), 8 deletions(-) diff --git a/datm/cime_config/config_component.xml b/datm/cime_config/config_component.xml index 107929616..3e50d237e 100644 --- a/datm/cime_config/config_component.xml +++ b/datm/cime_config/config_component.xml @@ -10,9 +10,10 @@ This file may have atm desc entries. --> - Data driven ATM + Data driven ATM QIAN data set QIAN with water isotopes + CRUJRA 2024 data set CRUNCEP data set CLM CRU NCEP v7 data set GSWP3v1 data set @@ -42,13 +43,13 @@ char - CORE2_NYF,CORE2_IAF,CLM_QIAN,CLM_QIAN_WISO,1PT,CLMCRUNCEP,CLMCRUNCEPv7,CLMGSWP3v1,CLMNLDAS2,CPLHIST,CORE_IAF_JRA,CORE_IAF_JRA_1p4_2018,CORE_IAF_JRA_1p5_2023,ERA5,SIMPLE + CORE2_NYF,CORE2_IAF,CLM_QIAN,CLM_QIAN_WISO,1PT,CLMCRUJRA2024,CLMCRUNCEP,CLMCRUNCEPv7,CLMGSWP3v1,CLMNLDAS2,CPLHIST,CORE_IAF_JRA,CORE_IAF_JRA_1p4_2018,CORE_IAF_JRA_1p5_2023,ERA5,SIMPLE CORE2_NYF run_component_datm env_run.xml Mode for data atmosphere component. CORE2_NYF (CORE2 normal year forcing) are modes used in forcing prognostic ocean/sea-ice components. - CLMCRUNCEPv7, CLMGSWP3v1, CLMNLDAS2 and 1PT are modes using observational data for forcing prognostic land components. + CLMCRUJRA2024, CLMCRUNCEPv7, CLMGSWP3v1, CLMNLDAS2 and 1PT are modes using observational data for forcing prognostic land components. WARNING for CLMNLDAS2: This is a regional forcing dataset over the U.S. (25-53N, 235-293E). Garbage data will be produced for runs extending beyond this regional domain. CORE2_NYF @@ -58,6 +59,7 @@ CORE_IAF_JRA_1p5_2023 CLM_QIAN CLM_QIAN_WISO + CLMCRUJRA2024 CLMCRUNCEPv7 CLMGSWP3v1 CLMNLDAS2 @@ -217,13 +219,16 @@ $DATM_YR_START 1 + 1 1 1 1895 + 1901 1901 1901 $DATM_YR_START 1895 + 1901 1901 1901 $DATM_YR_START @@ -263,24 +268,32 @@ 1992 1 1948 + 1901 1901 1901 0 2000 1972 1948 + 1901 1901 1901 0 1948 + 1901 1901 1901 0 1948 1995 + 2001 2001 2001 2002 + 1901 + 1991 + 2002 + 2005 1901 1991 2002 @@ -317,24 +330,32 @@ 1992 2 1972 + 1920 1920 1920 -1 2004 2004 1972 + 1920 1920 1920 -1 1972 + 1920 1920 1920 -1 2004 2004 + 2023 2016 2014 2003 + 1920 + 2010 + 2003 + 2014 1920 2010 2003 diff --git a/datm/cime_config/namelist_definition_datm.xml b/datm/cime_config/namelist_definition_datm.xml index 17be1c1f8..ffa69bbb1 100644 --- a/datm/cime_config/namelist_definition_datm.xml +++ b/datm/cime_config/namelist_definition_datm.xml @@ -19,6 +19,9 @@ CLM_QIAN_WISO.Solar,CLM_QIAN_WISO.Precip,CLM_QIAN_WISO.TPQW + + CLMCRUJRA2024.Solar,CLMCRUJRA2024.Precip,CLMCRUJRA2024.TPQW + CLMCRUNCEPv7.Solar,CLMCRUNCEPv7.Precip,CLMCRUNCEPv7.TPQW diff --git a/datm/cime_config/stream_definition_datm.xml b/datm/cime_config/stream_definition_datm.xml index 07be39a6d..cace07623 100644 --- a/datm/cime_config/stream_definition_datm.xml +++ b/datm/cime_config/stream_definition_datm.xml @@ -29,6 +29,7 @@ Currently the following data modes are supported: CLM_QIAN = Run with the CLM Qian dataset valid from 1948 to 2004 (force CLM) CLM_QIAN_WISO = Run with the CLM Qian dataset with isotopes valid from 2000 to 2004 (force CLM) + CLMCRUJRA2024 = Run with the CLM CRUJRA 2024 forcing valid from 1901 to 2023 (force CLM) CLMCRUNCEPv7 = Run with the CLM CRU NCEP V7 forcing valid from 1900 to 2010 (force CLM) CLMGSWP3v1 = Run with the CLM GSWP3 V1 forcing (force CLM) CLMNLDAS2 = Run with the CLM NLDAS2 regional forcing valid from 1980 to 2018 (force CLM) @@ -68,6 +69,13 @@ CLMGSWP3v1.Precip CLMGSWP3v1.TPQW + ======================== + datm_mode CLMCRUJRA2024: (DATM%CRUJRA2024 in env_run.xml) + ======================== + CLMCRUJRA2024.Solar + CLMCRUJRA2024.Precip + CLMCRUJRA2024.TPQW + ======================== datm_mode CLMCRUNCEPv7: (DATM%CRUv7 in env_run.xml) ======================== @@ -489,6 +497,107 @@ single + + + + + + + $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c2024/TRENDY2024/inputs/three_stream/mesh_cdf5.nc + + + $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c2024/TRENDY2024/inputs/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.Solr.%y.nc + + + FSDS Faxa_swdn + + null + + bilinear + + null + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END + 0 + + coszen + + + cycle + + + 1.5 + + single + + + + + $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c2024/TRENDY2024/inputs/three_stream/mesh_cdf5.nc + + + $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c2024/TRENDY2024/inputs/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.Prec.%y.nc + + + PRECTmms Faxa_precn + + null + + bilinear + + null + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END + 0 + + nearest + + + cycle + + + 1.5 + + single + + + + + $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c2024/TRENDY2024/inputs/three_stream/mesh_cdf5.nc + + + $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c2024/TRENDY2024/inputs/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.TPQWL.%y.nc + + + TBOT Sa_tbot + WIND Sa_wind + QBOT Sa_shum + PSRF Sa_pbot + FLDS Faxa_lwdn + + null + + bilinear + + null + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END + 0 + + linear + + + cycle + + + 1.5 + + single + + diff --git a/datm/cime_config/testdefs/testlist_datm.xml b/datm/cime_config/testdefs/testlist_datm.xml index 34bbe3fcf..6425e08eb 100644 --- a/datm/cime_config/testdefs/testlist_datm.xml +++ b/datm/cime_config/testdefs/testlist_datm.xml @@ -25,7 +25,7 @@ - + @@ -34,7 +34,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -52,7 +52,16 @@ - + + + + + + + + + + diff --git a/doc/source/datm.rst b/doc/source/datm.rst index d731bc689..cb31a98e8 100644 --- a/doc/source/datm.rst +++ b/doc/source/datm.rst @@ -11,7 +11,7 @@ referred to as its mode. In the case of CESM, the active model components would be: CTSM, POP2, MOM6, POP2, CICE5-6, WW3 and MOSART. As examples, CORE2_NYF (CORE2 normal year forcing) is the DATM mode used in driving -POP2 and MOM6. On the other hand CLM_QIAN, CLMCRUNCEP, CLMGSWP3 +POP2 and MOM6. On the other hand CLM_QIAN, CLMCRUJRA2024, CLMCRUNCEP, CLMGSWP3 and CLM1PT are DATM modes using observational data for forcing CTSM. .. _datm-datamodes: @@ -123,6 +123,12 @@ DATM%CLM_QIAN - streams: CLM_QIAN.Solar,CLM_QIAN.Precip,CLM_QIAN.TPQW - datamode: CLMNCEP +DATM%CLMCRUJRA2024 + - CRUJRA atm input data (CESM I compsets) + - datm_mode: CLMCRUJRA2024 + - streams: CLMCRUJRA2024.Solar,CLMCRUJRA2024.Precip,CLMCRUJRA2024.TPQW + - datamode: CLMCRUJRA2024 + DATM%CLMCRUNCEPv7 - CRUNCEP atm input data (CESM I compsets) - datm_mode: CLMNCEP From 29b08fedfad96edec7d9ae0ea075c2b7419696b5 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 10 Feb 2025 07:01:00 -0700 Subject: [PATCH 25/68] response to comments --- datm/datm_datamode_jra_mod.F90 | 1 + docn/docn_datamode_aquaplanet_mod.F90 | 1 + streams/dshr_strdata_mod.F90 | 3 ++- streams/dshr_tinterp_mod.F90 | 1 - 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/datm/datm_datamode_jra_mod.F90 b/datm/datm_datamode_jra_mod.F90 index 6563bc3d8..13ef64ebf 100644 --- a/datm/datm_datamode_jra_mod.F90 +++ b/datm/datm_datamode_jra_mod.F90 @@ -227,6 +227,7 @@ subroutine datm_datamode_jra_init_pointers(exportState, sdat, rc) ! erro check if (.not. associated(strm_prec) .or. .not. associated(strm_swdn)) then call shr_log_error(trim(subname)//'ERROR: prec and swdn must be in streams for CORE_IAF_JRA', rc=rc) + return endif end subroutine datm_datamode_jra_init_pointers diff --git a/docn/docn_datamode_aquaplanet_mod.F90 b/docn/docn_datamode_aquaplanet_mod.F90 index 2ed8b7826..e988b6dc2 100644 --- a/docn/docn_datamode_aquaplanet_mod.F90 +++ b/docn/docn_datamode_aquaplanet_mod.F90 @@ -307,6 +307,7 @@ subroutine docn_datamode_aquaplanet_advance(exportState, model_mesh, sst_option, else call shr_log_error("ERROR: either sst_constant value or sst_option must be input", rc=rc) + return end if end subroutine docn_datamode_aquaplanet_advance diff --git a/streams/dshr_strdata_mod.F90 b/streams/dshr_strdata_mod.F90 index 9c3dde35e..4f04ab5f5 100644 --- a/streams/dshr_strdata_mod.F90 +++ b/streams/dshr_strdata_mod.F90 @@ -1001,7 +1001,8 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) ! case (3), abort write(logunit,*) trim(subname),' ERROR: mismatch calendar ', & trim(sdat%model_calendar),':',trim(sdat%stream(ns)%calendar) - call shr_log_error(trim(subname)//' ERROR: mismatch calendar ') + call shr_log_error(trim(subname)//' ERROR: mismatch calendar ', rc=rc) + return endif else ! calendars are the same if(trim(sdat%model_calendar) == trim(shr_cal_gregorian)) then diff --git a/streams/dshr_tinterp_mod.F90 b/streams/dshr_tinterp_mod.F90 index fbc91e931..104bea65e 100644 --- a/streams/dshr_tinterp_mod.F90 +++ b/streams/dshr_tinterp_mod.F90 @@ -307,7 +307,6 @@ subroutine shr_tInterp_getCosz(cosz, lon, lat, ymd, tod, & if (lsize < 1 .or. size(lat) /= lsize .or. size(cosz) /= lsize) then write(6,*)'ERROR: lsize,size(lat),size(cosz) = ',lsize,size(lat),size(cosz) call shr_sys_abort(subname//' ERROR: lon lat cosz sizes disagree', file=__FILE__,line=__LINE__) - return endif call shr_cal_date2julian(ymd, tod, calday, calendar) From e014b9e6f35d17c092753a38d354f95f7ab40a55 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 10 Feb 2025 07:03:29 -0700 Subject: [PATCH 26/68] additional documentation --- share/shr_log_mod.F90 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/share/shr_log_mod.F90 b/share/shr_log_mod.F90 index 7676294ae..b0e19e06c 100644 --- a/share/shr_log_mod.F90 +++ b/share/shr_log_mod.F90 @@ -120,7 +120,9 @@ end subroutine shr_log_getLogUnit subroutine shr_log_error(string, rc, line, file) use esmf, only : ESMF_LOGWRITE, ESMF_LOGMSG_ERROR, ESMF_FINALIZE, ESMF_END_ABORT, ESMF_FAILURE, ESMF_SUCCESS - ! Consistent stopping mechanism + ! This routine prints error messages to shr_log_unit (which is standard output + ! for most tasks in CESM), to the ESMF PET files and to standard error if shr_log_unit is a + ! file. Sets rc to ESMF_FAILURE on return. !----- arguments ----- character(len=*) , intent(in) :: string ! error message string From 44c52036fd0ea1e012f2e37415a7cb8ffcd46db0 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 10 Feb 2025 08:33:43 -0700 Subject: [PATCH 27/68] cleanup whitespace --- share/shr_log_mod.F90 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/share/shr_log_mod.F90 b/share/shr_log_mod.F90 index b0e19e06c..306c00752 100644 --- a/share/shr_log_mod.F90 +++ b/share/shr_log_mod.F90 @@ -75,13 +75,13 @@ pure function shr_log_errMsg(file, line) character(len=SHR_KIND_CX) :: shr_log_errMsg character(len=*), intent(in) :: file integer , intent(in) :: line - + !EOP - + shr_log_errMsg = 'ERROR in '//trim(file)//' at line '//toString(line) - + end function shr_log_errMsg - + ! Create a message for an out of bounds error. pure function shr_log_OOBMsg(operation, bounds, idx) result(OOBMsg) @@ -89,19 +89,19 @@ pure function shr_log_OOBMsg(operation, bounds, idx) result(OOBMsg) ! occurred. A string containing the subroutine name is ideal, but more ! generic descriptions such as "read", "modify", or "insert" could be used. character(len=*), intent(in) :: operation - + ! Upper and lower bounds allowed for the operation. integer, intent(in) :: bounds(2) - + ! Index at which access was attempted. integer, intent(in) :: idx - + ! Output message character(len=:), allocatable :: OOBMsg - + allocate(OOBMsg, source=(operation//": "//toString(idx)//" not in range ["//& toString(bounds(1))//", "//toString(bounds(2))//"].")) - + end function shr_log_OOBMsg subroutine shr_log_setLogUnit(unit) @@ -160,7 +160,7 @@ subroutine shr_log_error(string, rc, line, file) write(log_units(i),*) trim(local_string) flush(log_units(i)) end do - + end subroutine shr_log_error - + end module shr_log_mod From 15e93d3893fe6a49d99e15ee95d085408b325000 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 11 Feb 2025 15:18:07 -0700 Subject: [PATCH 28/68] Removed plain CRU from config_component.xml --- datm/cime_config/config_component.xml | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/datm/cime_config/config_component.xml b/datm/cime_config/config_component.xml index 3e50d237e..a0655e6d0 100644 --- a/datm/cime_config/config_component.xml +++ b/datm/cime_config/config_component.xml @@ -10,11 +10,10 @@ This file may have atm desc entries. --> - Data driven ATM + Data driven ATM QIAN data set QIAN with water isotopes CRUJRA 2024 data set - CRUNCEP data set CLM CRU NCEP v7 data set GSWP3v1 data set NLDAS2 regional 0.125 degree data set over the U.S. (25-53N, 235-293E). WARNING: Garbage data will be produced for runs extending beyond this regional domain. @@ -43,7 +42,7 @@ char - CORE2_NYF,CORE2_IAF,CLM_QIAN,CLM_QIAN_WISO,1PT,CLMCRUJRA2024,CLMCRUNCEP,CLMCRUNCEPv7,CLMGSWP3v1,CLMNLDAS2,CPLHIST,CORE_IAF_JRA,CORE_IAF_JRA_1p4_2018,CORE_IAF_JRA_1p5_2023,ERA5,SIMPLE + CORE2_NYF,CORE2_IAF,CLM_QIAN,CLM_QIAN_WISO,1PT,CLMCRUJRA2024,CLMCRUNCEPv7,CLMGSWP3v1,CLMNLDAS2,CPLHIST,CORE_IAF_JRA,CORE_IAF_JRA_1p4_2018,CORE_IAF_JRA_1p5_2023,ERA5,SIMPLE CORE2_NYF run_component_datm env_run.xml @@ -220,21 +219,16 @@ $DATM_YR_START 1 1 - 1 1 1895 1901 - 1901 1901 $DATM_YR_START 1895 1901 - 1901 1901 $DATM_YR_START - $DATM_YR_START $DATM_YR_START - 1 1 $DATM_YR_START $DATM_YR_START @@ -269,35 +263,27 @@ 1 1948 1901 - 1901 1901 0 2000 1972 1948 1901 - 1901 1901 0 1948 1901 - 1901 1901 0 1948 1995 2001 - 2001 2001 2002 1901 1991 2002 2005 - 1901 - 1991 - 2002 - 2005 1901 1991 2005 @@ -331,35 +317,27 @@ 2 1972 1920 - 1920 1920 -1 2004 2004 1972 1920 - 1920 1920 -1 1972 1920 - 1920 1920 -1 2004 2004 2023 - 2016 2014 2003 1920 2010 2003 2014 - 1920 - 2010 - 2003 - 2014 1920 2010 2014 From db187f789bd81547a7d57deacd542e4a0b7c6834 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 11 Feb 2025 15:31:22 -0700 Subject: [PATCH 29/68] Change testlist_datm following Erik's review --- datm/cime_config/testdefs/testlist_datm.xml | 29 ++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/datm/cime_config/testdefs/testlist_datm.xml b/datm/cime_config/testdefs/testlist_datm.xml index 6425e08eb..760394a56 100644 --- a/datm/cime_config/testdefs/testlist_datm.xml +++ b/datm/cime_config/testdefs/testlist_datm.xml @@ -25,7 +25,34 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 3000f0c5058ad8d294e338504a9dadd94052e94b Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 12 Feb 2025 13:16:56 -0700 Subject: [PATCH 30/68] Fix bug in four shr_sys_abort calls --- streams/dshr_methods_mod.F90 | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/streams/dshr_methods_mod.F90 b/streams/dshr_methods_mod.F90 index c5aa946d1..28ed956e9 100644 --- a/streams/dshr_methods_mod.F90 +++ b/streams/dshr_methods_mod.F90 @@ -14,6 +14,7 @@ module dshr_methods_mod use ESMF , only : ESMF_TraceRegionEnter, ESMF_TraceRegionExit use shr_kind_mod , only : r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : errMsg => shr_log_errMsg implicit none public @@ -184,16 +185,14 @@ subroutine dshr_fldbun_GetFldPtr(FB, fldname, fldptr1, fldptr2, rank, field, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (ungriddedUBound(1) > 0) then if (.not.present(fldptr2)) then - call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array ", & - line=__LINE__, file=u_FILE_u) + call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array "//errMsg(u_FILE_u, __LINE__)) endif call ESMF_FieldGet(lfield, farrayptr=fldptr2, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return lrank = 2 else if (.not.present(fldptr1)) then - call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array ", & - line=__LINE__, file=u_FILE_u) + call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array "//errMsg(u_FILE_u, __LINE__)) endif call ESMF_FieldGet(lfield, farrayptr=fldptr1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -551,8 +550,7 @@ subroutine dshr_field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (ungriddedUBound(1) > 0) then if (.not.present(fldptr2)) then - call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array for "//trim(name), & - line=__LINE__, file=u_FILE_u) + call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array for "//trim(name)//errMsg(u_FILE_u, __LINE__)) rc = ESMF_FAILURE return endif @@ -561,8 +559,7 @@ subroutine dshr_field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) lrank = 2 else if (.not.present(fldptr1)) then - call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array for "//trim(name), & - line=__LINE__, file=u_FILE_u) + call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array for "//trim(name)//errMsg(u_FILE_u, __LINE__)) rc = ESMF_FAILURE return endif From 6fa792e6fd8a7273216a9def6bbc72a0fdb20bad Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 12 Feb 2025 15:24:18 -0700 Subject: [PATCH 31/68] Add CRUv7 defaults previously set as CRU (the latter is removed now) --- datm/cime_config/config_component.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/datm/cime_config/config_component.xml b/datm/cime_config/config_component.xml index a0655e6d0..2b5cfd332 100644 --- a/datm/cime_config/config_component.xml +++ b/datm/cime_config/config_component.xml @@ -219,13 +219,16 @@ $DATM_YR_START 1 1 + 1 1 1895 1901 + 1901 1901 $DATM_YR_START 1895 1901 + 1901 1901 $DATM_YR_START $DATM_YR_START @@ -263,27 +266,35 @@ 1 1948 1901 + 1901 1901 0 2000 1972 1948 1901 + 1901 1901 0 1948 1901 + 1901 1901 0 1948 1995 2001 + 2001 2001 2002 1901 1991 2002 2005 + 1901 + 1991 + 2002 + 2005 1901 1991 2005 @@ -317,27 +328,35 @@ 2 1972 1920 + 1920 1920 -1 2004 2004 1972 1920 + 1920 1920 -1 1972 1920 + 1920 1920 -1 2004 2004 2023 + 2016 2014 2003 1920 2010 2003 2014 + 1920 + 2010 + 2003 + 2014 1920 2010 2014 From 1bcd85a904c009dd3576e241bf32e839fd3a2e3c Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 12 Feb 2025 15:46:05 -0700 Subject: [PATCH 32/68] Revert "Fix bug in four shr_sys_abort calls" This reverts commit 3000f0c5058ad8d294e338504a9dadd94052e94b. The alternative to get the same outcome is to update to share1.1.8 --- streams/dshr_methods_mod.F90 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/streams/dshr_methods_mod.F90 b/streams/dshr_methods_mod.F90 index 28ed956e9..c5aa946d1 100644 --- a/streams/dshr_methods_mod.F90 +++ b/streams/dshr_methods_mod.F90 @@ -14,7 +14,6 @@ module dshr_methods_mod use ESMF , only : ESMF_TraceRegionEnter, ESMF_TraceRegionExit use shr_kind_mod , only : r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl use shr_sys_mod , only : shr_sys_abort - use shr_log_mod , only : errMsg => shr_log_errMsg implicit none public @@ -185,14 +184,16 @@ subroutine dshr_fldbun_GetFldPtr(FB, fldname, fldptr1, fldptr2, rank, field, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (ungriddedUBound(1) > 0) then if (.not.present(fldptr2)) then - call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array "//errMsg(u_FILE_u, __LINE__)) + call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array ", & + line=__LINE__, file=u_FILE_u) endif call ESMF_FieldGet(lfield, farrayptr=fldptr2, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return lrank = 2 else if (.not.present(fldptr1)) then - call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array "//errMsg(u_FILE_u, __LINE__)) + call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array ", & + line=__LINE__, file=u_FILE_u) endif call ESMF_FieldGet(lfield, farrayptr=fldptr1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -550,7 +551,8 @@ subroutine dshr_field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (ungriddedUBound(1) > 0) then if (.not.present(fldptr2)) then - call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array for "//trim(name)//errMsg(u_FILE_u, __LINE__)) + call shr_sys_abort(trim(subname)//": ERROR missing rank=2 array for "//trim(name), & + line=__LINE__, file=u_FILE_u) rc = ESMF_FAILURE return endif @@ -559,7 +561,8 @@ subroutine dshr_field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) lrank = 2 else if (.not.present(fldptr1)) then - call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array for "//trim(name)//errMsg(u_FILE_u, __LINE__)) + call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array for "//trim(name), & + line=__LINE__, file=u_FILE_u) rc = ESMF_FAILURE return endif From 0fad468eecd981c2ccdaf97b2addf98931ff547a Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 12 Feb 2025 17:33:06 -0700 Subject: [PATCH 33/68] Small updates in config_component.xml that I missed earlier --- datm/cime_config/config_component.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/datm/cime_config/config_component.xml b/datm/cime_config/config_component.xml index 2b5cfd332..6d4ea0e22 100644 --- a/datm/cime_config/config_component.xml +++ b/datm/cime_config/config_component.xml @@ -231,8 +231,9 @@ 1901 1901 $DATM_YR_START + $DATM_YR_START + $DATM_YR_START $DATM_YR_START - 1 $DATM_YR_START $DATM_YR_START $DATM_YR_START From d73aa120320717a56a07e9aa1c434e9bd13c95ae Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 8 May 2024 17:20:44 -0600 Subject: [PATCH 34/68] Add Anomaly.Forcing.cmip5.rcp45. --- datm/cime_config/namelist_definition_datm.xml | 2 +- datm/cime_config/stream_definition_datm.xml | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/datm/cime_config/namelist_definition_datm.xml b/datm/cime_config/namelist_definition_datm.xml index 3c2be3995..c3efa072b 100644 --- a/datm/cime_config/namelist_definition_datm.xml +++ b/datm/cime_config/namelist_definition_datm.xml @@ -221,7 +221,7 @@ char(10) datm datm_nml - Anomaly.Forcing.Precip,Anomaly.Forcing.Temperature,Anomaly.Forcing.Pressure,Anomaly.Forcing.Humidity,Anomaly.Forcing.Uwind,Anomaly.Forcing.Vwind,Anomaly.Forcing.Shortwave,Anomaly.Forcing.Longwave + Anomaly.Forcing.cmip5.rcp45,Anomaly.Forcing.Precip,Anomaly.Forcing.Temperature,Anomaly.Forcing.Pressure,Anomaly.Forcing.Humidity,Anomaly.Forcing.Uwind,Anomaly.Forcing.Vwind,Anomaly.Forcing.Shortwave,Anomaly.Forcing.Longwave If set, include anomaly forcing streams in namelist. diff --git a/datm/cime_config/stream_definition_datm.xml b/datm/cime_config/stream_definition_datm.xml index bfe6fc4a0..d9ea4705d 100644 --- a/datm/cime_config/stream_definition_datm.xml +++ b/datm/cime_config/stream_definition_datm.xml @@ -1172,6 +1172,44 @@ + + + + $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/domain.permafrostRCN_P2.c2013.nc + + + $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.allvars.ccsm4.rcp45.2006-2300.nc + + + huss Sa_shum_af + pr Faxa_prec_af + ps Sa_pbot_af + rlds Faxa_lwdn_af + rsds Faxa_swdn_af + tas Sa_tbot_af + uas Sa_u_af + vas Sa_v_af + + null + + bilinear + + null + 2006 + 2006 + 2300 + 0 + + nearest + + + cycle + + + 1.5 + + single + From 2be33389562f0fbc681cf620109037f544744261 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 9 May 2024 13:40:29 -0600 Subject: [PATCH 35/68] Fix 'anomoly_forcing' typo. --- datm/cime_config/stream_definition_datm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datm/cime_config/stream_definition_datm.xml b/datm/cime_config/stream_definition_datm.xml index d9ea4705d..e98a397f0 100644 --- a/datm/cime_config/stream_definition_datm.xml +++ b/datm/cime_config/stream_definition_datm.xml @@ -208,7 +208,7 @@ topo.cplhist ======================== - optional streams anonomly forcing (turned on and set my datm_nml variable anomoly_forcing + optional streams anonomly forcing (turned on and set my datm_nml variable anomaly_forcing ======================== Anomaly.Forcing.Humidity Anomaly.Forcing.Longwave From a4d87b341237e4cd54db7f611b00a750239fdd05 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 8 Aug 2024 16:12:03 -0600 Subject: [PATCH 36/68] Update meshfile used for Anomaly.Forcing.*. --- datm/cime_config/stream_definition_datm.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/datm/cime_config/stream_definition_datm.xml b/datm/cime_config/stream_definition_datm.xml index e98a397f0..e916b5607 100644 --- a/datm/cime_config/stream_definition_datm.xml +++ b/datm/cime_config/stream_definition_datm.xml @@ -1175,7 +1175,7 @@ - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/domain.permafrostRCN_P2.c2013.nc + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.allvars.ccsm4.rcp45.2006-2300.nc @@ -1213,7 +1213,7 @@ - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/domain.permafrostRCN_P2.c2013.nc + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.pr.ccsm4.rcp45.2006-2300.nc @@ -1244,7 +1244,7 @@ - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/domain.permafrostRCN_P2.c2013.nc + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.tas.ccsm4.rcp45.2006-2300.nc @@ -1275,7 +1275,7 @@ - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/domain.permafrostRCN_P2.c2013.nc + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.ps.ccsm4.rcp45.2006-2300.nc @@ -1306,7 +1306,7 @@ - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/domain.permafrostRCN_P2.c2013.nc + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.huss.ccsm4.rcp45.2006-2300.nc @@ -1337,7 +1337,7 @@ - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/domain.permafrostRCN_P2.c2013.nc + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.uas.ccsm4.rcp45.2006-2300.nc @@ -1368,7 +1368,7 @@ - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/domain.permafrostRCN_P2.c2013.nc + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.vas.ccsm4.rcp45.2006-2300.nc @@ -1399,7 +1399,7 @@ - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/domain.permafrostRCN_P2.c2013.nc + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.rsds.ccsm4.rcp45.2006-2300.nc @@ -1430,7 +1430,7 @@ - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/domain.permafrostRCN_P2.c2013.nc + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.rlds.ccsm4.rcp45.2006-2300.nc From 5323a11531d6b266eedcc70c313d01a1e8d0d119 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 8 Aug 2024 16:21:45 -0600 Subject: [PATCH 37/68] Fix more typos of "anomaly." --- datm/cime_config/stream_definition_datm.xml | 2 +- datm/datm_datamode_clmncep_mod.F90 | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/datm/cime_config/stream_definition_datm.xml b/datm/cime_config/stream_definition_datm.xml index e916b5607..1ac68790c 100644 --- a/datm/cime_config/stream_definition_datm.xml +++ b/datm/cime_config/stream_definition_datm.xml @@ -1170,7 +1170,7 @@ - + diff --git a/datm/datm_datamode_clmncep_mod.F90 b/datm/datm_datamode_clmncep_mod.F90 index 41a9725c0..b892bc9e8 100644 --- a/datm/datm_datamode_clmncep_mod.F90 +++ b/datm/datm_datamode_clmncep_mod.F90 @@ -76,15 +76,15 @@ module datm_datamode_clmncep_mod ! stream data bias correction real(r8), pointer :: strm_precsf(:) => null() - ! stream data anomonly forcing - real(r8), pointer :: strm_u_af(:) => null() ! anomoly forcing - real(r8), pointer :: strm_v_af(:) => null() ! anomoly forcing - real(r8), pointer :: strm_prec_af(:) => null() ! anomoly forcing - real(r8), pointer :: strm_tbot_af(:) => null() ! anomoly forcing - real(r8), pointer :: strm_pbot_af(:) => null() ! anomoly forcing - real(r8), pointer :: strm_shum_af(:) => null() ! anomoly forcing - real(r8), pointer :: strm_swdn_af(:) => null() ! anomoly forcing - real(r8), pointer :: strm_lwdn_af(:) => null() ! anomoly forcing + ! stream data anomaly forcing + real(r8), pointer :: strm_u_af(:) => null() ! anomaly forcing + real(r8), pointer :: strm_v_af(:) => null() ! anomaly forcing + real(r8), pointer :: strm_prec_af(:) => null() ! anomaly forcing + real(r8), pointer :: strm_tbot_af(:) => null() ! anomaly forcing + real(r8), pointer :: strm_pbot_af(:) => null() ! anomaly forcing + real(r8), pointer :: strm_shum_af(:) => null() ! anomaly forcing + real(r8), pointer :: strm_swdn_af(:) => null() ! anomaly forcing + real(r8), pointer :: strm_lwdn_af(:) => null() ! anomaly forcing ! import state data real(r8), pointer :: Sx_avsdr(:) => null() @@ -249,7 +249,7 @@ subroutine datm_datamode_clmncep_init_pointers(importState, exportState, sdat, r call shr_strdata_get_stream_pointer( sdat, 'Faxa_precsf' , strm_precsf , rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! initialize pointers for module level stream arrays for anomonly forcing + ! initialize pointers for module level stream arrays for anomaly forcing call shr_strdata_get_stream_pointer( sdat, 'Sa_u_af' , strm_u_af , rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call shr_strdata_get_stream_pointer( sdat, 'Sa_v_af' , strm_v_af , rc) From ba85ec4ea74820a797317121a4aa0984bf33f09c Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 8 Aug 2024 17:31:59 -0600 Subject: [PATCH 38/68] Add Anomaly.Forcing.cmip6.ssp126. --- datm/cime_config/namelist_definition_datm.xml | 2 +- datm/cime_config/stream_definition_datm.xml | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/datm/cime_config/namelist_definition_datm.xml b/datm/cime_config/namelist_definition_datm.xml index c3efa072b..6ab571803 100644 --- a/datm/cime_config/namelist_definition_datm.xml +++ b/datm/cime_config/namelist_definition_datm.xml @@ -221,7 +221,7 @@ char(10) datm datm_nml - Anomaly.Forcing.cmip5.rcp45,Anomaly.Forcing.Precip,Anomaly.Forcing.Temperature,Anomaly.Forcing.Pressure,Anomaly.Forcing.Humidity,Anomaly.Forcing.Uwind,Anomaly.Forcing.Vwind,Anomaly.Forcing.Shortwave,Anomaly.Forcing.Longwave + Anomaly.Forcing.cmip5.rcp45,Anomaly.Forcing.cmip6.ssp126,Anomaly.Forcing.Precip,Anomaly.Forcing.Temperature,Anomaly.Forcing.Pressure,Anomaly.Forcing.Humidity,Anomaly.Forcing.Uwind,Anomaly.Forcing.Vwind,Anomaly.Forcing.Shortwave,Anomaly.Forcing.Longwave If set, include anomaly forcing streams in namelist. diff --git a/datm/cime_config/stream_definition_datm.xml b/datm/cime_config/stream_definition_datm.xml index 1ac68790c..5a9e4fc42 100644 --- a/datm/cime_config/stream_definition_datm.xml +++ b/datm/cime_config/stream_definition_datm.xml @@ -1211,6 +1211,44 @@ single + + + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc + + + $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/CMIP6-SSP1-2.6/af.allvars.CESM.SSP1-2.6.2015-2100_c20220628.nc + + + huss Sa_shum_af + pr Faxa_prec_af + ps Sa_pbot_af + rlds Faxa_lwdn_af + rsds Faxa_swdn_af + tas Sa_tbot_af + uas Sa_u_af + vas Sa_v_af + + null + + bilinear + + null + 2015 + 2015 + 2100 + 0 + + nearest + + + cycle + + + 1.5 + + single + + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc From 9b0f71424517a817c8581d2350bc66299ce3bc9a Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 8 Aug 2024 18:25:07 -0600 Subject: [PATCH 39/68] Add Anomaly.Forcing.cmip6.245, 370, 585. --- datm/cime_config/namelist_definition_datm.xml | 2 +- datm/cime_config/stream_definition_datm.xml | 114 ++++++++++++++++++ 2 files changed, 115 insertions(+), 1 deletion(-) diff --git a/datm/cime_config/namelist_definition_datm.xml b/datm/cime_config/namelist_definition_datm.xml index 6ab571803..54e2bc0b1 100644 --- a/datm/cime_config/namelist_definition_datm.xml +++ b/datm/cime_config/namelist_definition_datm.xml @@ -221,7 +221,7 @@ char(10) datm datm_nml - Anomaly.Forcing.cmip5.rcp45,Anomaly.Forcing.cmip6.ssp126,Anomaly.Forcing.Precip,Anomaly.Forcing.Temperature,Anomaly.Forcing.Pressure,Anomaly.Forcing.Humidity,Anomaly.Forcing.Uwind,Anomaly.Forcing.Vwind,Anomaly.Forcing.Shortwave,Anomaly.Forcing.Longwave + Anomaly.Forcing.cmip5.rcp45,Anomaly.Forcing.cmip6.ssp126,Anomaly.Forcing.cmip6.ssp245,Anomaly.Forcing.cmip6.ssp370,Anomaly.Forcing.cmip6.ssp585,Anomaly.Forcing.Precip,Anomaly.Forcing.Temperature,Anomaly.Forcing.Pressure,Anomaly.Forcing.Humidity,Anomaly.Forcing.Uwind,Anomaly.Forcing.Vwind,Anomaly.Forcing.Shortwave,Anomaly.Forcing.Longwave If set, include anomaly forcing streams in namelist. diff --git a/datm/cime_config/stream_definition_datm.xml b/datm/cime_config/stream_definition_datm.xml index 5a9e4fc42..232b2ec02 100644 --- a/datm/cime_config/stream_definition_datm.xml +++ b/datm/cime_config/stream_definition_datm.xml @@ -1249,6 +1249,120 @@ single + + + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc + + + $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/CMIP6-SSP2-4.5/af.allvars.CESM.SSP2-4.5.2015-2100_c20220628.nc + + + huss Sa_shum_af + pr Faxa_prec_af + ps Sa_pbot_af + rlds Faxa_lwdn_af + rsds Faxa_swdn_af + tas Sa_tbot_af + uas Sa_u_af + vas Sa_v_af + + null + + bilinear + + null + 2015 + 2015 + 2100 + 0 + + nearest + + + cycle + + + 1.5 + + single + + + + + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc + + + $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/CMIP6-SSP3-7.0/af.allvars.CESM.SSP3-7.0.2015-2100_c20220628.nc + + + huss Sa_shum_af + pr Faxa_prec_af + ps Sa_pbot_af + rlds Faxa_lwdn_af + rsds Faxa_swdn_af + tas Sa_tbot_af + uas Sa_u_af + vas Sa_v_af + + null + + bilinear + + null + 2015 + 2015 + 2100 + 0 + + nearest + + + cycle + + + 1.5 + + single + + + + + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc + + + $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/CMIP6-SSP5-8.5/af.allvars.CESM.SSP5-8.5.2015-2100_c20220628.nc + + + huss Sa_shum_af + pr Faxa_prec_af + ps Sa_pbot_af + rlds Faxa_lwdn_af + rsds Faxa_swdn_af + tas Sa_tbot_af + uas Sa_u_af + vas Sa_v_af + + null + + bilinear + + null + 2015 + 2015 + 2100 + 0 + + nearest + + + cycle + + + 1.5 + + single + + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc From d92193146f9dd5202d68b1db799500152d803470 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 4 Sep 2024 16:50:16 -0600 Subject: [PATCH 40/68] anomaly_forcing now automatically set based on compset (ISSP*). --- datm/cime_config/namelist_definition_datm.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/datm/cime_config/namelist_definition_datm.xml b/datm/cime_config/namelist_definition_datm.xml index 54e2bc0b1..dc5aa5270 100644 --- a/datm/cime_config/namelist_definition_datm.xml +++ b/datm/cime_config/namelist_definition_datm.xml @@ -226,7 +226,11 @@ If set, include anomaly forcing streams in namelist. - + null + Anomaly.Forcing.cmip6.ssp126 + Anomaly.Forcing.cmip6.ssp245 + Anomaly.Forcing.cmip6.ssp370 + Anomaly.Forcing.cmip6.ssp585 From 0389799db274a0e793ebb049a4118ad87577ebdd Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 5 Sep 2024 08:56:27 -0600 Subject: [PATCH 41/68] Now actually sets anomaly_forcing based on compset. This reverts commit 3f36622b3bd6358d324f1aca5e90009db306963e, which tried to do this in namelist_definition_datm.xml, and instead does it in datm/cime_config/buildnml. Only looks at compset if anomaly_forcing not specified in namelist. --- datm/cime_config/buildnml | 11 +++++++++++ datm/cime_config/namelist_definition_datm.xml | 6 +----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/datm/cime_config/buildnml b/datm/cime_config/buildnml index 28e341c02..560bc86d2 100755 --- a/datm/cime_config/buildnml +++ b/datm/cime_config/buildnml @@ -10,6 +10,7 @@ # pylint: disable=wildcard-import,unused-wildcard-import,wrong-import-position import os, sys +import re _CDEPS_CONFIG = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir,os.pardir,"cime_config") _CIMEROOT = os.environ.get("CIMEROOT") @@ -115,6 +116,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path atm_grid = case.get_value("ATM_GRID") model_grid = case.get_value("GRID") comp_lnd = case.get_value("COMP_LND") + compset = case.get_value("COMPSET") # Check for incompatible options. if "CLM" in datm_mode and comp_lnd == "clm": @@ -135,6 +137,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path logger.debug("DATM preso3 mode is {}".format(datm_preso3)) logger.debug("DATM topo mode is {}".format(datm_topo)) logger.debug("CLM_USRDAT_NAME is {}".format(clm_usrdat_name)) + logger.debug("COMPSET is {}".format(compset)) # Initialize namelist defaults config = {} @@ -205,9 +208,17 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path bias_correct = nmlgen.get_value("bias_correct") if bias_correct is not None: streamlist.append(bias_correct) + + # Set anomaly forcing anomaly_forcing = nmlgen.get_value("anomaly_forcing") + ssp = re.search(r"^SSP\d+", compset).group() + # First by looking in namelist if anomaly_forcing[0] is not None: streamlist += anomaly_forcing + # If not in namelist, look at compset + elif ssp: + anomaly_forcing = "Anomaly.Forcing.cmip6." + ssp.lower() + streamlist += [anomaly_forcing] # Generate datm.streams.xml outfile = os.path.join(confdir, "datm.streams"+inst_string+".xml" ) diff --git a/datm/cime_config/namelist_definition_datm.xml b/datm/cime_config/namelist_definition_datm.xml index dc5aa5270..54e2bc0b1 100644 --- a/datm/cime_config/namelist_definition_datm.xml +++ b/datm/cime_config/namelist_definition_datm.xml @@ -226,11 +226,7 @@ If set, include anomaly forcing streams in namelist. - null - Anomaly.Forcing.cmip6.ssp126 - Anomaly.Forcing.cmip6.ssp245 - Anomaly.Forcing.cmip6.ssp370 - Anomaly.Forcing.cmip6.ssp585 + From c191e5eaf967db0db66e1a89b5cb78839987f2e3 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 5 Sep 2024 10:46:13 -0600 Subject: [PATCH 42/68] SSP compsets now automatically get anomaly_forcing in datm_in. --- datm/cime_config/buildnml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/datm/cime_config/buildnml b/datm/cime_config/buildnml index 560bc86d2..8b90a73a3 100755 --- a/datm/cime_config/buildnml +++ b/datm/cime_config/buildnml @@ -180,6 +180,16 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path nmlgen.init_defaults(infile, config) + # Get anomaly forcing + # First, look in namelist + anomaly_forcing = nmlgen.get_value("anomaly_forcing") + if anomaly_forcing[0] is None: + # If not in namelist, check whether it's an SSP compset + ssp = re.search(r"^SSP\d+", compset).group() + if ssp: + anomaly_forcing = ["Anomaly.Forcing.cmip6." + ssp.lower()] + nmlgen.set_value("anomaly_forcing", anomaly_forcing) + # Generate datm_in namelist_file = os.path.join(confdir, "datm_in") nmlgen.write_output_file(namelist_file, data_list_path, groups=['datm_nml','const_forcing_nml']) @@ -209,16 +219,10 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path if bias_correct is not None: streamlist.append(bias_correct) - # Set anomaly forcing + # Set anomaly forcing in datm.streams.xml anomaly_forcing = nmlgen.get_value("anomaly_forcing") - ssp = re.search(r"^SSP\d+", compset).group() - # First by looking in namelist if anomaly_forcing[0] is not None: streamlist += anomaly_forcing - # If not in namelist, look at compset - elif ssp: - anomaly_forcing = "Anomaly.Forcing.cmip6." + ssp.lower() - streamlist += [anomaly_forcing] # Generate datm.streams.xml outfile = os.path.join(confdir, "datm.streams"+inst_string+".xml" ) From b02f0cddd7672c34b1044d3b843f930861c9f0af Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 5 Sep 2024 11:26:06 -0600 Subject: [PATCH 43/68] Remove Anomaly.Forcing.Precip, Anomaly.Forcing.Temperature, etc. --- datm/cime_config/namelist_definition_datm.xml | 2 +- datm/cime_config/stream_definition_datm.xml | 260 +----------------- 2 files changed, 6 insertions(+), 256 deletions(-) diff --git a/datm/cime_config/namelist_definition_datm.xml b/datm/cime_config/namelist_definition_datm.xml index 54e2bc0b1..dde528f78 100644 --- a/datm/cime_config/namelist_definition_datm.xml +++ b/datm/cime_config/namelist_definition_datm.xml @@ -221,7 +221,7 @@ char(10) datm datm_nml - Anomaly.Forcing.cmip5.rcp45,Anomaly.Forcing.cmip6.ssp126,Anomaly.Forcing.cmip6.ssp245,Anomaly.Forcing.cmip6.ssp370,Anomaly.Forcing.cmip6.ssp585,Anomaly.Forcing.Precip,Anomaly.Forcing.Temperature,Anomaly.Forcing.Pressure,Anomaly.Forcing.Humidity,Anomaly.Forcing.Uwind,Anomaly.Forcing.Vwind,Anomaly.Forcing.Shortwave,Anomaly.Forcing.Longwave + Anomaly.Forcing.cmip5.rcp45,Anomaly.Forcing.cmip6.ssp126,Anomaly.Forcing.cmip6.ssp245,Anomaly.Forcing.cmip6.ssp370,Anomaly.Forcing.cmip6.ssp585 If set, include anomaly forcing streams in namelist. diff --git a/datm/cime_config/stream_definition_datm.xml b/datm/cime_config/stream_definition_datm.xml index 232b2ec02..db473195c 100644 --- a/datm/cime_config/stream_definition_datm.xml +++ b/datm/cime_config/stream_definition_datm.xml @@ -210,14 +210,11 @@ ======================== optional streams anonomly forcing (turned on and set my datm_nml variable anomaly_forcing ======================== - Anomaly.Forcing.Humidity - Anomaly.Forcing.Longwave - Anomaly.Forcing.Precip - Anomaly.Forcing.Pressure - Anomaly.Forcing.Shortwave - Anomaly.Forcing.Temperature - Anomaly.Forcing.Uwind - Anomaly.Forcing.Vwind + Anomaly.Forcing.cmip5.rcp45 + Anomaly.Forcing.cmip6.ssp126 + Anomaly.Forcing.cmip6.ssp245 + Anomaly.Forcing.cmip6.ssp370 + Anomaly.Forcing.cmip6.ssp585 ======================== optional streams bias correction (turned on and set my datm_nml variable bias_correct) @@ -1363,253 +1360,6 @@ single - - - $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc - - - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.pr.ccsm4.rcp45.2006-2300.nc - - - pr Faxa_prec_af - - null - - bilinear - - null - 2006 - 2006 - 2300 - 0 - - nearest - - - cycle - - - 1.5 - - single - - - - - $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc - - - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.tas.ccsm4.rcp45.2006-2300.nc - - - tas Sa_tbot_af - - null - - bilinear - - null - 2006 - 2006 - 2300 - 0 - - nearest - - - cycle - - - 1.5 - - single - - - - - $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc - - - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.ps.ccsm4.rcp45.2006-2300.nc - - - ps Sa_pbot_af - - null - - bilinear - - null - 2006 - 2006 - 2300 - 0 - - nearest - - - cycle - - - 1.5 - - single - - - - - $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc - - - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.huss.ccsm4.rcp45.2006-2300.nc - - - huss Sa_shum_af - - null - - bilinear - - null - 2006 - 2300 - 2300 - 0 - - nearest - - - cycle - - - 1.5 - - single - - - - - $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc - - - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.uas.ccsm4.rcp45.2006-2300.nc - - - uas Sa_u_af - - null - - bilinear - - null - 2006 - 2006 - 2300 - 0 - - nearest - - - cycle - - - 1.5 - - single - - - - - $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc - - - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.vas.ccsm4.rcp45.2006-2300.nc - - - vas Sa_v_af - - null - - bilinear - - null - 2006 - 2006 - 2300 - 0 - - nearest - - - cycle - - - 1.5 - - single - - - - - $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc - - - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.rsds.ccsm4.rcp45.2006-2300.nc - - - rsds Faxa_swdn_af - - null - - bilinear - - null - 2006 - 2006 - 2300 - 0 - - nearest - - - cycle - - - 1.5 - - single - - - - - $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc - - - $DIN_LOC_ROOT/atm/datm7/anomaly_forcing/af.rlds.ccsm4.rcp45.2006-2300.nc - - - rlds Faxa_lwdn_af - - null - - bilinear - - null - 2006 - 2006 - 2300 - 0 - - nearest - - - cycle - - - 1.5 - - single - From 074d90d76c5e951acbc6dea98ea29b8e867d7319 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 5 Sep 2024 12:15:40 -0600 Subject: [PATCH 44/68] Set anomaly_forcing = 'none' to not use anomalies in an SSP compset. --- datm/cime_config/buildnml | 2 +- datm/cime_config/namelist_definition_datm.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/datm/cime_config/buildnml b/datm/cime_config/buildnml index 8b90a73a3..d8c9a2f28 100755 --- a/datm/cime_config/buildnml +++ b/datm/cime_config/buildnml @@ -221,7 +221,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path # Set anomaly forcing in datm.streams.xml anomaly_forcing = nmlgen.get_value("anomaly_forcing") - if anomaly_forcing[0] is not None: + if anomaly_forcing[0] is not None and anomaly_forcing[0] != "none": streamlist += anomaly_forcing # Generate datm.streams.xml diff --git a/datm/cime_config/namelist_definition_datm.xml b/datm/cime_config/namelist_definition_datm.xml index dde528f78..6d4f676db 100644 --- a/datm/cime_config/namelist_definition_datm.xml +++ b/datm/cime_config/namelist_definition_datm.xml @@ -221,7 +221,7 @@ char(10) datm datm_nml - Anomaly.Forcing.cmip5.rcp45,Anomaly.Forcing.cmip6.ssp126,Anomaly.Forcing.cmip6.ssp245,Anomaly.Forcing.cmip6.ssp370,Anomaly.Forcing.cmip6.ssp585 + none,Anomaly.Forcing.cmip5.rcp45,Anomaly.Forcing.cmip6.ssp126,Anomaly.Forcing.cmip6.ssp245,Anomaly.Forcing.cmip6.ssp370,Anomaly.Forcing.cmip6.ssp585 If set, include anomaly forcing streams in namelist. From 0a6142225ebde0a80060e06a85f9d44d3f5453b6 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 5 Sep 2024 13:00:09 -0600 Subject: [PATCH 45/68] Only set anomaly_forcing for DATM SSP compsets. --- datm/cime_config/buildnml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/datm/cime_config/buildnml b/datm/cime_config/buildnml index d8c9a2f28..c374440fd 100755 --- a/datm/cime_config/buildnml +++ b/datm/cime_config/buildnml @@ -185,8 +185,9 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path anomaly_forcing = nmlgen.get_value("anomaly_forcing") if anomaly_forcing[0] is None: # If not in namelist, check whether it's an SSP compset - ssp = re.search(r"^SSP\d+", compset).group() + ssp = re.search(r"^SSP\d+_DATM", compset).group() if ssp: + ssp = ssp.replace("_DATM", "") anomaly_forcing = ["Anomaly.Forcing.cmip6." + ssp.lower()] nmlgen.set_value("anomaly_forcing", anomaly_forcing) From 4715267bcff8b46f228722cccc4d6b445c89ed8b Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 5 Sep 2024 13:43:43 -0600 Subject: [PATCH 46/68] Provide hint in error message if namelist variable invalid due to surrounding quote marks. --- cime_config/stream_cdeps.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/cime_config/stream_cdeps.py b/cime_config/stream_cdeps.py index b7af2f28c..325ec2c16 100644 --- a/cime_config/stream_cdeps.py +++ b/cime_config/stream_cdeps.py @@ -333,14 +333,30 @@ def create_stream_xml( ), ) if var_key in valid_values: + + # # Handle, e.g., 'bilinear' in namelist instead of bilinear (no quotes) + mod_dict_var_key = mod_dict[var_key] + + # Check that key is valid + is_valid = mod_dict_var_key in valid_values[var_key] + msg = "{} can only have values of {} for stream {} in file {}, not {}".format( + var_key, + valid_values[var_key], + stream_name, + user_mods_file, + mod_dict[var_key], + ) + if not is_valid: + # Check for surrounding quote marks + has_surrounding_quotes = ( + (mod_dict_var_key[0] == mod_dict_var_key[-1] == "'") or + (mod_dict_var_key[0] == mod_dict_var_key[-1] == '"') + ) + if has_surrounding_quotes and mod_dict_var_key[1:-1] in valid_values[var_key]: + msg += " (try removing surrounding quotes)" expect( - mod_dict[var_key] in valid_values[var_key], - "{} can only have values of {} for stream {} in file {}".format( - var_key, - valid_values[var_key], - stream_name, - user_mods_file, - ), + is_valid, + msg, ) stream_vars["stream_" + var_key] = mod_dict[var_key] if var_key == "datafiles": From a11abf756bac4ce5621600ae372cd5c63650753a Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 5 Sep 2024 15:15:11 -0600 Subject: [PATCH 47/68] Make datm buildnml more robust. --- datm/cime_config/buildnml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datm/cime_config/buildnml b/datm/cime_config/buildnml index c374440fd..93be5d981 100755 --- a/datm/cime_config/buildnml +++ b/datm/cime_config/buildnml @@ -183,11 +183,11 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path # Get anomaly forcing # First, look in namelist anomaly_forcing = nmlgen.get_value("anomaly_forcing") - if anomaly_forcing[0] is None: + if anomaly_forcing and anomaly_forcing[0] is None: # If not in namelist, check whether it's an SSP compset - ssp = re.search(r"^SSP\d+_DATM", compset).group() + ssp = re.search(r"^SSP\d+_DATM", compset) if ssp: - ssp = ssp.replace("_DATM", "") + ssp = ssp.group().replace("_DATM", "") anomaly_forcing = ["Anomaly.Forcing.cmip6." + ssp.lower()] nmlgen.set_value("anomaly_forcing", anomaly_forcing) From cd97deac4caa6b133930aaf3fb8f4802cdd21a2e Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 5 Sep 2024 15:47:54 -0600 Subject: [PATCH 48/68] Bugfix to future-proofing of datm buildnml. --- datm/cime_config/buildnml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datm/cime_config/buildnml b/datm/cime_config/buildnml index 93be5d981..17e24b8cc 100755 --- a/datm/cime_config/buildnml +++ b/datm/cime_config/buildnml @@ -183,7 +183,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path # Get anomaly forcing # First, look in namelist anomaly_forcing = nmlgen.get_value("anomaly_forcing") - if anomaly_forcing and anomaly_forcing[0] is None: + if not anomaly_forcing or anomaly_forcing[0] is None: # If not in namelist, check whether it's an SSP compset ssp = re.search(r"^SSP\d+_DATM", compset) if ssp: From 94dcdb04a9e0be1c8eeed0f18bbaca321e8b0f19 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Fri, 6 Sep 2024 09:52:17 -0600 Subject: [PATCH 49/68] Add aux_cdeps tests for SSPs other than 585. Resolves ESCOMP/CDEPS#310. --- datm/cime_config/testdefs/testlist_datm.xml | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/datm/cime_config/testdefs/testlist_datm.xml b/datm/cime_config/testdefs/testlist_datm.xml index 34bbe3fcf..788e6f555 100644 --- a/datm/cime_config/testdefs/testlist_datm.xml +++ b/datm/cime_config/testdefs/testlist_datm.xml @@ -52,6 +52,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + From a911685d37b7276ecfbbb55c7c946ca10429d505 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 19 Feb 2025 13:06:08 -0700 Subject: [PATCH 50/68] Simplify removal of quotes. --- cime_config/stream_cdeps.py | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/cime_config/stream_cdeps.py b/cime_config/stream_cdeps.py index 325ec2c16..efbbba4cd 100644 --- a/cime_config/stream_cdeps.py +++ b/cime_config/stream_cdeps.py @@ -335,28 +335,17 @@ def create_stream_xml( if var_key in valid_values: # # Handle, e.g., 'bilinear' in namelist instead of bilinear (no quotes) - mod_dict_var_key = mod_dict[var_key] + mod_dict[var_key] = re.sub(r"[\"\']", "", mod_dict[var_key]) # Check that key is valid - is_valid = mod_dict_var_key in valid_values[var_key] - msg = "{} can only have values of {} for stream {} in file {}, not {}".format( - var_key, - valid_values[var_key], - stream_name, - user_mods_file, - mod_dict[var_key], - ) - if not is_valid: - # Check for surrounding quote marks - has_surrounding_quotes = ( - (mod_dict_var_key[0] == mod_dict_var_key[-1] == "'") or - (mod_dict_var_key[0] == mod_dict_var_key[-1] == '"') - ) - if has_surrounding_quotes and mod_dict_var_key[1:-1] in valid_values[var_key]: - msg += " (try removing surrounding quotes)" expect( - is_valid, - msg, + mod_dict[var_key] in valid_values[var_key], + "{} can only have values of {} for stream {} in file {}".format( + var_key, + valid_values[var_key], + stream_name, + user_mods_file, + ), ) stream_vars["stream_" + var_key] = mod_dict[var_key] if var_key == "datafiles": From 93e59c0f19110d2ace7a94c6906b19ca3bfa98f0 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 19 Feb 2025 13:08:58 -0700 Subject: [PATCH 51/68] Fix indentation. --- datm/cime_config/stream_definition_datm.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datm/cime_config/stream_definition_datm.xml b/datm/cime_config/stream_definition_datm.xml index db473195c..b198b1e76 100644 --- a/datm/cime_config/stream_definition_datm.xml +++ b/datm/cime_config/stream_definition_datm.xml @@ -1169,8 +1169,8 @@ - - + + $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc From 2a6af66efd1219516e3ec3f23fef0122d0ddf385 Mon Sep 17 00:00:00 2001 From: Nicholas Szapiro <149816583+NickSzapiro-NOAA@users.noreply.github.com> Date: Wed, 5 Mar 2025 10:36:30 -0500 Subject: [PATCH 52/68] Update dshr_restart_{read,write} calls in dice_datamode_cplhist_mod.F90 --- dice/dice_datamode_cplhist_mod.F90 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dice/dice_datamode_cplhist_mod.F90 b/dice/dice_datamode_cplhist_mod.F90 index 1d1eb28a0..5532d7cba 100644 --- a/dice/dice_datamode_cplhist_mod.F90 +++ b/dice/dice_datamode_cplhist_mod.F90 @@ -37,7 +37,6 @@ module dice_datamode_cplhist_mod real(r8), pointer :: Si_anidr(:) => null() real(r8), pointer :: Si_anidf(:) => null() - character(*) , parameter :: nullstr = 'null' character(*) , parameter :: rpfile = 'rpointer.ice' character(*) , parameter :: u_FILE_u = & __FILE__ @@ -169,26 +168,33 @@ subroutine dice_datamode_cplhist_restart_write(case_name, inst_suffix, ymd, tod, integer , intent(in) :: logunit integer , intent(in) :: my_task type(shr_strdata_type) , intent(inout) :: sdat + + ! local variables + integer :: rc !------------------------------------------------------------------------------- call dshr_restart_write(rpfile, case_name, 'dice', inst_suffix, ymd, tod, & - logunit, my_task, sdat) + logunit, my_task, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return end subroutine dice_datamode_cplhist_restart_write !=============================================================================== - subroutine dice_datamode_cplhist_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) + subroutine dice_datamode_cplhist_restart_read(rest_filem, logunit, my_task, mpicom, sdat) ! input/output arguments character(len=*) , intent(inout) :: rest_filem - character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom type(shr_strdata_type) , intent(inout) :: sdat + + ! local variables + integer :: rc !------------------------------------------------------------------------------- - call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) + call dshr_restart_read(rest_filem, rpfile, logunit, my_task, mpicom, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return end subroutine dice_datamode_cplhist_restart_read From ca495384b32f752e8941f1f1d742deb79936d09f Mon Sep 17 00:00:00 2001 From: Nicholas Szapiro <149816583+NickSzapiro-NOAA@users.noreply.github.com> Date: Wed, 5 Mar 2025 10:55:11 -0500 Subject: [PATCH 53/68] Remove gcomp from dice_datamode_ssmi_restart_read in dice_datamode_ssmi_mod.F90 --- dice/dice_datamode_ssmi_mod.F90 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dice/dice_datamode_ssmi_mod.F90 b/dice/dice_datamode_ssmi_mod.F90 index 20976c236..b484b40ae 100644 --- a/dice/dice_datamode_ssmi_mod.F90 +++ b/dice/dice_datamode_ssmi_mod.F90 @@ -586,10 +586,9 @@ subroutine dice_datamode_ssmi_restart_write(rpfile, case_name, inst_suffix, ymd, end subroutine dice_datamode_ssmi_restart_write !=============================================================================== - subroutine dice_datamode_ssmi_restart_read(gcomp, rest_filem, rpfile, logunit, my_task, mpicom, sdat) + subroutine dice_datamode_ssmi_restart_read(rest_filem, rpfile, logunit, my_task, mpicom, sdat) ! input/output arguments - type(ESMF_GridComp) , intent(in) :: gcomp character(len=*) , intent(inout) :: rest_filem character(len=*) , intent(in) :: rpfile integer , intent(in) :: logunit From 7a2d75afe5e1e1809d6567c4b11d77789cdf4ac9 Mon Sep 17 00:00:00 2001 From: Nicholas Szapiro <149816583+NickSzapiro-NOAA@users.noreply.github.com> Date: Wed, 5 Mar 2025 11:05:43 -0500 Subject: [PATCH 54/68] Update dice_datamode_{ssmi,cplhist}_restart_read calls in ice_comp_nuopc.F90 --- dice/ice_comp_nuopc.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dice/ice_comp_nuopc.F90 b/dice/ice_comp_nuopc.F90 index 35618ff59..725042ec7 100644 --- a/dice/ice_comp_nuopc.F90 +++ b/dice/ice_comp_nuopc.F90 @@ -531,9 +531,9 @@ subroutine dice_comp_run(gcomp, importstate, exportstate, target_ymd, target_tod if (ChkErr(rc,__LINE__,u_FILE_u)) return select case (trim(datamode)) case('ssmi', 'ssmi_iaf') - call dice_datamode_ssmi_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call dice_datamode_ssmi_restart_read(restfilm, rpfile, logunit, my_task, mpicom, sdat) case('cplhist') - call dice_datamode_cplhist_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + call dice_datamode_cplhist_restart_read(restfilm, rpfile, logunit, my_task, mpicom, sdat) end select end if From 9e5701c6286f8d44c0d3d24f13f22efd6d843e6b Mon Sep 17 00:00:00 2001 From: Nicholas Szapiro <149816583+NickSzapiro-NOAA@users.noreply.github.com> Date: Wed, 5 Mar 2025 11:11:06 -0500 Subject: [PATCH 55/68] rpfile as read,write arguments in dice_datamode_cplhist_mod.F90 --- dice/dice_datamode_cplhist_mod.F90 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dice/dice_datamode_cplhist_mod.F90 b/dice/dice_datamode_cplhist_mod.F90 index 5532d7cba..4bc15d225 100644 --- a/dice/dice_datamode_cplhist_mod.F90 +++ b/dice/dice_datamode_cplhist_mod.F90 @@ -37,7 +37,6 @@ module dice_datamode_cplhist_mod real(r8), pointer :: Si_anidr(:) => null() real(r8), pointer :: Si_anidf(:) => null() - character(*) , parameter :: rpfile = 'rpointer.ice' character(*) , parameter :: u_FILE_u = & __FILE__ @@ -157,10 +156,11 @@ subroutine dice_datamode_cplhist_advance(rc) end subroutine dice_datamode_cplhist_advance !=============================================================================== - subroutine dice_datamode_cplhist_restart_write(case_name, inst_suffix, ymd, tod, & + subroutine dice_datamode_cplhist_restart_write(rpfile, case_name, inst_suffix, ymd, tod, & logunit, my_task, sdat) ! input/output variables + character(len=*) , intent(in) :: rpfile character(len=*) , intent(in) :: case_name character(len=*) , intent(in) :: inst_suffix integer , intent(in) :: ymd ! model date @@ -180,10 +180,11 @@ subroutine dice_datamode_cplhist_restart_write(case_name, inst_suffix, ymd, tod, end subroutine dice_datamode_cplhist_restart_write !=============================================================================== - subroutine dice_datamode_cplhist_restart_read(rest_filem, logunit, my_task, mpicom, sdat) + subroutine dice_datamode_cplhist_restart_read(rest_filem, rpfile, logunit, my_task, mpicom, sdat) ! input/output arguments character(len=*) , intent(inout) :: rest_filem + character(len=*) , intent(inout) :: rpfile integer , intent(in) :: logunit integer , intent(in) :: my_task integer , intent(in) :: mpicom From bfd49ab331b9f24576601f707195b0471016ecaf Mon Sep 17 00:00:00 2001 From: Nicholas Szapiro <149816583+NickSzapiro-NOAA@users.noreply.github.com> Date: Wed, 5 Mar 2025 11:12:47 -0500 Subject: [PATCH 56/68] rpfile in call dice_datamode_cplhist_restart_write in ice_comp_nuopc.F90 --- dice/ice_comp_nuopc.F90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dice/ice_comp_nuopc.F90 b/dice/ice_comp_nuopc.F90 index 725042ec7..ab4b7c8ee 100644 --- a/dice/ice_comp_nuopc.F90 +++ b/dice/ice_comp_nuopc.F90 @@ -588,7 +588,8 @@ subroutine dice_comp_run(gcomp, importstate, exportstate, target_ymd, target_tod call dice_datamode_ssmi_restart_write(rpfile, case_name, inst_suffix, target_ymd, target_tod, & logunit, my_task, sdat) case ('cplhist') - call dice_datamode_cplhist_restart_write(case_name, inst_suffix, target_ymd, target_tod, logunit, my_task, sdat) + call dice_datamode_cplhist_restart_write(rpfile, case_name, inst_suffix, target_ymd, target_tod, & + logunit, my_task, sdat) end select end if From 3eba3ea282759697d446a59cfcb00b48c00a6b70 Mon Sep 17 00:00:00 2001 From: Nicholas Szapiro <149816583+NickSzapiro-NOAA@users.noreply.github.com> Date: Wed, 5 Mar 2025 13:33:04 -0500 Subject: [PATCH 57/68] Remove isPresent,isSet wrongly added around flds_i2o_per_cat in ice_comp_nuopc.F90 --- dice/ice_comp_nuopc.F90 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dice/ice_comp_nuopc.F90 b/dice/ice_comp_nuopc.F90 index ab4b7c8ee..35a25ab15 100644 --- a/dice/ice_comp_nuopc.F90 +++ b/dice/ice_comp_nuopc.F90 @@ -181,7 +181,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) integer :: bcasttmp(4) real(r8) :: rbcasttmp(3) type(ESMF_VM) :: vm - logical :: isPresent, isSet character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' character(*) ,parameter :: F00 = "('(" // trim(modName) // ") ',8a)" character(*) ,parameter :: F01 = "('(" // trim(modName) // ") ',a,2x,i8)" @@ -283,7 +282,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if ( trim(datamode) == 'ssmi' .or. trim(datamode) == 'ssmi_iaf') then call NUOPC_CompAttributeGet(gcomp, name='flds_i2o_per_cat', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - if (isPresent .and. isSet) read(cvalue,*) flds_i2o_per_cat ! module variable + read(cvalue,*) flds_i2o_per_cat ! module variable endif !datamode already validated From 1fb4025d9a657ba17c2c3b736fb8102456a800f3 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 6 Mar 2025 17:08:18 -0700 Subject: [PATCH 58/68] Change path to the CRUJRA2024 data for consistency with other datasets --- datm/cime_config/stream_definition_datm.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/datm/cime_config/stream_definition_datm.xml b/datm/cime_config/stream_definition_datm.xml index cace07623..771e41f2c 100644 --- a/datm/cime_config/stream_definition_datm.xml +++ b/datm/cime_config/stream_definition_datm.xml @@ -503,10 +503,10 @@ - $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c2024/TRENDY2024/inputs/three_stream/mesh_cdf5.nc + $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c20241231/inputs/three_stream/mesh_cdf5.nc - $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c2024/TRENDY2024/inputs/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.Solr.%y.nc + $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c20241231/inputs/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.Solr.%y.nc FSDS Faxa_swdn @@ -534,10 +534,10 @@ - $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c2024/TRENDY2024/inputs/three_stream/mesh_cdf5.nc + $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c20241231/inputs/three_stream/mesh_cdf5.nc - $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c2024/TRENDY2024/inputs/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.Prec.%y.nc + $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c20241231/inputs/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.Prec.%y.nc PRECTmms Faxa_precn @@ -565,10 +565,10 @@ - $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c2024/TRENDY2024/inputs/three_stream/mesh_cdf5.nc + $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c20241231/inputs/three_stream/mesh_cdf5.nc - $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c2024/TRENDY2024/inputs/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.TPQWL.%y.nc + $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c20241231/inputs/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.TPQWL.%y.nc TBOT Sa_tbot From aea26e4f9e4cc5e319016c8c684816af2640b248 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 6 Mar 2025 17:17:44 -0700 Subject: [PATCH 59/68] For DATM%CLMCRUJRA2024, change datamode and datm_mode to CLMNCEP --- doc/source/datm.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/datm.rst b/doc/source/datm.rst index 88dd2c952..847df419e 100644 --- a/doc/source/datm.rst +++ b/doc/source/datm.rst @@ -123,9 +123,9 @@ DATM%CLM_QIAN DATM%CLMCRUJRA2024 - CRUJRA atm input data (CESM I compsets) - - datm_mode: CLMCRUJRA2024 + - datm_mode: CLMNCEP - streams: CLMCRUJRA2024.Solar,CLMCRUJRA2024.Precip,CLMCRUJRA2024.TPQW - - datamode: CLMCRUJRA2024 + - datamode: CLMNCEP DATM%CLMCRUNCEPv7 - CRUNCEP atm input data (CESM I compsets) From 32f351797bea40bbe558e8d682e9739e06f93d6b Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 6 Mar 2025 17:21:51 -0700 Subject: [PATCH 60/68] Add comment explaining the four new tests in testlist_datm.xml --- datm/cime_config/testdefs/testlist_datm.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/datm/cime_config/testdefs/testlist_datm.xml b/datm/cime_config/testdefs/testlist_datm.xml index 760394a56..9a02e0e68 100644 --- a/datm/cime_config/testdefs/testlist_datm.xml +++ b/datm/cime_config/testdefs/testlist_datm.xml @@ -68,6 +68,7 @@ + @@ -77,6 +78,7 @@ + @@ -86,6 +88,7 @@ + @@ -95,6 +98,7 @@ + From ef16f0940a3a7c8431df9bc4b4ff1fec8dbc3db1 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 7 Mar 2025 11:23:30 -0700 Subject: [PATCH 61/68] Corrections to a test and corresponding comments based on Erik's review --- datm/cime_config/testdefs/testlist_datm.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datm/cime_config/testdefs/testlist_datm.xml b/datm/cime_config/testdefs/testlist_datm.xml index 9a02e0e68..70f5fc2ee 100644 --- a/datm/cime_config/testdefs/testlist_datm.xml +++ b/datm/cime_config/testdefs/testlist_datm.xml @@ -78,7 +78,7 @@ - + @@ -88,10 +88,10 @@ - + - + From 54af59f07eae227efea272ec343636a61910100e Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 7 Mar 2025 11:56:43 -0700 Subject: [PATCH 62/68] Removed duplicate new test --- datm/cime_config/testdefs/testlist_datm.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/datm/cime_config/testdefs/testlist_datm.xml b/datm/cime_config/testdefs/testlist_datm.xml index 70f5fc2ee..28a1facba 100644 --- a/datm/cime_config/testdefs/testlist_datm.xml +++ b/datm/cime_config/testdefs/testlist_datm.xml @@ -91,16 +91,6 @@ - - - - - - - - - - From 43ba720be05ff8cbd6d27be989eca54178d47502 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 10 Mar 2025 08:20:56 -0600 Subject: [PATCH 63/68] update 1850 and HIST compset names to allow for Concentration or Emissions desginations. --- datm/cime_config/config_component.xml | 14 ++++++------- docn/cime_config/config_component.xml | 30 +++++++++++++-------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/datm/cime_config/config_component.xml b/datm/cime_config/config_component.xml index 6d4ea0e22..57762b9e2 100644 --- a/datm/cime_config/config_component.xml +++ b/datm/cime_config/config_component.xml @@ -74,7 +74,7 @@ none,clim_1850,clim_2000,clim_2010,hist,SSP1-1.9,SSP1-2.6,SSP2-4.5,SSP3-7.0,SSP4-3.4,SSP4-6.0,SSP5-3.4,SSP5-8.5,cplhist clim_2000 - clim_1850 + clim_1850 clim_2000 clim_2010 SSP1-1.9 @@ -85,7 +85,7 @@ SSP4-6.0 SSP5-3.4 SSP5-8.5 - hist + hist hist cplhist none @@ -100,14 +100,14 @@ none,clim_1850,clim_2000,clim_2010,hist,SSP1-2.6,SSP2-4.5,SSP3-7.0,SSP5-3.4,SSP5-8.5,cplhist clim_2000 - clim_1850 + clim_1850 clim_2000 clim_2010 SSP1-2.6 SSP2-4.5 SSP3-7.0 SSP5-8.5 - hist + hist hist cplhist none @@ -122,13 +122,13 @@ none,clim_1850,clim_2000,clim_2010,hist,SSP2-4.5,SSP3-7.0,SSP5-8.5 clim_2000 - clim_1850 + clim_1850 clim_2000 clim_2010 SSP2-4.5 SSP3-7.0 SSP5-8.5 - hist + hist hist none @@ -167,7 +167,7 @@ SSP4-6.0 SSP5-3.4 SSP5-8.5 - 20tr + 20tr 20tr omip.iaf omip.jra diff --git a/docn/cime_config/config_component.xml b/docn/cime_config/config_component.xml index c5461d900..251dddf66 100644 --- a/docn/cime_config/config_component.xml +++ b/docn/cime_config/config_component.xml @@ -159,19 +159,19 @@ $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.9x1.25_clim_c040926.nc $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.47x0.63_clim_c061106.nc $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.23x0.31_clim_c110526.nc - $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_1x1_1850_2021_c120422.nc - $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_48x96_1850_2021_c120422.nc - $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_1.9x2.5_1850_2021_c120422.nc - $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.9x1.25_1850_2021_c120422.nc - $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.47x0.63_1850_2021_c120422.nc - $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.23x0.31_1850_2021_c120422.nc - $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_1x1_clim_pi_c101029.nc + $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_1x1_1850_2021_c120422.nc + $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_48x96_1850_2021_c120422.nc + $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_1.9x2.5_1850_2021_c120422.nc + $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.9x1.25_1850_2021_c120422.nc + $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.47x0.63_1850_2021_c120422.nc + $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.23x0.31_1850_2021_c120422.nc + $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_1x1_clim_pi_c101029.nc $DIN_LOC_ROOT/ocn/docn7/SSTDATA/sst_ice_CMIP6_DECK_E3SM_1x1_1850_clim_c20190125.nc - $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_48x96_clim_pi_c101028.nc - $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_1.9x2.5_clim_pi_c101028.nc - $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.9x1.25_clim_pi_c101028.nc - $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.47x0.63_clim_pi_c101028.nc - $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.23x0.31_clim_pi_c101028.nc + $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_48x96_clim_pi_c101028.nc + $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_1.9x2.5_clim_pi_c101028.nc + $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.9x1.25_clim_pi_c101028.nc + $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.47x0.63_clim_pi_c101028.nc + $DIN_LOC_ROOT/atm/cam/sst/sst_HadOIBl_bc_0.23x0.31_clim_pi_c101028.nc $DIN_LOC_ROOT/ocn/docn7/SSTDATA/sst_ice_CMIP6_DECK_E3SM_1x1_1950_clim_c20180910.nc $DIN_LOC_ROOT/ocn/docn7/SSTDATA/sst_ice_CMIP6_DECK_E3SM_1x1_2010_clim_c20190821.nc @@ -206,7 +206,7 @@ 1 - 1850 + 1850 run_component_cam_sstice env_run.xml @@ -228,7 +228,7 @@ 0 - 1850 + 1850 run_component_cam_sstice env_run.xml @@ -244,7 +244,7 @@ 0 - 2021 + 2021 run_component_cam_sstice env_run.xml From b7b8f5ce636c67ecad1b421834a348038de6443e Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 10 Mar 2025 14:11:12 -0600 Subject: [PATCH 64/68] Rename mesh file and remove /inputs from CRUJRA paths --- datm/cime_config/stream_definition_datm.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/datm/cime_config/stream_definition_datm.xml b/datm/cime_config/stream_definition_datm.xml index 771e41f2c..f8523203d 100644 --- a/datm/cime_config/stream_definition_datm.xml +++ b/datm/cime_config/stream_definition_datm.xml @@ -503,10 +503,10 @@ - $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c20241231/inputs/three_stream/mesh_cdf5.nc + $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c20241231/three_stream/mesh_0.5x0.5_CRUJRAv2.5mask_cdf5_c20240916.nc - $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c20241231/inputs/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.Solr.%y.nc + $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c20241231/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.Solr.%y.nc FSDS Faxa_swdn @@ -534,10 +534,10 @@ - $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c20241231/inputs/three_stream/mesh_cdf5.nc + $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c20241231/three_stream/mesh_0.5x0.5_CRUJRAv2.5mask_cdf5_c20240916.nc - $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c20241231/inputs/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.Prec.%y.nc + $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c20241231/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.Prec.%y.nc PRECTmms Faxa_precn @@ -565,10 +565,10 @@ - $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c20241231/inputs/three_stream/mesh_cdf5.nc + $DIN_LOC_ROOT/atm/datm7/atm_forcing.datm7.CRUJRA.0.5d.c20241231/three_stream/mesh_0.5x0.5_CRUJRAv2.5mask_cdf5_c20240916.nc - $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c20241231/inputs/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.TPQWL.%y.nc + $DIN_LOC_ROOT_CLMFORC/atm_forcing.datm7.CRUJRA.0.5d.c20241231/three_stream/clmforc.CRUJRAv2.5_0.5x0.5.TPQWL.%y.nc TBOT Sa_tbot From 196957fce5b9604d723efbd643fe9aa72b98477f Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Fri, 14 Mar 2025 14:49:56 -0600 Subject: [PATCH 65/68] buildnml now errors on mismatch between anomaly forcing and DATM_MODE. cmip5 and cmip6 anomalies were generated only with GSWP3, so buildnml now errors if DATM_MODE isn't CLMGSWP3v1. However, the user can override this by setting the XML variable DATM_MODE_ANOMALY_FORCING_MISMATCH to TRUE. --- datm/cime_config/buildnml | 15 +++++++++++++++ datm/cime_config/config_component.xml | 11 +++++++++++ 2 files changed, 26 insertions(+) diff --git a/datm/cime_config/buildnml b/datm/cime_config/buildnml index 17e24b8cc..31d45d5e8 100755 --- a/datm/cime_config/buildnml +++ b/datm/cime_config/buildnml @@ -89,6 +89,18 @@ def _get_neon_data_availability(case, neonsite): expect(newestdate, "No tower data found on server for NEON site {}".format(neonsite)) return None +#################################################################################### +def _check_datm_af_mismatch(anomaly_forcing, datm_mode): +#################################################################################### + + # CMIP5 and CMIP6 anomalies were only generated relative to GSWP3v1 + is_cmip5_or_6 = any(x in anomaly_forcing for x in ["cmip5", "cmip6"]) + if is_cmip5_or_6 and datm_mode != "CLMGSWP3v1": + raise SystemExit( + "CMIP5 and CMIP6 anomalies were only generated relative for DATM_MODE='CLMGSWP3v1'" + ) + + # pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements #################################################################################### def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path): @@ -107,6 +119,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path caseroot = case.get_value("CASEROOT") datm_mode = case.get_value("DATM_MODE") + mismatch_ok = case.get_value("DATM_MODE_ANOMALY_FORCING_MISMATCH") datm_topo = case.get_value("DATM_TOPO") datm_presaero = case.get_value("DATM_PRESAERO") datm_presndep = case.get_value("DATM_PRESNDEP") @@ -223,6 +236,8 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path # Set anomaly forcing in datm.streams.xml anomaly_forcing = nmlgen.get_value("anomaly_forcing") if anomaly_forcing[0] is not None and anomaly_forcing[0] != "none": + if not mismatch_ok: + _check_datm_af_mismatch(anomaly_forcing[0], datm_mode) streamlist += anomaly_forcing # Generate datm.streams.xml diff --git a/datm/cime_config/config_component.xml b/datm/cime_config/config_component.xml index f2698e9d4..8b5eab641 100644 --- a/datm/cime_config/config_component.xml +++ b/datm/cime_config/config_component.xml @@ -39,6 +39,17 @@ Name of atmospheric component + + logical + TRUE,FALSE + FALSE + run_component_datm + env_run.xml + If set to true, then user will be allowed to specify an anomaly forcing that was based + on a different climate forcing than what's given in DATM_MODE + + + char CORE2_NYF,CORE2_IAF,CLM_QIAN,CLM_QIAN_WISO,1PT,CLMCRUNCEP,CLMCRUNCEPv7,CLMGSWP3v1,CLMNLDAS2,CPLHIST,CORE_IAF_JRA,CORE_IAF_JRA_1p4_2018,ERA5,SIMPLE From b56f0b7ab2ff78bedce0660e66c6c58e191a3b58 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Tue, 18 Mar 2025 12:46:29 -0600 Subject: [PATCH 66/68] Add comments about new tests in testlist_datm.xml. --- datm/cime_config/testdefs/testlist_datm.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/datm/cime_config/testdefs/testlist_datm.xml b/datm/cime_config/testdefs/testlist_datm.xml index 788e6f555..a94bf694f 100644 --- a/datm/cime_config/testdefs/testlist_datm.xml +++ b/datm/cime_config/testdefs/testlist_datm.xml @@ -59,6 +59,7 @@ + @@ -68,6 +69,7 @@ + @@ -77,6 +79,7 @@ + From 8aab1aeb9afc7fbb4e4d212f8c57d0178bc9b905 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 19 Mar 2025 11:53:05 -0600 Subject: [PATCH 67/68] Remove DATM_MODE_ANOMALY_FORCING_MISMATCH option. --- datm/cime_config/buildnml | 7 +++---- datm/cime_config/config_component.xml | 11 ----------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/datm/cime_config/buildnml b/datm/cime_config/buildnml index 31d45d5e8..cebd9b86c 100755 --- a/datm/cime_config/buildnml +++ b/datm/cime_config/buildnml @@ -97,7 +97,8 @@ def _check_datm_af_mismatch(anomaly_forcing, datm_mode): is_cmip5_or_6 = any(x in anomaly_forcing for x in ["cmip5", "cmip6"]) if is_cmip5_or_6 and datm_mode != "CLMGSWP3v1": raise SystemExit( - "CMIP5 and CMIP6 anomalies were only generated relative for DATM_MODE='CLMGSWP3v1'" + "CMIP5 and CMIP6 anomalies were only generated relative for DATM_MODE CLMGSWP3v1." + " To fix this error, do: ./xmlchange DATM_MODE=CLMGSWP3v1" ) @@ -119,7 +120,6 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path caseroot = case.get_value("CASEROOT") datm_mode = case.get_value("DATM_MODE") - mismatch_ok = case.get_value("DATM_MODE_ANOMALY_FORCING_MISMATCH") datm_topo = case.get_value("DATM_TOPO") datm_presaero = case.get_value("DATM_PRESAERO") datm_presndep = case.get_value("DATM_PRESNDEP") @@ -236,8 +236,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path # Set anomaly forcing in datm.streams.xml anomaly_forcing = nmlgen.get_value("anomaly_forcing") if anomaly_forcing[0] is not None and anomaly_forcing[0] != "none": - if not mismatch_ok: - _check_datm_af_mismatch(anomaly_forcing[0], datm_mode) + _check_datm_af_mismatch(anomaly_forcing[0], datm_mode) streamlist += anomaly_forcing # Generate datm.streams.xml diff --git a/datm/cime_config/config_component.xml b/datm/cime_config/config_component.xml index c4c886d32..107929616 100644 --- a/datm/cime_config/config_component.xml +++ b/datm/cime_config/config_component.xml @@ -40,17 +40,6 @@ Name of atmospheric component - - logical - TRUE,FALSE - FALSE - run_component_datm - env_run.xml - If set to true, then user will be allowed to specify an anomaly forcing that was based - on a different climate forcing than what's given in DATM_MODE - - - char CORE2_NYF,CORE2_IAF,CLM_QIAN,CLM_QIAN_WISO,1PT,CLMCRUNCEP,CLMCRUNCEPv7,CLMGSWP3v1,CLMNLDAS2,CPLHIST,CORE_IAF_JRA,CORE_IAF_JRA_1p4_2018,CORE_IAF_JRA_1p5_2023,ERA5,SIMPLE From 877024eaec4f645cd0c3ec2700d8cebb61a0951a Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 21 Mar 2025 07:32:04 -0600 Subject: [PATCH 68/68] needed to be added to CMakeLists.txt --- share/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 3a821304b..cee2936d4 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -19,6 +19,7 @@ add_library(cdeps_share ${GenF90_SRCS} shr_strconvert_mod.F90 shr_precip_mod.F90 shr_string_mod.F90 + shr_is_restart_fh_mod.F90 nuopc_shr_methods.F90) target_include_directories (cdeps_share PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${ESMF_F90COMPILEPATHS} ${PIO_Fortran_INCLUDE_DIRS})