From f3e94bf541bce414dec82b18fad3a6d04bb3a2af Mon Sep 17 00:00:00 2001 From: EZHILSABAREESH KANNADASAN Date: Wed, 12 Jul 2023 10:33:40 +1000 Subject: [PATCH 01/12] Support JRA55-do --- CDEPS/CMakeLists.txt | 2 +- CDEPS/extra_sources/datm.streams.xml | 257 ++++++++++++++ CDEPS/extra_sources/datm_datamode_jra_mod.F90 | 323 ++++++++++++++++++ CDEPS/extra_sources/drof.streams.xml | 46 +++ 4 files changed, 627 insertions(+), 1 deletion(-) create mode 100644 CDEPS/extra_sources/datm.streams.xml create mode 100644 CDEPS/extra_sources/datm_datamode_jra_mod.F90 create mode 100644 CDEPS/extra_sources/drof.streams.xml diff --git a/CDEPS/CMakeLists.txt b/CDEPS/CMakeLists.txt index bab4b42..dc485a6 100644 --- a/CDEPS/CMakeLists.txt +++ b/CDEPS/CMakeLists.txt @@ -23,7 +23,7 @@ list(APPEND cdeps_datm_src_files CDEPS/datm/datm_datamode_cplhist_mod.F90 CDEPS/datm/datm_datamode_era5_mod.F90 CDEPS/datm/datm_datamode_gefs_mod.F90 - CDEPS/datm/datm_datamode_jra_mod.F90 + extra_sources/datm_datamode_jra_mod.F90 ) diff --git a/CDEPS/extra_sources/datm.streams.xml b/CDEPS/extra_sources/datm.streams.xml new file mode 100644 index 0000000..14fe68f --- /dev/null +++ b/CDEPS/extra_sources/datm.streams.xml @@ -0,0 +1,257 @@ + + + + + cycle + linear + single + bilinear + 1.5 + 1990 + 1990 + 1 + null + ./input/TL319_151007_ESMFmesh.nc + null + + ./input/JRA.v1.3.prec.TL319.1990.171019.nc + + + prsn Faxa_prsn + + 0 + + + + cycle + linear + single + bilinear + 1.5 + 1990 + 1990 + 1 + null + ./input/TL319_151007_ESMFmesh.nc + null + + ./input/JRA.v1.3.prec.TL319.1958.171019.nc + + + prra Faxa_prrn + + 0 + + + + cycle + linear + single + bilinear + 1.5 + 1990 + 1990 + 1 + null + ./input/TL319_151007_ESMFmesh.nc + null + + ./input/JRA.v1.3.lwdn.TL319.1990.171019.nc + + + rlds Faxa_lwdn + + 0 + + + + + cycle + coszen + single + bilinear + 1.5 + 1990 + 1990 + 1 + null + ./input/TL319_151007_ESMFmesh.nc + null + + ./input/JRA.v1.3.swdn.TL319.1990.171019.nc + + + rsds Faxa_swdn + + -5400 + + + + + cycle + linear + single + bilinear + 1.5 + 1990 + 1990 + 1 + null + ./input/TL319_151007_ESMFmesh.nc + null + + ./input/JRA.v1.3.q_10.TL319.1990.171019.nc + + + huss Sa_shum + + 0 + + + + + cycle + linear + single + bilinear + 1.5 + 1990 + 1990 + 1 + null + ./input/TL319_151007_ESMFmesh.nc + null + + ./input/JRA.v1.3.slp.TL319.1990.171019.nc + + + psl Sa_pslv + + 0 + + + + + cycle + linear + single + bilinear + 1.5 + 1990 + 1990 + 1 + null + ./input/TL319_151007_ESMFmesh.nc + null + + ./input/JRA.v1.3.t_10.TL319.1990.171019.nc + + + tas Sa_tbot + + 0 + + + + + cycle + linear + single + bilinear + 1.5 + 1990 + 1990 + 1 + null + ./input/TL319_151007_ESMFmesh.nc + null + + ./input/JRA.v1.3.u_10.TL319.1990.171019.nc + + + uas Sa_u + + 0 + + + + + cycle + linear + single + bilinear + 1.5 + 1990 + 1990 + 1 + null + ./input/TL319_151007_ESMFmesh.nc + null + + ./input/JRA.v1.3.v_10.TL319.1990.171019.nc + + + vas Sa_v + + 0 + + + + + cycle + linear + single + bilinear + 1.5 + 2000 + 2000 + 1 + null + ./input/fv0.9x1.25_141008_polemod_ESMFmesh.nc + null + + ./input/aerosoldep_WACCM.ensmean_monthly_hist_1849-2015_0.9x1.25_CMIP6_c180926.nc + + + BCDEPWET Faxa_bcphiwet + BCPHODRY Faxa_bcphodry + BCPHIDRY Faxa_bcphidry + OCDEPWET Faxa_ocphiwet + OCPHIDRY Faxa_ocphidry + OCPHODRY Faxa_ocphodry + DSTX01WD Faxa_dstwet1 + DSTX01DD Faxa_dstdry1 + DSTX02WD Faxa_dstwet2 + DSTX02DD Faxa_dstdry2 + DSTX03WD Faxa_dstwet3 + DSTX03DD Faxa_dstdry3 + DSTX04WD Faxa_dstwet4 + DSTX04DD Faxa_dstdry4 + + 0 + + + + + cycle + linear + single + bilinear + 1.5 + 2000 + 2000 + 1 + null + ./input/fv0.9x1.25_141008_polemod_ESMFmesh.nc + null + + ./input/fndep_clm_hist_b.e21.BWHIST.f09_g17.CMIP6-historical-WACCM.ensmean_1849-2015_monthly_0.9x1.25_c180926.nc + + + NDEP_NHx_month Faxa_ndep_nhx + NDEP_NOy_month Faxa_ndep_noy + + 0 + + + diff --git a/CDEPS/extra_sources/datm_datamode_jra_mod.F90 b/CDEPS/extra_sources/datm_datamode_jra_mod.F90 new file mode 100644 index 0000000..4009a49 --- /dev/null +++ b/CDEPS/extra_sources/datm_datamode_jra_mod.F90 @@ -0,0 +1,323 @@ +module datm_datamode_jra_mod + + use ESMF , only : ESMF_State, ESMF_StateGet, ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO + use ESMF , only : ESMF_MeshGet + 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_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 + use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, dshr_fldbun_regrid, chkerr + 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_jra_advertise + public :: datm_datamode_jra_init_pointers + public :: datm_datamode_jra_advance + public :: datm_datamode_jra_restart_write + public :: datm_datamode_jra_restart_read + + ! export state pointers + real(r8), pointer :: Sa_z(:) => null() + real(r8), pointer :: Sa_tbot(:) => null() + real(r8), pointer :: Sa_ptem(:) => null() + real(r8), pointer :: Sa_shum(:) => null() + real(r8), pointer :: Sa_dens(:) => null() + real(r8), pointer :: Sa_pbot(:) => null() + real(r8), pointer :: Sa_pslv(:) => null() + real(r8), pointer :: Faxa_rainc(:) => null() + real(r8), pointer :: Faxa_rainl(:) => null() + real(r8), pointer :: Faxa_snowc(:) => null() + real(r8), pointer :: Faxa_snowl(:) => 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() + real(r8), pointer :: Faxa_swnet(:) => null() + real(r8), pointer :: Faxa_ndep(:,:) => null() + + ! stream data + real(r8), pointer :: strm_prec(:) => null() + real(r8), pointer :: strm_prrn(:) => null() ! Rainfall flux + real(r8), pointer :: strm_prsn(:) => null() ! Snowfall flux + real(r8), pointer :: strm_swdn(:) => null() + + ! othe module arrays + real(R8), pointer :: yc(:) ! array of model latitudes + + ! constants + real(R8) , parameter :: tKFrz = SHR_CONST_TKFRZ + real(R8) , parameter :: rdair = SHR_CONST_RDAIR ! dry air gas constant ~ J/K/kg + real(R8) , parameter :: degtorad = SHR_CONST_PI/180.0_R8 + real(R8) , parameter :: phs_c0 = 0.298_R8 + real(R8) , parameter :: dLWarc = -5.000_R8 + + character(*), parameter :: nullstr = 'null' + character(*), parameter :: rpfile = 'rpointer.atm' + character(*), parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine datm_datamode_jra_advertise(exportState, fldsexport, flds_scalar_name, & + flds_co2, flds_wiso, flds_presaero, flds_presndep, rc) + + ! input/output variables + type(esmf_State) , intent(inout) :: exportState + type(fldlist_type) , pointer :: fldsexport + character(len=*) , intent(in) :: flds_scalar_name + logical , intent(in) :: flds_co2 + logical , intent(in) :: flds_wiso + logical , intent(in) :: flds_presaero + logical , intent(in) :: flds_presndep + 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_ptem' ) + call dshr_fldList_add(fldsExport, 'Sa_dens' ) + call dshr_fldList_add(fldsExport, 'Sa_pslv' ) + 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, 'Faxa_rainc' ) + call dshr_fldList_add(fldsExport, 'Faxa_rainl' ) + call dshr_fldList_add(fldsExport, 'Faxa_snowc' ) + call dshr_fldList_add(fldsExport, 'Faxa_snowl' ) + 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_swnet' ) + call dshr_fldList_add(fldsExport, 'Faxa_lwdn' ) + call dshr_fldList_add(fldsExport, 'Faxa_swdn' ) + + if (flds_co2) then + call dshr_fldList_add(fldsExport, 'Sa_co2prog') + call dshr_fldList_add(fldsExport, 'Sa_co2diag') + end if + if (flds_presaero) then + call dshr_fldList_add(fldsExport, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) + call dshr_fldList_add(fldsExport, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) + call dshr_fldList_add(fldsExport, 'Faxa_dstwet' , ungridded_lbound=1, ungridded_ubound=4) + call dshr_fldList_add(fldsExport, 'Faxa_dstdry' , ungridded_lbound=1, ungridded_ubound=4) + end if + if (flds_presndep) then + call dshr_fldList_add(fldsExport, 'Faxa_ndep', ungridded_lbound=1, ungridded_ubound=2) + end if + if (flds_wiso) then + call dshr_fldList_add(fldsExport, 'Faxa_rainc_wiso', ungridded_lbound=1, ungridded_ubound=3) + call dshr_fldList_add(fldsExport, 'Faxa_rainl_wiso', ungridded_lbound=1, ungridded_ubound=3) + call dshr_fldList_add(fldsExport, 'Faxa_snowc_wiso', ungridded_lbound=1, ungridded_ubound=3) + call dshr_fldList_add(fldsExport, 'Faxa_snowl_wiso', ungridded_lbound=1, ungridded_ubound=3) + call dshr_fldList_add(fldsExport, 'Faxa_shum_wiso' , ungridded_lbound=1, ungridded_ubound=3) + end if + + 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_jra_advertise + + !=============================================================================== + subroutine datm_datamode_jra_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 + integer :: n + integer :: lsize + integer :: spatialDim ! number of dimension in mesh + integer :: numOwnedElements ! size of mesh + real(r8), pointer :: ownedElemCoords(:) ! mesh lat and lons + type(ESMF_StateItem_Flag) :: itemFlag + character(len=*), parameter :: subname='(datm_init_pointers): ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + lsize = sdat%model_lsize + + call ESMF_MeshGet(sdat%model_mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + allocate(yc(numOwnedElements)) + call ESMF_MeshGet(sdat%model_mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + do n = 1,numOwnedElements + yc(n) = ownedElemCoords(2*n) + end do + + call shr_strdata_get_stream_pointer( sdat, 'Faxa_prrn' , strm_prrn , rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call shr_strdata_get_stream_pointer( sdat, 'Faxa_prsn' , strm_prsn , rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call shr_strdata_get_stream_pointer( sdat, 'Faxa_swdn' , strm_swdn , rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + 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_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_pslv' , fldptr1=Sa_pslv , rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Sa_ptem' , fldptr1=Sa_ptem , 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_dens' , fldptr1=Sa_dens , rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Faxa_rainc' , fldptr1=Faxa_rainc , rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Faxa_rainl' , fldptr1=Faxa_rainl , rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Faxa_snowc' , fldptr1=Faxa_snowc , rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call dshr_state_getfldptr(exportState, 'Faxa_snowl' , fldptr1=Faxa_snowl , 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_swnet' , fldptr1=Faxa_swnet , rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call ESMF_StateGet(exportState, 'Faxa_ndep', itemFlag, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (itemflag /= ESMF_STATEITEM_NOTFOUND) then + call dshr_state_getfldptr(exportState, 'Faxa_ndep', fldptr2=Faxa_ndep, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if + + ! erro check + if (.not. associated(strm_prsn) .or. .not. associated(strm_swdn)) then + call shr_sys_abort(trim(subname)//'ERROR: prec and swdn must be in streams for CORE_IAF_JRA') + endif + + end subroutine datm_datamode_jra_init_pointers + + !=============================================================================== + subroutine datm_datamode_jra_advance(exportstate, target_ymd, target_tod, model_calendar, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer , intent(in) :: target_ymd + integer , intent(in) :: target_tod + character(len=*) , intent(in) :: model_calendar + integer , intent(out) :: rc + + ! local variables + integer :: n + integer :: lsize + real(R8) :: avg_alb ! average albedo + real(R8) :: rday ! elapsed day + real(R8) :: cosFactor ! cosine factor + character(len=*), parameter :: subname='(datm_datamode_jra): ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + lsize = size(Sa_z) + + call shr_cal_date2julian(target_ymd, target_tod, rday, model_calendar) + rday = mod((rday - 1.0_R8),365.0_R8) + cosfactor = cos((2.0_R8*SHR_CONST_PI*rday)/365 - phs_c0) + + do n = 1,lsize + Sa_z(n) = 10.0_R8 + Sa_pbot(n) = Sa_pslv(n) + Sa_ptem(n) = Sa_tbot(n) + + ! density computation for JRA55 forcing + Sa_dens(n) = Sa_pbot(n)/(rdair*Sa_tbot(n)*(1 + 0.608*Sa_shum(n))) + + ! precipitation data + Faxa_rainc(n) = 0.0_R8 ! default zero + Faxa_snowc(n) = 0.0_R8 + + Faxa_snowl(n) = strm_prsn(n) ! Snowfall flux + Faxa_rainl(n) = strm_prrn(n) ! Rainfall flux + + ! radiation data - fabricate required swdn components from net swdn + Faxa_swvdr(n) = strm_swdn(n)*(0.28_R8) + Faxa_swndr(n) = strm_swdn(n)*(0.31_R8) + Faxa_swvdf(n) = strm_swdn(n)*(0.24_R8) + Faxa_swndf(n) = strm_swdn(n)*(0.17_R8) + + ! radiation data - compute net short-wave based on LY08 latitudinally-varying albedo + avg_alb = ( 0.069 - 0.011*cos(2.0_R8*yc(n)*degtorad ) ) + Faxa_swnet(n) = strm_swdn(n)*(1.0_R8 - avg_alb) + enddo ! lsize + + if (associated(Faxa_ndep)) then + ! convert ndep flux to units of kgN/m2/s (input is in gN/m2/s) + Faxa_ndep(:,:) = Faxa_ndep(:,:) / 1000._r8 + end if + + end subroutine datm_datamode_jra_advance + + !=============================================================================== + subroutine datm_datamode_jra_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_jra_restart_write + + !=============================================================================== + subroutine datm_datamode_jra_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_jra_restart_read + +end module datm_datamode_jra_mod diff --git a/CDEPS/extra_sources/drof.streams.xml b/CDEPS/extra_sources/drof.streams.xml new file mode 100644 index 0000000..f64e489 --- /dev/null +++ b/CDEPS/extra_sources/drof.streams.xml @@ -0,0 +1,46 @@ + + + + + cycle + upper + single + bilinear + 3.0 + 1990 + 1990 + 1 + null + ./input/JRA.v1.4.runoff.1958_ESMFmesh_cdf5_20201020.nc + null + + ./input/JRA.v1.1.runoff.1990.170807.nc + + + friver Forr_rofl + + 0 + + + + cycle + upper + single + bilinear + 3.0 + 1990 + 1990 + 1 + null + ./input/JRA.v1.4.runoff.1958_ESMFmesh_cdf5_20201020.nc + null + + ./input/JRA.v1.1.runoff.1990.170807.nc + + + licalvf Forr_rofi + + 0 + + + From 48df147f5916faefa96bf70af3584ba0f1428d3a Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Wed, 12 Jul 2023 13:58:17 +1000 Subject: [PATCH 02/12] Update and rename datm_datamode_jra_mod.F90 to datm_datamode_jra55do_mod.F90 Module and subroutine names are changed to jra55do --- ..._mod.F90 => datm_datamode_jra55do_mod.F90} | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) rename CDEPS/extra_sources/{datm_datamode_jra_mod.F90 => datm_datamode_jra55do_mod.F90} (94%) diff --git a/CDEPS/extra_sources/datm_datamode_jra_mod.F90 b/CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 similarity index 94% rename from CDEPS/extra_sources/datm_datamode_jra_mod.F90 rename to CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 index 4009a49..8e34b66 100644 --- a/CDEPS/extra_sources/datm_datamode_jra_mod.F90 +++ b/CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 @@ -1,4 +1,4 @@ -module datm_datamode_jra_mod +module datm_datamode_jra55do_mod use ESMF , only : ESMF_State, ESMF_StateGet, ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO use ESMF , only : ESMF_MeshGet @@ -67,7 +67,7 @@ module datm_datamode_jra_mod contains !=============================================================================== - subroutine datm_datamode_jra_advertise(exportState, fldsexport, flds_scalar_name, & + subroutine datm_datamode_jra55do_advertise(exportState, fldsexport, flds_scalar_name, & flds_co2, flds_wiso, flds_presaero, flds_presndep, rc) ! input/output variables @@ -137,10 +137,10 @@ subroutine datm_datamode_jra_advertise(exportState, fldsexport, flds_scalar_name fldList => fldList%next enddo - end subroutine datm_datamode_jra_advertise + end subroutine datm_datamode_jra55do_advertise !=============================================================================== - subroutine datm_datamode_jra_init_pointers(exportState, sdat, rc) + subroutine datm_datamode_jra55do_init_pointers(exportState, sdat, rc) ! input/output variables type(ESMF_State) , intent(inout) :: exportState @@ -223,10 +223,10 @@ subroutine datm_datamode_jra_init_pointers(exportState, sdat, rc) call shr_sys_abort(trim(subname)//'ERROR: prec and swdn must be in streams for CORE_IAF_JRA') endif - end subroutine datm_datamode_jra_init_pointers + end subroutine datm_datamode_jra55do_init_pointers !=============================================================================== - subroutine datm_datamode_jra_advance(exportstate, target_ymd, target_tod, model_calendar, rc) + subroutine datm_datamode_jra55do_advance(exportstate, target_ymd, target_tod, model_calendar, rc) ! input/output variables type(ESMF_State) , intent(inout) :: exportState @@ -283,10 +283,10 @@ subroutine datm_datamode_jra_advance(exportstate, target_ymd, target_tod, model_ Faxa_ndep(:,:) = Faxa_ndep(:,:) / 1000._r8 end if - end subroutine datm_datamode_jra_advance + end subroutine datm_datamode_jra55do_advance !=============================================================================== - subroutine datm_datamode_jra_restart_write(case_name, inst_suffix, ymd, tod, & + subroutine datm_datamode_jra55do_restart_write(case_name, inst_suffix, ymd, tod, & logunit, my_task, sdat) ! input/output variables @@ -302,10 +302,10 @@ subroutine datm_datamode_jra_restart_write(case_name, inst_suffix, ymd, tod, & call dshr_restart_write(rpfile, case_name, 'datm', inst_suffix, ymd, tod, & logunit, my_task, sdat) - end subroutine datm_datamode_jra_restart_write + end subroutine datm_datamode_jra55do_restart_write !=============================================================================== - subroutine datm_datamode_jra_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) + subroutine datm_datamode_jra55do_restart_read(rest_filem, inst_suffix, logunit, my_task, mpicom, sdat) ! input/output arguments character(len=*) , intent(inout) :: rest_filem @@ -318,6 +318,6 @@ subroutine datm_datamode_jra_restart_read(rest_filem, inst_suffix, logunit, my_t call dshr_restart_read(rest_filem, rpfile, inst_suffix, nullstr, logunit, my_task, mpicom, sdat) - end subroutine datm_datamode_jra_restart_read + end subroutine datm_datamode_jra55do_restart_read -end module datm_datamode_jra_mod +end module datm_datamode_jra55do_mod From 7a58b25e3da1d53239c384c0acb31717973c5b4d Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Wed, 12 Jul 2023 14:10:24 +1000 Subject: [PATCH 03/12] Update CMakeLists.txt Changed file path from extra_sources/datm_datamode_jra55_mod.F90 to extra_sources/datm_datamode_jra55do_mod.F90 --- CDEPS/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CDEPS/CMakeLists.txt b/CDEPS/CMakeLists.txt index dc485a6..4e6f6e5 100644 --- a/CDEPS/CMakeLists.txt +++ b/CDEPS/CMakeLists.txt @@ -23,7 +23,8 @@ list(APPEND cdeps_datm_src_files CDEPS/datm/datm_datamode_cplhist_mod.F90 CDEPS/datm/datm_datamode_era5_mod.F90 CDEPS/datm/datm_datamode_gefs_mod.F90 - extra_sources/datm_datamode_jra_mod.F90 + CDEPS/datm/datm_datamode_jra_mod.F90 + extra_sources/datm_datamode_jra55do_mod.F90 ) From 65e9a2242dd6e6785f1344fd6b1bca3882fe09b6 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Wed, 12 Jul 2023 14:15:24 +1000 Subject: [PATCH 04/12] Update datm_datamode_jra55do_mod.F90 Module and subroutine names are changed to jra55do --- CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 b/CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 index 8e34b66..e49471f 100644 --- a/CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 +++ b/CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 @@ -17,11 +17,11 @@ module datm_datamode_jra55do_mod implicit none private ! except - public :: datm_datamode_jra_advertise - public :: datm_datamode_jra_init_pointers - public :: datm_datamode_jra_advance - public :: datm_datamode_jra_restart_write - public :: datm_datamode_jra_restart_read + public :: datm_datamode_jra55do_advertise + public :: datm_datamode_jra55do_init_pointers + public :: datm_datamode_jra55do_advance + public :: datm_datamode_jra55do_restart_write + public :: datm_datamode_jra55do_restart_read ! export state pointers real(r8), pointer :: Sa_z(:) => null() From 45157c6555ea036f0ae0de592a7320fd6eec999c Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Wed, 12 Jul 2023 14:39:44 +1000 Subject: [PATCH 05/12] Update drof.streams.xml Updated to use the RYF inputs from /g/data/ik11/inputs/JRA-55/RYF/v1-4 --- CDEPS/extra_sources/drof.streams.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CDEPS/extra_sources/drof.streams.xml b/CDEPS/extra_sources/drof.streams.xml index f64e489..bcaa14c 100644 --- a/CDEPS/extra_sources/drof.streams.xml +++ b/CDEPS/extra_sources/drof.streams.xml @@ -14,7 +14,7 @@ ./input/JRA.v1.4.runoff.1958_ESMFmesh_cdf5_20201020.nc null - ./input/JRA.v1.1.runoff.1990.170807.nc + /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.friver.1990_1991.nc friver Forr_rofl @@ -35,7 +35,7 @@ ./input/JRA.v1.4.runoff.1958_ESMFmesh_cdf5_20201020.nc null - ./input/JRA.v1.1.runoff.1990.170807.nc + /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.licalvf.1990_1991.nc licalvf Forr_rofi From dff70508609552774b483ff350d1324c1281a9f7 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Wed, 12 Jul 2023 15:02:23 +1000 Subject: [PATCH 06/12] Update datm.streams.xml Updated to use the RYF inputs from /g/data/ik11/inputs/JRA-55/RYF/v1-4 --- CDEPS/extra_sources/datm.streams.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CDEPS/extra_sources/datm.streams.xml b/CDEPS/extra_sources/datm.streams.xml index 14fe68f..d6b71a9 100644 --- a/CDEPS/extra_sources/datm.streams.xml +++ b/CDEPS/extra_sources/datm.streams.xml @@ -14,7 +14,7 @@ ./input/TL319_151007_ESMFmesh.nc null - ./input/JRA.v1.3.prec.TL319.1990.171019.nc + /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.prsn.1990_1991.nc prsn Faxa_prsn @@ -35,7 +35,7 @@ ./input/TL319_151007_ESMFmesh.nc null - ./input/JRA.v1.3.prec.TL319.1958.171019.nc + /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.prra.1990_1991.nc prra Faxa_prrn @@ -56,7 +56,7 @@ ./input/TL319_151007_ESMFmesh.nc null - ./input/JRA.v1.3.lwdn.TL319.1990.171019.nc + /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.rlds.1990_1991.nc rlds Faxa_lwdn @@ -78,7 +78,7 @@ ./input/TL319_151007_ESMFmesh.nc null - ./input/JRA.v1.3.swdn.TL319.1990.171019.nc + /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.rsds.1990_1991.nc rsds Faxa_swdn @@ -100,7 +100,7 @@ ./input/TL319_151007_ESMFmesh.nc null - ./input/JRA.v1.3.q_10.TL319.1990.171019.nc + /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.huss.1990_1991.nc huss Sa_shum @@ -122,7 +122,7 @@ ./input/TL319_151007_ESMFmesh.nc null - ./input/JRA.v1.3.slp.TL319.1990.171019.nc + /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.psl.1990_1991.nc psl Sa_pslv @@ -144,7 +144,7 @@ ./input/TL319_151007_ESMFmesh.nc null - ./input/JRA.v1.3.t_10.TL319.1990.171019.nc + /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.tas.1990_1991.nc tas Sa_tbot @@ -166,7 +166,7 @@ ./input/TL319_151007_ESMFmesh.nc null - ./input/JRA.v1.3.u_10.TL319.1990.171019.nc + /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.uas.1990_1991.nc uas Sa_u @@ -188,7 +188,7 @@ ./input/TL319_151007_ESMFmesh.nc null - ./input/JRA.v1.3.v_10.TL319.1990.171019.nc + /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.vas.1990_1991.nc vas Sa_v From 2571214ee5e4566e6791c75a35565c9861207e4f Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 Date: Thu, 13 Jul 2023 09:21:32 +1000 Subject: [PATCH 07/12] Updated atm_comp_nuopc.F90 to support JRA-55 do --- CDEPS/CMakeLists.txt | 2 +- CDEPS/extra_sources/atm_comp_nuopc.F90 | 911 +++++++++++++++++++++++++ 2 files changed, 912 insertions(+), 1 deletion(-) create mode 100644 CDEPS/extra_sources/atm_comp_nuopc.F90 diff --git a/CDEPS/CMakeLists.txt b/CDEPS/CMakeLists.txt index 4e6f6e5..b18953c 100644 --- a/CDEPS/CMakeLists.txt +++ b/CDEPS/CMakeLists.txt @@ -16,7 +16,7 @@ list(APPEND cdeps_drof_src_files ) list(APPEND cdeps_datm_src_files - CDEPS/datm/atm_comp_nuopc.F90 + extra_sources/atm_comp_nuopc.F90 CDEPS/datm/datm_datamode_cfsr_mod.F90 CDEPS/datm/datm_datamode_clmncep_mod.F90 CDEPS/datm/datm_datamode_core2_mod.F90 diff --git a/CDEPS/extra_sources/atm_comp_nuopc.F90 b/CDEPS/extra_sources/atm_comp_nuopc.F90 new file mode 100644 index 0000000..66a111f --- /dev/null +++ b/CDEPS/extra_sources/atm_comp_nuopc.F90 @@ -0,0 +1,911 @@ +#ifdef CESMCOUPLED +module atm_comp_nuopc +#else +module cdeps_datm_comp +#endif + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for DATM + !---------------------------------------------------------------------------- + + use ESMF , only : ESMF_VM, ESMF_VMBroadcast + use ESMF , only : ESMF_Mesh, ESMF_GridComp, ESMF_SUCCESS, ESMF_LogWrite + use ESMF , only : ESMF_GridCompSetEntryPoint, ESMF_METHOD_INITIALIZE + use ESMF , only : ESMF_MethodRemove, ESMF_State, ESMF_Clock, ESMF_TimeInterval + use ESMF , only : ESMF_State, ESMF_Field, ESMF_LOGMSG_INFO, ESMF_ClockGet + use ESMF , only : ESMF_Time, ESMF_Alarm, ESMF_TimeGet, ESMF_TimeInterval + use ESMF , only : operator(+), ESMF_TimeIntervalGet, ESMF_ClockGetAlarm + use ESMF , only : ESMF_AlarmIsRinging, ESMF_AlarmRingerOff, ESMF_StateGet + use ESMF , only : ESMF_FieldGet, ESMF_MAXSTR, ESMF_VMBroadcast + use ESMF , only : ESMF_TraceRegionEnter, ESMF_TraceRegionExit, ESMF_GridCompGet + use NUOPC , only : NUOPC_CompDerive, NUOPC_CompSetEntryPoint, NUOPC_CompSpecialize + use NUOPC , only : NUOPC_CompAttributeGet, NUOPC_Advertise + use NUOPC_Model , only : model_routine_SS => SetServices + use NUOPC_Model , only : model_label_Advance => label_Advance + use NUOPC_Model , only : model_label_SetRunClock => label_SetRunClock + 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_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 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 + use dshr_mod , only : dshr_model_initphase, dshr_init + use dshr_mod , only : dshr_state_setscalar, dshr_set_runclock, dshr_log_clock_advance + use dshr_mod , only : dshr_mesh_init, dshr_check_restart_alarm + use dshr_mod , only : dshr_orbital_init, dshr_orbital_update + use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy + use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add, dshr_fldlist_realize + + use datm_datamode_core2_mod , only : datm_datamode_core2_advertise + use datm_datamode_core2_mod , only : datm_datamode_core2_init_pointers + use datm_datamode_core2_mod , only : datm_datamode_core2_advance + use datm_datamode_core2_mod , only : datm_datamode_core2_restart_write + use datm_datamode_core2_mod , only : datm_datamode_core2_restart_read + + use datm_datamode_jra_mod , only : datm_datamode_jra_advertise + use datm_datamode_jra_mod , only : datm_datamode_jra_init_pointers + use datm_datamode_jra_mod , only : datm_datamode_jra_advance + use datm_datamode_jra_mod , only : datm_datamode_jra_restart_write + use datm_datamode_jra_mod , only : datm_datamode_jra_restart_read + + use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_advertise + use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_init_pointers + use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_advance + use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_restart_write + use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_restart_read + + use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_advertise + use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_init_pointers + use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_advance + use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_restart_write + use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_restart_read + + use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_advertise + use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_init_pointers + use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_advance + use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_restart_write + use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_restart_read + + use datm_datamode_era5_mod , only : datm_datamode_era5_advertise + use datm_datamode_era5_mod , only : datm_datamode_era5_init_pointers + use datm_datamode_era5_mod , only : datm_datamode_era5_advance + use datm_datamode_era5_mod , only : datm_datamode_era5_restart_write + use datm_datamode_era5_mod , only : datm_datamode_era5_restart_read + + use datm_datamode_gefs_mod , only : datm_datamode_gefs_advertise + use datm_datamode_gefs_mod , only : datm_datamode_gefs_init_pointers + use datm_datamode_gefs_mod , only : datm_datamode_gefs_advance + 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 + + implicit none + private ! except + + public :: SetServices + public :: SetVM + private :: InitializeAdvertise + private :: InitializeRealize + private :: ModelAdvance + private :: datm_comp_run + private :: ModelFinalize + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + type(shr_strdata_type) :: sdat + type(ESMF_Mesh) :: model_mesh ! model mesh + character(len=128) :: flds_scalar_name = '' + integer :: flds_scalar_num = 0 + integer :: flds_scalar_index_nx = 0 + integer :: flds_scalar_index_ny = 0 + integer :: flds_scalar_index_nextsw_cday = 0 + integer :: mpicom ! mpi communicator + integer :: my_task ! my task in mpi communicator mpicom + logical :: mainproc ! true of my_task == main_task + integer :: inst_index ! number of current instance (ie. 1) + character(len=16) :: inst_suffix = "" ! char string associated with instance (ie. "_0001" or "") + integer :: logunit ! logging unit number + logical :: restart_read ! start from restart + character(CL) :: case_name ! case name + character(len=*) , parameter :: nullstr = 'null' + + ! datm_in namelist input + character(CL) :: nlfilename = nullstr ! filename to obtain namelist info from + character(CL) :: streamfilename = nullstr ! filename to obtain stream info from + character(CL) :: dataMode = nullstr ! flags physics options wrt input data + character(CL) :: model_meshfile = nullstr ! full pathname to model meshfile + character(CL) :: model_maskfile = nullstr ! full pathname to obtain mask from + integer :: iradsw = 0 ! radiation interval (input namelist) + character(CL) :: factorFn_mesh = 'null' ! file containing correction factors mesh + character(CL) :: factorFn_data = 'null' ! file containing correction factors data + logical :: flds_presaero = .false. ! true => send valid prescribed aero fields to mediator + logical :: flds_presndep = .false. ! true => send valid prescribed ndep fields to mediator + logical :: flds_preso3 = .false. ! true => send valid prescribed ozone fields to mediator + logical :: flds_co2 = .false. ! true => send prescribed co2 to mediator + logical :: flds_wiso = .false. ! true => send water isotopes to mediator + + character(CL) :: bias_correct = nullstr ! send bias correction fields to coupler + character(CL) :: anomaly_forcing(8) = nullstr ! send anomaly forcing fields to coupler + + character(CL) :: restfilm = nullstr ! model restart file namelist + integer :: nx_global ! global nx + integer :: ny_global ! global ny + logical :: skip_restart_read = .false. ! true => skip restart read in continuation run + + ! linked lists + type(fldList_type) , pointer :: fldsImport => null() + type(fldList_type) , pointer :: fldsExport => null() + type(dfield_type) , pointer :: dfields => null() + + ! model mask and model fraction + real(r8), pointer :: model_frac(:) => null() + integer , pointer :: model_mask(:) => null() + + ! constants + integer :: idt ! integer model timestep + logical :: diagnose_data = .true. + integer , parameter :: main_task = 0 ! task number of main task + character(len=*) , parameter :: rpfile = 'rpointer.atm' +#ifdef CESMCOUPLED + character(*) , parameter :: modName = "(atm_comp_nuopc)" +#else + character(*) , parameter :: modName = "(cdeps_datm_comp)" +#endif + + character(*), parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO) + + ! the NUOPC gcomp component will register the generic methods + call NUOPC_CompDerive(gcomp, model_routine_SS, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! switching to IPD versions + call ESMF_GridCompSetEntryPoint(gcomp, ESMF_METHOD_INITIALIZE, & + userRoutine=dshr_model_initphase, phase=0, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! set entry point for methods that require specific implementation + call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_INITIALIZE, & + phaseLabelList=(/"IPDv01p1"/), userRoutine=InitializeAdvertise, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_INITIALIZE, & + phaseLabelList=(/"IPDv01p3"/), userRoutine=InitializeRealize, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! attach specializing method(s) + call NUOPC_CompSpecialize(gcomp, specLabel=model_label_Advance, specRoutine=ModelAdvance, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call ESMF_MethodRemove(gcomp, label=model_label_SetRunClock, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call NUOPC_CompSpecialize(gcomp, specLabel=model_label_SetRunClock, specRoutine=dshr_set_runclock, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call NUOPC_CompSpecialize(gcomp, specLabel=model_label_Finalize, specRoutine=ModelFinalize, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO) + + end subroutine SetServices + + !=============================================================================== + + subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + type(ESMF_State) :: importState, exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + + ! local variables + integer :: nu ! unit number + integer :: ierr ! error code + integer :: bcasttmp(9) + type(ESMF_VM) :: vm + character(len=*),parameter :: subname=trim(modName) // ':(InitializeAdvertise) ' + character(*) ,parameter :: F00 = "('(" // trim(modName) // ") ',8a)" + character(*) ,parameter :: F01 = "('(" // trim(modName) // ") ',a,2x,i8)" + character(*) ,parameter :: F02 = "('(" // trim(modName) // ") ',a,l6)" + !------------------------------------------------------------------------------- + + namelist / datm_nml / & + datamode, & + model_meshfile, & + model_maskfile, & + nx_global, & + ny_global, & + restfilm, & + iradsw, & + factorFn_data, & + factorFn_mesh, & + flds_presaero, & + flds_co2, & + flds_wiso, & + bias_correct, & + anomaly_forcing, & + skip_restart_read, & + flds_presndep, & + flds_preso3 + + rc = ESMF_SUCCESS + + call NUOPC_CompAttributeGet(gcomp, name='case_name', value=case_name, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! Obtain flds_scalar values, mpi values, multi-instance values and + ! set logunit and set shr logging to my log file + call dshr_init(gcomp, 'ATM', sdat, mpicom, my_task, inst_index, inst_suffix, & + flds_scalar_name, flds_scalar_num, flds_scalar_index_nx, flds_scalar_index_ny, & + logunit, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! Determine logical mainproc + mainproc = (my_task == main_task) + + ! Read atm_nml from nlfilename + if (my_task == main_task) then + nlfilename = "datm_in"//trim(inst_suffix) + open (newunit=nu,file=trim(nlfilename),status="old",action="read") + 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)) + end if + bcasttmp = 0 + bcasttmp(1) = nx_global + bcasttmp(2) = ny_global + bcasttmp(3) = iradsw + if(flds_presaero) bcasttmp(4) = 1 + if(flds_presndep) bcasttmp(5) = 1 + if(flds_preso3) bcasttmp(6) = 1 + if(flds_co2) bcasttmp(7) = 1 + if(flds_wiso) bcasttmp(8) = 1 + if(skip_restart_read) bcasttmp(9) = 1 + + end if + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMBroadcast(vm, datamode, CL, main_task, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMBroadcast(vm, bias_correct, CL, main_task, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMBroadcast(vm, anomaly_forcing, CL*8, main_task, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMBroadcast(vm, model_meshfile, CL, main_task, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMBroadcast(vm, model_maskfile, CL, main_task, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMBroadcast(vm, factorFn_data, CL, main_task, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMBroadcast(vm, factorFn_mesh, CL, main_task, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMBroadcast(vm, restfilm, CL, main_task, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMBroadcast(vm, bcasttmp, 9, main_task, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + nx_global = bcasttmp(1) + ny_global = bcasttmp(2) + iradsw = bcasttmp(3) + flds_presaero = (bcasttmp(4) == 1) + flds_presndep = (bcasttmp(5) == 1) + flds_preso3 = (bcasttmp(6) == 1) + flds_co2 = (bcasttmp(7) == 1) + flds_wiso = (bcasttmp(8) == 1) + skip_restart_read = (bcasttmp(9) == 1) + + ! write namelist input to standard out + if (my_task == main_task) then + write(logunit,F00)' case_name = ',trim(case_name) + write(logunit,F00)' datamode = ',trim(datamode) + write(logunit,F00)' model_meshfile = ',trim(model_meshfile) + write(logunit,F00)' model_maskfile = ',trim(model_maskfile) + write(logunit,F01)' nx_global = ',nx_global + write(logunit,F01)' ny_global = ',ny_global + write(logunit,F00)' restfilm = ',trim(restfilm) + write(logunit,F01)' iradsw = ',iradsw + write(logunit,F00)' factorFn_data = ',trim(factorFn_data) + write(logunit,F00)' factorFn_mesh = ',trim(factorFn_mesh) + write(logunit,F02)' flds_presaero = ',flds_presaero + write(logunit,F02)' flds_presndep = ',flds_presndep + write(logunit,F02)' flds_preso3 = ',flds_preso3 + write(logunit,F02)' flds_co2 = ',flds_co2 + write(logunit,F02)' flds_wiso = ',flds_wiso + write(logunit,F02)' skip_restart_read = ',skip_restart_read + end if + + ! Validate sdat datamode + if (mainproc) write(logunit,*) ' datm datamode = ',trim(datamode) + if ( trim(datamode) == 'CORE2_NYF' .or. & + trim(datamode) == 'CORE2_IAF' .or. & + trim(datamode) == 'CORE_IAF_JRA' .or. & + trim(datamode) == 'CLMNCEP' .or. & + trim(datamode) == 'CPLHIST' .or. & + trim(datamode) == 'GEFS' .or. & + trim(datamode) == 'CFSR' .or. & + trim(datamode) == 'ERA5') then + else + call shr_sys_abort(' ERROR illegal datm datamode = '//trim(datamode)) + endif + + ! Advertise datm fields + select case (trim(datamode)) + case ('CORE2_NYF', 'CORE2_IAF') + call datm_datamode_core2_advertise(exportState, fldsExport, flds_scalar_name, & + flds_co2, flds_wiso, flds_presaero, flds_presndep, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case ('CORE_IAF_JRA') + call datm_datamode_jra_advertise(exportState, fldsExport, flds_scalar_name, & + flds_co2, flds_wiso, flds_presaero, flds_presndep, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case ('CLMNCEP') + call datm_datamode_clmncep_advertise(exportState, fldsExport, flds_scalar_name, & + flds_co2, flds_wiso, flds_presaero, flds_presndep, flds_preso3, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case ('CPLHIST') + call datm_datamode_cplhist_advertise(exportState, fldsExport, flds_scalar_name, & + flds_co2, flds_wiso, flds_presaero, flds_presndep, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case ('ERA5') + call datm_datamode_era5_advertise(exportState, fldsExport, flds_scalar_name, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + 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 + end select + + end subroutine InitializeAdvertise + + !=============================================================================== + + subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + type(ESMF_State) :: importState, exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + + ! local variables + type(ESMF_TimeInterval) :: timeStep + type(ESMF_TIME) :: currTime + integer :: current_ymd ! model date + integer :: current_year ! model year + integer :: current_mon ! model month + integer :: current_day ! model day + integer :: current_tod ! model sec into model date + integer(i8) :: stepno ! step number + real(r8) :: nextsw_cday ! calendar of next atm sw + character(CL) :: cvalue ! character string for input config + real(R8) :: orbEccen ! orb eccentricity (unist-less) + real(R8) :: orbMvelpp ! orb moving vernal eqa (radians) + real(R8) :: orbLambm0 ! orb mean long of perhelion (radians) + real(R8) :: orbObliqr ! orb obliquity (radians) + logical :: isPresent, isSet + real(R8) :: dayofYear + character(len=*), parameter :: subname=trim(modName)//':(InitializeRealize) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO) + + ! Initialize mesh, restart flag, compid, and logunit + call ESMF_TraceRegionEnter('datm_strdata_init') + call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'ATM', nx_global, ny_global, & + model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! Initialize stream data type + streamfilename = 'datm.streams'//trim(inst_suffix) +#ifndef DISABLE_FoX + streamfilename = trim(streamfilename)//'.xml' +#endif + call shr_strdata_init_from_config(sdat, streamfilename, model_mesh, clock, 'ATM', logunit, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_TraceRegionExit('datm_strdata_init') + + ! NUOPC_Realize "realizes" a previously advertised field in the importState and exportState + ! by replacing the advertised fields with the newly created fields of the same name. + call dshr_fldlist_realize( exportState, fldsExport, flds_scalar_name, flds_scalar_num, model_mesh, & + subname//':datmExport', rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call dshr_fldlist_realize( importState, fldsImport, flds_scalar_name, flds_scalar_num, model_mesh, & + subname//':datmImport', rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! Get the time to interpolate the stream data to + call ESMF_ClockGet( clock, currTime=currTime, timeStep=timeStep, advanceCount=stepno, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_TimeGet(currTime, yy=current_year, mm=current_mon, dd=current_day, s=current_tod, & + dayofYear_r8=dayofYear, rc=rc ) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call shr_cal_ymd2date(current_year, current_mon, current_day, current_ymd) + + ! Get model timestep (idt is module variable) + call ESMF_TimeIntervalGet( timeStep, s=idt, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! Initialize and update orbital values + call dshr_orbital_init(gcomp, logunit, my_task == main_task, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call dshr_orbital_update(currTime, logunit, my_task == main_task, & + orbEccen, orbObliqr, orbLambm0, orbMvelpp, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! Run datm + call datm_comp_run(importstate, exportstate, current_ymd, current_tod, current_mon, & + orbEccen, orbMvelpp, orbLambm0, orbObliqr, restart_write=.false., rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! Add scalars to export state + call dshr_state_SetScalar(dble(nx_global),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call dshr_state_SetScalar(dble(ny_global),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxNextSwCday", value=cvalue, & + isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + read (cvalue,*) flds_scalar_index_nextsw_cday + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxNextSwCday') + endif + + nextsw_cday = getNextRadCDay(dayofYear, current_tod, stepno, idt, iradsw) + call dshr_state_SetScalar(nextsw_cday, flds_scalar_index_nextsw_cday, exportState, flds_scalar_name, flds_scalar_num, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + end subroutine InitializeRealize + + !=============================================================================== + subroutine ModelAdvance(gcomp, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_State) :: importState, exportState + type(ESMF_Clock) :: clock + type(ESMF_Time) :: currTime + type(ESMF_Time) :: nextTime + type(ESMF_TimeInterval) :: timeStep + real(r8) :: nextsw_cday + logical :: restart_write ! restart alarm is ringing + integer :: next_ymd ! model date + integer :: next_tod ! model sec into model date + integer :: yr, mon, day ! year, month, day + integer(i8) :: stepno ! step number + real(R8) :: orbEccen ! orb eccentricity (unit-less) + real(R8) :: orbMvelpp ! orb moving vernal eq (radians) + real(R8) :: orbLambm0 ! orb mean long of perhelion (radians) + real(R8) :: orbObliqr ! orb obliquity (radians) + real(R8) :: dayofYear + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_TraceRegionEnter(subname) + call shr_log_setLogUnit(logunit) + call memcheck(subname, 5, my_task==main_task) + + ! Query the Component for its clock, importState and exportState + call NUOPC_ModelGet(gcomp, modelClock=clock, importState=importState, exportState=exportState, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! For nuopc - the component clock is advanced at the end of the time interval + ! For these to match for now - need to advance nuopc one timestep ahead for + ! shr_strdata time interpolation + call ESMF_ClockGet( clock, currTime=currTime, timeStep=timeStep, advanceCount=stepno, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + nextTime = currTime + timeStep + call ESMF_TimeGet( nextTime, yy=yr, mm=mon, dd=day, s=next_tod, dayofYear_r8=dayofYear, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call shr_cal_ymd2date(yr, mon, day, next_ymd) + + ! Update the orbital values + call dshr_orbital_update(nextTime, logunit, my_task == main_task, & + orbEccen, orbObliqr, orbLambm0, orbMvelpp, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + restart_write = dshr_check_restart_alarm(clock, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! Run datm + call ESMF_TraceRegionEnter('datm_run') + call datm_comp_run(importstate, exportstate, next_ymd, next_tod, mon, & + orbEccen, orbMvelpp, orbLambm0, orbObliqr, restart_write, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_TraceRegionExit('datm_run') + + ! Update nextsw_cday for scalar data + ! Use nextYMD and nextTOD here since since the component - clock is advance at the END of the time interval + + nextsw_cday = getNextRadCDay(dayofYear, next_tod, stepno, idt, iradsw) + + call dshr_state_SetScalar(nextsw_cday, flds_scalar_index_nextsw_cday, exportState, flds_scalar_name, flds_scalar_num, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call ESMF_TraceRegionExit(subname) + + end subroutine ModelAdvance + + !=============================================================================== + subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, target_mon, & + orbEccen, orbMvelpp, orbLambm0, orbObliqr, restart_write, rc) + + ! ---------------------------------- + ! run method for datm model + ! ---------------------------------- + + ! input/output variables + type(ESMF_State) , intent(inout) :: importState + type(ESMF_State) , intent(inout) :: exportState + integer , intent(in) :: target_ymd ! model date + integer , intent(in) :: target_tod ! model sec into model date + integer , intent(in) :: target_mon ! model month + real(R8) , intent(in) :: orbEccen ! orb eccentricity (unit-less) + real(R8) , intent(in) :: orbMvelpp ! orb moving vernal eq (radians) + real(R8) , intent(in) :: orbLambm0 ! orb mean long of perhelion (radians) + real(R8) , intent(in) :: orbObliqr ! orb obliquity (radians) + logical , intent(in) :: restart_write + integer , intent(out) :: rc + + ! local variables + logical :: first_time = .true. + character(*), parameter :: subName = '(datm_comp_run) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_TraceRegionEnter('DATM_RUN') + + !-------------------- + ! First time initialization + !-------------------- + + if (first_time) then + + ! Initialize dfields + call datm_init_dfields(rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! Initialize datamode module ponters + select case (trim(datamode)) + case('CORE2_NYF','CORE2_IAF') + call datm_datamode_core2_init_pointers(exportState, sdat, datamode, factorfn_mesh, factorfn_data, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('CORE_IAF_JRA') + call datm_datamode_jra_init_pointers(exportState, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('CLMNCEP') + call datm_datamode_clmncep_init_pointers(importState, exportState, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('CPLHIST') + call datm_datamode_cplhist_init_pointers(importState, exportState, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('ERA5') + call datm_datamode_era5_init_pointers(exportState, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + 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 + end select + + ! Read restart if needed + if (restart_read .and. .not. skip_restart_read) then + select case (trim(datamode)) + case('CORE2_NYF','CORE2_IAF') + call datm_datamode_core2_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + case('CORE_IAF_JRA') + call datm_datamode_jra_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + case('CLMNCEP') + call datm_datamode_clmncep_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + case('CPLHIST') + call datm_datamode_cplhist_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + case('ERA5') + 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) + end select + end if + + ! reset first_time + first_time = .false. + end if + + !-------------------- + ! Advance datm streams + !-------------------- + + ! set data needed for cosz t-interp method + call shr_strdata_setOrbs(sdat, orbEccen, orbMvelpp, orbLambm0, orbObliqr, idt) + + ! time and spatially interpolate to model time and grid + call ESMF_TraceRegionEnter('datm_strdata_advance') + call shr_strdata_advance(sdat, target_ymd, target_tod, logunit, 'datm', rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_TraceRegionExit('datm_strdata_advance') + + ! copy all fields from streams to export state as default + ! This automatically will update the fields in the export state + call ESMF_TraceRegionEnter('datm_dfield_copy') + call dshr_dfield_copy(dfields, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_TraceRegionExit('datm_dfield_copy') + + ! Determine data model behavior based on the mode + call ESMF_TraceRegionEnter('datm_datamode') + select case (trim(datamode)) + case('CORE2_NYF','CORE2_IAF') + call datm_datamode_core2_advance(datamode, target_ymd, target_tod, target_mon, & + sdat%model_calendar, factorfn_mesh, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('CORE_IAF_JRA') + call datm_datamode_jra_advance(exportstate, target_ymd, target_tod, sdat%model_calendar, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('CLMNCEP') + call datm_datamode_clmncep_advance(mainproc, logunit, mpicom, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('CPLHIST') + call datm_datamode_cplhist_advance(mainproc, logunit, mpicom, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('ERA5') + call datm_datamode_era5_advance(exportstate, mainproc, logunit, mpicom, target_ymd, & + target_tod, sdat%model_calendar, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + 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 + end select + + ! Write restarts if needed + if (restart_write) then + select case (trim(datamode)) + case('CORE2_NYF','CORE2_IAF') + call datm_datamode_core2_restart_write(case_name, inst_suffix, target_ymd, target_tod, & + logunit, my_task, sdat) + case('CORE_IAF_JRA') + call datm_datamode_jra_restart_write(case_name, inst_suffix, target_ymd, target_tod, & + logunit, my_task, sdat) + case('CLMNCEP') + call datm_datamode_clmncep_restart_write(case_name, inst_suffix, target_ymd, target_tod, & + logunit, my_task, sdat) + case('CPLHIST') + call datm_datamode_cplhist_restart_write(case_name, inst_suffix, target_ymd, target_tod, & + logunit, my_task, sdat) + case('ERA5') + call datm_datamode_era5_restart_write(case_name, inst_suffix, target_ymd, target_tod, & + logunit, my_task, sdat) + case('GEFS') + 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 + end select + end if + + ! Log output for model date + if (mainproc) write(logunit,*) 'atm : model date ', target_ymd, target_tod + + ! Diagnostics + if (diagnose_data) then + call dshr_state_diagnose(exportState, flds_scalar_name, subname//':ES', rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end if + + call ESMF_TraceRegionExit('datm_datamode') + call ESMF_TraceRegionExit('DATM_RUN') + + !-------- + contains + !-------- + + subroutine datm_init_dfields(rc) + ! ----------------------------- + ! Initialize dfields arrays + ! (for export fields that have a corresponding stream field) + ! ----------------------------- + + ! input/output parameters + integer, intent(out) :: rc + + ! local variables + integer :: n + character(CS) :: strm_flds2(2) + character(CS) :: strm_flds3(3) + character(CS) :: strm_flds4(4) + integer :: rank + integer :: fieldcount + type(ESMF_Field) :: lfield + character(ESMF_MAXSTR) ,pointer :: lfieldnames(:) + character(*), parameter :: subName = "(datm_init_dfields) " + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemCount=fieldCount, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + allocate(lfieldnames(fieldCount)) + call ESMF_StateGet(exportState, itemNameList=lfieldnames, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + do n = 1, fieldCount + call ESMF_StateGet(exportState, itemName=trim(lfieldnames(n)), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldGet(lfield, rank=rank, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (rank == 1) then + call dshr_dfield_add( dfields, sdat, trim(lfieldnames(n)), trim(lfieldnames(n)), & + exportState, logunit, mainproc, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else if (rank == 2) then + ! The following maps stream input fields to export fields that have an ungridded dimension + ! TODO: in the future it might be better to change the format of the streams file to have two more entries + ! that could denote how the stream variables are mapped to export fields that have an ungridded dimension + + select case (trim(lfieldnames(n))) + case('Faxa_bcph') + strm_flds3 = (/'Faxa_bcphidry', 'Faxa_bcphodry', 'Faxa_bcphiwet'/) + call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds3, exportState, logunit, mainproc, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('Faxa_ocph') + strm_flds3 = (/'Faxa_ocphidry', 'Faxa_ocphodry', 'Faxa_ocphiwet'/) + call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds3, exportState, logunit, mainproc, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('Faxa_dstwet') + strm_flds4 = (/'Faxa_dstwet1', 'Faxa_dstwet2', 'Faxa_dstwet3', 'Faxa_dstwet4'/) + call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds4, exportState, logunit, mainproc, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('Faxa_dstdry') + strm_flds4 = (/'Faxa_dstdry1', 'Faxa_dstdry2', 'Faxa_dstdry3', 'Faxa_dstdry4'/) + call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds4, exportState, logunit, mainproc, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('Faxa_rainc_wiso') + strm_flds3 = (/'Faxa_rainc_16O', 'Faxa_rainc_18O', 'Faxa_rainc_HDO'/) + call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds3, exportState, logunit, mainproc, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('Faxa_rainl_wiso') + strm_flds3 = (/'Faxa_rainl_16O', 'Faxa_rainl_18O', 'Faxa_rainl_HDO'/) + call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds3, exportState, logunit, mainproc, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('Faxa_snowc_wiso') + strm_flds3 = (/'Faxa_snowc_16O', 'Faxa_snowc_18O', 'Faxa_snowc_HDO'/) + call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds3, exportState, logunit, mainproc, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('Faxa_snowl_wiso') + strm_flds3 = (/'Faxa_snowl_16O', 'Faxa_snowl_18O', 'Faxa_snowl_HDO'/) + call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds3, exportState, logunit, mainproc, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('Faxa_ndep') + strm_flds2 = (/'Faxa_ndep_nhx', 'Faxa_ndep_noy'/) + call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds2, exportState, logunit, mainproc, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('cpl_scalars') + continue + case default + call shr_sys_abort(subName//'field '//trim(lfieldnames(n))//' not recognized') + end select + end if + end do + end subroutine datm_init_dfields + + end subroutine datm_comp_run + + !=============================================================================== + real(R8) function getNextRadCDay( julday, tod, stepno, dtime, iradsw ) + + ! Return the calendar day of the next radiation time-step. + ! General Usage: nextswday = getNextRadCDay(curr_date) iradsw is + ! the frequency to update the next shortwave. in number of steps + ! (or hours if negative) Julian date. + ! -- values greater than 1 set + ! the next radiation to the present time plus 2 timesteps every iradsw + ! -- values less than 0 turn set the next radiation to the present time + ! plus two timesteps every -iradsw hours. + ! -- if iradsw is zero, the next radiation time is the + ! present time plus 1 timestep. + + ! input/output variables + real(r8) , intent(in) :: julday + integer , intent(in) :: tod + integer(i8) , intent(in) :: stepno + integer , intent(in) :: dtime + integer , intent(in) :: iradsw + + ! local variables + real(R8) :: nextsw_cday + integer :: liradsw + integer :: delta_radsw + character(*),parameter :: subName = '(getNextRadCDay) ' + !------------------------------------------------------------------------------- + + ! Note that stepno is obtained via the advancecount argument to + ! ESMF_GetClock and is the number of times the ESMF_Clock has been + ! advanced. The ESMF clock is actually advanced an additional time + ! (in order to trigger alarms) in the routine dshr_set_runclock + ! which is the specialized routine for the model_lable_SetRunClock. + ! This is called each time the ModelAdvance phase is called. Hence + ! stepno is not used to trigger the calculation of nextsw_cday. + + liradsw = iradsw + if (liradsw < 0) liradsw = nint((-liradsw *3600._r8)/dtime) + + if (liradsw > 1) then + delta_radsw = liradsw * dtime + if (mod(tod+dtime,delta_radsw) == 0 .and. stepno > 0) then + nextsw_cday = julday + 2*dtime/shr_const_cday + else + nextsw_cday = -1._r8 + end if + else + nextsw_cday = julday + dtime/shr_const_cday + end if + getNextRadCDay = nextsw_cday + + end function getNextRadCDay + + !=============================================================================== + subroutine ModelFinalize(gcomp, rc) + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (my_task == main_task) then + write(logunit,*) + write(logunit,*) 'datm : end of main integration loop' + write(logunit,*) + end if + end subroutine ModelFinalize + +#ifdef CESMCOUPLED +end module atm_comp_nuopc +#else +end module cdeps_datm_comp +#endif From aaeee3dcc365c362270be8023b3e2caaca6ed7c3 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Wed, 12 Jul 2023 15:55:52 +1000 Subject: [PATCH 08/12] moved to JRA55do1.4.0-RYF fork of the MOM6-CICE6 configuration --- CDEPS/extra_sources/datm.streams.xml | 257 --------------------------- 1 file changed, 257 deletions(-) delete mode 100644 CDEPS/extra_sources/datm.streams.xml diff --git a/CDEPS/extra_sources/datm.streams.xml b/CDEPS/extra_sources/datm.streams.xml deleted file mode 100644 index d6b71a9..0000000 --- a/CDEPS/extra_sources/datm.streams.xml +++ /dev/null @@ -1,257 +0,0 @@ - - - - - cycle - linear - single - bilinear - 1.5 - 1990 - 1990 - 1 - null - ./input/TL319_151007_ESMFmesh.nc - null - - /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.prsn.1990_1991.nc - - - prsn Faxa_prsn - - 0 - - - - cycle - linear - single - bilinear - 1.5 - 1990 - 1990 - 1 - null - ./input/TL319_151007_ESMFmesh.nc - null - - /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.prra.1990_1991.nc - - - prra Faxa_prrn - - 0 - - - - cycle - linear - single - bilinear - 1.5 - 1990 - 1990 - 1 - null - ./input/TL319_151007_ESMFmesh.nc - null - - /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.rlds.1990_1991.nc - - - rlds Faxa_lwdn - - 0 - - - - - cycle - coszen - single - bilinear - 1.5 - 1990 - 1990 - 1 - null - ./input/TL319_151007_ESMFmesh.nc - null - - /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.rsds.1990_1991.nc - - - rsds Faxa_swdn - - -5400 - - - - - cycle - linear - single - bilinear - 1.5 - 1990 - 1990 - 1 - null - ./input/TL319_151007_ESMFmesh.nc - null - - /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.huss.1990_1991.nc - - - huss Sa_shum - - 0 - - - - - cycle - linear - single - bilinear - 1.5 - 1990 - 1990 - 1 - null - ./input/TL319_151007_ESMFmesh.nc - null - - /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.psl.1990_1991.nc - - - psl Sa_pslv - - 0 - - - - - cycle - linear - single - bilinear - 1.5 - 1990 - 1990 - 1 - null - ./input/TL319_151007_ESMFmesh.nc - null - - /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.tas.1990_1991.nc - - - tas Sa_tbot - - 0 - - - - - cycle - linear - single - bilinear - 1.5 - 1990 - 1990 - 1 - null - ./input/TL319_151007_ESMFmesh.nc - null - - /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.uas.1990_1991.nc - - - uas Sa_u - - 0 - - - - - cycle - linear - single - bilinear - 1.5 - 1990 - 1990 - 1 - null - ./input/TL319_151007_ESMFmesh.nc - null - - /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.vas.1990_1991.nc - - - vas Sa_v - - 0 - - - - - cycle - linear - single - bilinear - 1.5 - 2000 - 2000 - 1 - null - ./input/fv0.9x1.25_141008_polemod_ESMFmesh.nc - null - - ./input/aerosoldep_WACCM.ensmean_monthly_hist_1849-2015_0.9x1.25_CMIP6_c180926.nc - - - BCDEPWET Faxa_bcphiwet - BCPHODRY Faxa_bcphodry - BCPHIDRY Faxa_bcphidry - OCDEPWET Faxa_ocphiwet - OCPHIDRY Faxa_ocphidry - OCPHODRY Faxa_ocphodry - DSTX01WD Faxa_dstwet1 - DSTX01DD Faxa_dstdry1 - DSTX02WD Faxa_dstwet2 - DSTX02DD Faxa_dstdry2 - DSTX03WD Faxa_dstwet3 - DSTX03DD Faxa_dstdry3 - DSTX04WD Faxa_dstwet4 - DSTX04DD Faxa_dstdry4 - - 0 - - - - - cycle - linear - single - bilinear - 1.5 - 2000 - 2000 - 1 - null - ./input/fv0.9x1.25_141008_polemod_ESMFmesh.nc - null - - ./input/fndep_clm_hist_b.e21.BWHIST.f09_g17.CMIP6-historical-WACCM.ensmean_1849-2015_monthly_0.9x1.25_c180926.nc - - - NDEP_NHx_month Faxa_ndep_nhx - NDEP_NOy_month Faxa_ndep_noy - - 0 - - - From 085a219405fce739573d21822d4b8e924034e5e2 Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 <108497463+ezhilsabareesh8@users.noreply.github.com> Date: Wed, 12 Jul 2023 15:57:03 +1000 Subject: [PATCH 09/12] moved to JRA55do1.4.0-RYF fork of the MOM6-CICE6 configuration --- CDEPS/extra_sources/drof.streams.xml | 46 ---------------------------- 1 file changed, 46 deletions(-) delete mode 100644 CDEPS/extra_sources/drof.streams.xml diff --git a/CDEPS/extra_sources/drof.streams.xml b/CDEPS/extra_sources/drof.streams.xml deleted file mode 100644 index bcaa14c..0000000 --- a/CDEPS/extra_sources/drof.streams.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - cycle - upper - single - bilinear - 3.0 - 1990 - 1990 - 1 - null - ./input/JRA.v1.4.runoff.1958_ESMFmesh_cdf5_20201020.nc - null - - /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.friver.1990_1991.nc - - - friver Forr_rofl - - 0 - - - - cycle - upper - single - bilinear - 3.0 - 1990 - 1990 - 1 - null - ./input/JRA.v1.4.runoff.1958_ESMFmesh_cdf5_20201020.nc - null - - /g/data/ik11/inputs/JRA-55/RYF/v1-4/RYF.licalvf.1990_1991.nc - - - licalvf Forr_rofi - - 0 - - - From b35ee2409161eab6f326126957670f7d89bc7b60 Mon Sep 17 00:00:00 2001 From: Andrew Kiss <31054815+aekiss@users.noreply.github.com> Date: Thu, 13 Jul 2023 11:15:04 +1000 Subject: [PATCH 10/12] minor tweaks to atm_comp_nuopc.F90 and datm_datamode_jra55do_mod.F90 --- CDEPS/extra_sources/atm_comp_nuopc.F90 | 10 +++++----- CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 | 12 +++++------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CDEPS/extra_sources/atm_comp_nuopc.F90 b/CDEPS/extra_sources/atm_comp_nuopc.F90 index 66a111f..b6a2a72 100644 --- a/CDEPS/extra_sources/atm_comp_nuopc.F90 +++ b/CDEPS/extra_sources/atm_comp_nuopc.F90 @@ -52,11 +52,11 @@ module cdeps_datm_comp use datm_datamode_jra_mod , only : datm_datamode_jra_restart_write use datm_datamode_jra_mod , only : datm_datamode_jra_restart_read - use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_advertise - use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_init_pointers - use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_advance - use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_restart_write - use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_restart_read + use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_advertise + use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_init_pointers + use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_advance + use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_restart_write + use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_restart_read use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_advertise use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_init_pointers diff --git a/CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 b/CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 index e49471f..2d6acad 100644 --- a/CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 +++ b/CDEPS/extra_sources/datm_datamode_jra55do_mod.F90 @@ -43,7 +43,6 @@ module datm_datamode_jra55do_mod real(r8), pointer :: Faxa_ndep(:,:) => null() ! stream data - real(r8), pointer :: strm_prec(:) => null() real(r8), pointer :: strm_prrn(:) => null() ! Rainfall flux real(r8), pointer :: strm_prsn(:) => null() ! Snowfall flux real(r8), pointer :: strm_swdn(:) => null() @@ -154,7 +153,7 @@ subroutine datm_datamode_jra55do_init_pointers(exportState, sdat, rc) integer :: numOwnedElements ! size of mesh real(r8), pointer :: ownedElemCoords(:) ! mesh lat and lons type(ESMF_StateItem_Flag) :: itemFlag - character(len=*), parameter :: subname='(datm_init_pointers): ' + character(len=*), parameter :: subname='(datm_datamode_jra55do_init_pointers): ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS @@ -219,8 +218,8 @@ subroutine datm_datamode_jra55do_init_pointers(exportState, sdat, rc) end if ! erro check - if (.not. associated(strm_prsn) .or. .not. associated(strm_swdn)) then - call shr_sys_abort(trim(subname)//'ERROR: prec and swdn must be in streams for CORE_IAF_JRA') + if (.not. associated(strm_prrn) .or. .not. associated(strm_prsn) .or. .not. associated(strm_swdn)) then + call shr_sys_abort(trim(subname)//'ERROR: prrn, prsn and swdn must be in streams for JRA55-do') endif end subroutine datm_datamode_jra55do_init_pointers @@ -241,7 +240,7 @@ subroutine datm_datamode_jra55do_advance(exportstate, target_ymd, target_tod, mo real(R8) :: avg_alb ! average albedo real(R8) :: rday ! elapsed day real(R8) :: cosFactor ! cosine factor - character(len=*), parameter :: subname='(datm_datamode_jra): ' + character(len=*), parameter :: subname='(datm_datamode_jra55do_advance): ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS @@ -257,13 +256,12 @@ subroutine datm_datamode_jra55do_advance(exportstate, target_ymd, target_tod, mo Sa_pbot(n) = Sa_pslv(n) Sa_ptem(n) = Sa_tbot(n) - ! density computation for JRA55 forcing + ! density computation for JRA55-do forcing Sa_dens(n) = Sa_pbot(n)/(rdair*Sa_tbot(n)*(1 + 0.608*Sa_shum(n))) ! precipitation data Faxa_rainc(n) = 0.0_R8 ! default zero Faxa_snowc(n) = 0.0_R8 - Faxa_snowl(n) = strm_prsn(n) ! Snowfall flux Faxa_rainl(n) = strm_prrn(n) ! Rainfall flux From 9a491626aaa0b4c7db8cef4527d060b1763186ed Mon Sep 17 00:00:00 2001 From: ezhilsabareesh8 Date: Thu, 13 Jul 2023 15:18:27 +1000 Subject: [PATCH 11/12] JRA55do datamode added to atm_comp_nuopc.F9 --- CDEPS/extra_sources/atm_comp_nuopc.F90 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CDEPS/extra_sources/atm_comp_nuopc.F90 b/CDEPS/extra_sources/atm_comp_nuopc.F90 index b6a2a72..cbf38bd 100644 --- a/CDEPS/extra_sources/atm_comp_nuopc.F90 +++ b/CDEPS/extra_sources/atm_comp_nuopc.F90 @@ -348,6 +348,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if ( trim(datamode) == 'CORE2_NYF' .or. & trim(datamode) == 'CORE2_IAF' .or. & trim(datamode) == 'CORE_IAF_JRA' .or. & + trim(datamode) == 'CORE_IAF_JRA55do'.or. & trim(datamode) == 'CLMNCEP' .or. & trim(datamode) == 'CPLHIST' .or. & trim(datamode) == 'GEFS' .or. & @@ -367,6 +368,10 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call datm_datamode_jra_advertise(exportState, fldsExport, flds_scalar_name, & flds_co2, flds_wiso, flds_presaero, flds_presndep, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + case ('CORE_IAF_JRA55do') + call datm_datamode_jra55do_advertise(exportState, fldsExport, flds_scalar_name, & + flds_co2, flds_wiso, flds_presaero, flds_presndep, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return case ('CLMNCEP') call datm_datamode_clmncep_advertise(exportState, fldsExport, flds_scalar_name, & flds_co2, flds_wiso, flds_presaero, flds_presndep, flds_preso3, rc) @@ -612,6 +617,9 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe case('CORE_IAF_JRA') call datm_datamode_jra_init_pointers(exportState, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('CORE_IAF_JRA55do') + call datm_datamode_jra55do_init_pointers(exportState, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return case('CLMNCEP') call datm_datamode_clmncep_init_pointers(importState, exportState, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -636,6 +644,8 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe call datm_datamode_core2_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) case('CORE_IAF_JRA') call datm_datamode_jra_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + case('CORE_IAF_JRA55do') + call datm_datamode_jra55do_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) case('CLMNCEP') call datm_datamode_clmncep_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) case('CPLHIST') @@ -683,6 +693,9 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe case('CORE_IAF_JRA') call datm_datamode_jra_advance(exportstate, target_ymd, target_tod, sdat%model_calendar, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('CORE_IAF_JRA55do') + call datm_datamode_jra55do_advance(exportstate, target_ymd, target_tod, sdat%model_calendar, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return case('CLMNCEP') call datm_datamode_clmncep_advance(mainproc, logunit, mpicom, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -711,6 +724,9 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe case('CORE_IAF_JRA') call datm_datamode_jra_restart_write(case_name, inst_suffix, target_ymd, target_tod, & logunit, my_task, sdat) + case('CORE_IAF_JRA55do') + call datm_datamode_jra55do_restart_write(case_name, inst_suffix, target_ymd, target_tod, & + logunit, my_task, sdat) case('CLMNCEP') call datm_datamode_clmncep_restart_write(case_name, inst_suffix, target_ymd, target_tod, & logunit, my_task, sdat) From b242b795553d673ebc638770821c613c0fab90a0 Mon Sep 17 00:00:00 2001 From: Micael Oliveira Date: Thu, 31 Aug 2023 14:38:41 +1000 Subject: [PATCH 12/12] Changes to the CDEPS/datm/atm_comp_nuopc.F90 are now handled with a patch, instead of storing a full copy of the modified file. --- CDEPS/CMakeLists.txt | 3 +- CDEPS/extra_sources/atm_comp_nuopc.F90 | 927 ------------------------- CDEPS/patches/atm_comp_nuopc.F90.patch | 73 ++ 3 files changed, 75 insertions(+), 928 deletions(-) delete mode 100644 CDEPS/extra_sources/atm_comp_nuopc.F90 create mode 100644 CDEPS/patches/atm_comp_nuopc.F90.patch diff --git a/CDEPS/CMakeLists.txt b/CDEPS/CMakeLists.txt index b18953c..635080b 100644 --- a/CDEPS/CMakeLists.txt +++ b/CDEPS/CMakeLists.txt @@ -16,7 +16,6 @@ list(APPEND cdeps_drof_src_files ) list(APPEND cdeps_datm_src_files - extra_sources/atm_comp_nuopc.F90 CDEPS/datm/datm_datamode_cfsr_mod.F90 CDEPS/datm/datm_datamode_clmncep_mod.F90 CDEPS/datm/datm_datamode_core2_mod.F90 @@ -57,3 +56,5 @@ foreach(LIB cdeps_docn cdeps_dice cdeps_dwav cdeps_drof cdeps_datm) target_include_directories(${LIB} PUBLIC $) target_link_libraries(${LIB} PUBLIC share cmeps esmf PIO::PIO_Fortran FoX_dom cdeps_common) endforeach() + +add_patched_source(cdeps_datm CDEPS/datm/atm_comp_nuopc.F90) diff --git a/CDEPS/extra_sources/atm_comp_nuopc.F90 b/CDEPS/extra_sources/atm_comp_nuopc.F90 deleted file mode 100644 index cbf38bd..0000000 --- a/CDEPS/extra_sources/atm_comp_nuopc.F90 +++ /dev/null @@ -1,927 +0,0 @@ -#ifdef CESMCOUPLED -module atm_comp_nuopc -#else -module cdeps_datm_comp -#endif - - !---------------------------------------------------------------------------- - ! This is the NUOPC cap for DATM - !---------------------------------------------------------------------------- - - use ESMF , only : ESMF_VM, ESMF_VMBroadcast - use ESMF , only : ESMF_Mesh, ESMF_GridComp, ESMF_SUCCESS, ESMF_LogWrite - use ESMF , only : ESMF_GridCompSetEntryPoint, ESMF_METHOD_INITIALIZE - use ESMF , only : ESMF_MethodRemove, ESMF_State, ESMF_Clock, ESMF_TimeInterval - use ESMF , only : ESMF_State, ESMF_Field, ESMF_LOGMSG_INFO, ESMF_ClockGet - use ESMF , only : ESMF_Time, ESMF_Alarm, ESMF_TimeGet, ESMF_TimeInterval - use ESMF , only : operator(+), ESMF_TimeIntervalGet, ESMF_ClockGetAlarm - use ESMF , only : ESMF_AlarmIsRinging, ESMF_AlarmRingerOff, ESMF_StateGet - use ESMF , only : ESMF_FieldGet, ESMF_MAXSTR, ESMF_VMBroadcast - use ESMF , only : ESMF_TraceRegionEnter, ESMF_TraceRegionExit, ESMF_GridCompGet - use NUOPC , only : NUOPC_CompDerive, NUOPC_CompSetEntryPoint, NUOPC_CompSpecialize - use NUOPC , only : NUOPC_CompAttributeGet, NUOPC_Advertise - use NUOPC_Model , only : model_routine_SS => SetServices - use NUOPC_Model , only : model_label_Advance => label_Advance - use NUOPC_Model , only : model_label_SetRunClock => label_SetRunClock - 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_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 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 - use dshr_mod , only : dshr_model_initphase, dshr_init - use dshr_mod , only : dshr_state_setscalar, dshr_set_runclock, dshr_log_clock_advance - use dshr_mod , only : dshr_mesh_init, dshr_check_restart_alarm - use dshr_mod , only : dshr_orbital_init, dshr_orbital_update - use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy - use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add, dshr_fldlist_realize - - use datm_datamode_core2_mod , only : datm_datamode_core2_advertise - use datm_datamode_core2_mod , only : datm_datamode_core2_init_pointers - use datm_datamode_core2_mod , only : datm_datamode_core2_advance - use datm_datamode_core2_mod , only : datm_datamode_core2_restart_write - use datm_datamode_core2_mod , only : datm_datamode_core2_restart_read - - use datm_datamode_jra_mod , only : datm_datamode_jra_advertise - use datm_datamode_jra_mod , only : datm_datamode_jra_init_pointers - use datm_datamode_jra_mod , only : datm_datamode_jra_advance - use datm_datamode_jra_mod , only : datm_datamode_jra_restart_write - use datm_datamode_jra_mod , only : datm_datamode_jra_restart_read - - use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_advertise - use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_init_pointers - use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_advance - use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_restart_write - use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_restart_read - - use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_advertise - use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_init_pointers - use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_advance - use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_restart_write - use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_restart_read - - use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_advertise - use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_init_pointers - use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_advance - use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_restart_write - use datm_datamode_cplhist_mod , only : datm_datamode_cplhist_restart_read - - use datm_datamode_era5_mod , only : datm_datamode_era5_advertise - use datm_datamode_era5_mod , only : datm_datamode_era5_init_pointers - use datm_datamode_era5_mod , only : datm_datamode_era5_advance - use datm_datamode_era5_mod , only : datm_datamode_era5_restart_write - use datm_datamode_era5_mod , only : datm_datamode_era5_restart_read - - use datm_datamode_gefs_mod , only : datm_datamode_gefs_advertise - use datm_datamode_gefs_mod , only : datm_datamode_gefs_init_pointers - use datm_datamode_gefs_mod , only : datm_datamode_gefs_advance - 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 - - implicit none - private ! except - - public :: SetServices - public :: SetVM - private :: InitializeAdvertise - private :: InitializeRealize - private :: ModelAdvance - private :: datm_comp_run - private :: ModelFinalize - - !-------------------------------------------------------------------------- - ! Private module data - !-------------------------------------------------------------------------- - - type(shr_strdata_type) :: sdat - type(ESMF_Mesh) :: model_mesh ! model mesh - character(len=128) :: flds_scalar_name = '' - integer :: flds_scalar_num = 0 - integer :: flds_scalar_index_nx = 0 - integer :: flds_scalar_index_ny = 0 - integer :: flds_scalar_index_nextsw_cday = 0 - integer :: mpicom ! mpi communicator - integer :: my_task ! my task in mpi communicator mpicom - logical :: mainproc ! true of my_task == main_task - integer :: inst_index ! number of current instance (ie. 1) - character(len=16) :: inst_suffix = "" ! char string associated with instance (ie. "_0001" or "") - integer :: logunit ! logging unit number - logical :: restart_read ! start from restart - character(CL) :: case_name ! case name - character(len=*) , parameter :: nullstr = 'null' - - ! datm_in namelist input - character(CL) :: nlfilename = nullstr ! filename to obtain namelist info from - character(CL) :: streamfilename = nullstr ! filename to obtain stream info from - character(CL) :: dataMode = nullstr ! flags physics options wrt input data - character(CL) :: model_meshfile = nullstr ! full pathname to model meshfile - character(CL) :: model_maskfile = nullstr ! full pathname to obtain mask from - integer :: iradsw = 0 ! radiation interval (input namelist) - character(CL) :: factorFn_mesh = 'null' ! file containing correction factors mesh - character(CL) :: factorFn_data = 'null' ! file containing correction factors data - logical :: flds_presaero = .false. ! true => send valid prescribed aero fields to mediator - logical :: flds_presndep = .false. ! true => send valid prescribed ndep fields to mediator - logical :: flds_preso3 = .false. ! true => send valid prescribed ozone fields to mediator - logical :: flds_co2 = .false. ! true => send prescribed co2 to mediator - logical :: flds_wiso = .false. ! true => send water isotopes to mediator - - character(CL) :: bias_correct = nullstr ! send bias correction fields to coupler - character(CL) :: anomaly_forcing(8) = nullstr ! send anomaly forcing fields to coupler - - character(CL) :: restfilm = nullstr ! model restart file namelist - integer :: nx_global ! global nx - integer :: ny_global ! global ny - logical :: skip_restart_read = .false. ! true => skip restart read in continuation run - - ! linked lists - type(fldList_type) , pointer :: fldsImport => null() - type(fldList_type) , pointer :: fldsExport => null() - type(dfield_type) , pointer :: dfields => null() - - ! model mask and model fraction - real(r8), pointer :: model_frac(:) => null() - integer , pointer :: model_mask(:) => null() - - ! constants - integer :: idt ! integer model timestep - logical :: diagnose_data = .true. - integer , parameter :: main_task = 0 ! task number of main task - character(len=*) , parameter :: rpfile = 'rpointer.atm' -#ifdef CESMCOUPLED - character(*) , parameter :: modName = "(atm_comp_nuopc)" -#else - character(*) , parameter :: modName = "(cdeps_datm_comp)" -#endif - - character(*), parameter :: u_FILE_u = & - __FILE__ - -!=============================================================================== -contains -!=============================================================================== - - subroutine SetServices(gcomp, rc) - type(ESMF_GridComp) :: gcomp - integer, intent(out) :: rc - - ! local variables - character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' - !------------------------------------------------------------------------------- - - rc = ESMF_SUCCESS - call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO) - - ! the NUOPC gcomp component will register the generic methods - call NUOPC_CompDerive(gcomp, model_routine_SS, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! switching to IPD versions - call ESMF_GridCompSetEntryPoint(gcomp, ESMF_METHOD_INITIALIZE, & - userRoutine=dshr_model_initphase, phase=0, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! set entry point for methods that require specific implementation - call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_INITIALIZE, & - phaseLabelList=(/"IPDv01p1"/), userRoutine=InitializeAdvertise, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_INITIALIZE, & - phaseLabelList=(/"IPDv01p3"/), userRoutine=InitializeRealize, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! attach specializing method(s) - call NUOPC_CompSpecialize(gcomp, specLabel=model_label_Advance, specRoutine=ModelAdvance, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - call ESMF_MethodRemove(gcomp, label=model_label_SetRunClock, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call NUOPC_CompSpecialize(gcomp, specLabel=model_label_SetRunClock, specRoutine=dshr_set_runclock, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - call NUOPC_CompSpecialize(gcomp, specLabel=model_label_Finalize, specRoutine=ModelFinalize, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO) - - end subroutine SetServices - - !=============================================================================== - - subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) - - ! input/output variables - type(ESMF_GridComp) :: gcomp - type(ESMF_State) :: importState, exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - ! local variables - integer :: nu ! unit number - integer :: ierr ! error code - integer :: bcasttmp(9) - type(ESMF_VM) :: vm - character(len=*),parameter :: subname=trim(modName) // ':(InitializeAdvertise) ' - character(*) ,parameter :: F00 = "('(" // trim(modName) // ") ',8a)" - character(*) ,parameter :: F01 = "('(" // trim(modName) // ") ',a,2x,i8)" - character(*) ,parameter :: F02 = "('(" // trim(modName) // ") ',a,l6)" - !------------------------------------------------------------------------------- - - namelist / datm_nml / & - datamode, & - model_meshfile, & - model_maskfile, & - nx_global, & - ny_global, & - restfilm, & - iradsw, & - factorFn_data, & - factorFn_mesh, & - flds_presaero, & - flds_co2, & - flds_wiso, & - bias_correct, & - anomaly_forcing, & - skip_restart_read, & - flds_presndep, & - flds_preso3 - - rc = ESMF_SUCCESS - - call NUOPC_CompAttributeGet(gcomp, name='case_name', value=case_name, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! Obtain flds_scalar values, mpi values, multi-instance values and - ! set logunit and set shr logging to my log file - call dshr_init(gcomp, 'ATM', sdat, mpicom, my_task, inst_index, inst_suffix, & - flds_scalar_name, flds_scalar_num, flds_scalar_index_nx, flds_scalar_index_ny, & - logunit, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! Determine logical mainproc - mainproc = (my_task == main_task) - - ! Read atm_nml from nlfilename - if (my_task == main_task) then - nlfilename = "datm_in"//trim(inst_suffix) - open (newunit=nu,file=trim(nlfilename),status="old",action="read") - 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)) - end if - bcasttmp = 0 - bcasttmp(1) = nx_global - bcasttmp(2) = ny_global - bcasttmp(3) = iradsw - if(flds_presaero) bcasttmp(4) = 1 - if(flds_presndep) bcasttmp(5) = 1 - if(flds_preso3) bcasttmp(6) = 1 - if(flds_co2) bcasttmp(7) = 1 - if(flds_wiso) bcasttmp(8) = 1 - if(skip_restart_read) bcasttmp(9) = 1 - - end if - call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - call ESMF_VMBroadcast(vm, datamode, CL, main_task, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMBroadcast(vm, bias_correct, CL, main_task, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMBroadcast(vm, anomaly_forcing, CL*8, main_task, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMBroadcast(vm, model_meshfile, CL, main_task, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMBroadcast(vm, model_maskfile, CL, main_task, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMBroadcast(vm, factorFn_data, CL, main_task, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMBroadcast(vm, factorFn_mesh, CL, main_task, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMBroadcast(vm, restfilm, CL, main_task, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMBroadcast(vm, bcasttmp, 9, main_task, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - nx_global = bcasttmp(1) - ny_global = bcasttmp(2) - iradsw = bcasttmp(3) - flds_presaero = (bcasttmp(4) == 1) - flds_presndep = (bcasttmp(5) == 1) - flds_preso3 = (bcasttmp(6) == 1) - flds_co2 = (bcasttmp(7) == 1) - flds_wiso = (bcasttmp(8) == 1) - skip_restart_read = (bcasttmp(9) == 1) - - ! write namelist input to standard out - if (my_task == main_task) then - write(logunit,F00)' case_name = ',trim(case_name) - write(logunit,F00)' datamode = ',trim(datamode) - write(logunit,F00)' model_meshfile = ',trim(model_meshfile) - write(logunit,F00)' model_maskfile = ',trim(model_maskfile) - write(logunit,F01)' nx_global = ',nx_global - write(logunit,F01)' ny_global = ',ny_global - write(logunit,F00)' restfilm = ',trim(restfilm) - write(logunit,F01)' iradsw = ',iradsw - write(logunit,F00)' factorFn_data = ',trim(factorFn_data) - write(logunit,F00)' factorFn_mesh = ',trim(factorFn_mesh) - write(logunit,F02)' flds_presaero = ',flds_presaero - write(logunit,F02)' flds_presndep = ',flds_presndep - write(logunit,F02)' flds_preso3 = ',flds_preso3 - write(logunit,F02)' flds_co2 = ',flds_co2 - write(logunit,F02)' flds_wiso = ',flds_wiso - write(logunit,F02)' skip_restart_read = ',skip_restart_read - end if - - ! Validate sdat datamode - if (mainproc) write(logunit,*) ' datm datamode = ',trim(datamode) - if ( trim(datamode) == 'CORE2_NYF' .or. & - trim(datamode) == 'CORE2_IAF' .or. & - trim(datamode) == 'CORE_IAF_JRA' .or. & - trim(datamode) == 'CORE_IAF_JRA55do'.or. & - trim(datamode) == 'CLMNCEP' .or. & - trim(datamode) == 'CPLHIST' .or. & - trim(datamode) == 'GEFS' .or. & - trim(datamode) == 'CFSR' .or. & - trim(datamode) == 'ERA5') then - else - call shr_sys_abort(' ERROR illegal datm datamode = '//trim(datamode)) - endif - - ! Advertise datm fields - select case (trim(datamode)) - case ('CORE2_NYF', 'CORE2_IAF') - call datm_datamode_core2_advertise(exportState, fldsExport, flds_scalar_name, & - flds_co2, flds_wiso, flds_presaero, flds_presndep, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case ('CORE_IAF_JRA') - call datm_datamode_jra_advertise(exportState, fldsExport, flds_scalar_name, & - flds_co2, flds_wiso, flds_presaero, flds_presndep, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case ('CORE_IAF_JRA55do') - call datm_datamode_jra55do_advertise(exportState, fldsExport, flds_scalar_name, & - flds_co2, flds_wiso, flds_presaero, flds_presndep, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case ('CLMNCEP') - call datm_datamode_clmncep_advertise(exportState, fldsExport, flds_scalar_name, & - flds_co2, flds_wiso, flds_presaero, flds_presndep, flds_preso3, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case ('CPLHIST') - call datm_datamode_cplhist_advertise(exportState, fldsExport, flds_scalar_name, & - flds_co2, flds_wiso, flds_presaero, flds_presndep, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case ('ERA5') - call datm_datamode_era5_advertise(exportState, fldsExport, flds_scalar_name, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - 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 - end select - - end subroutine InitializeAdvertise - - !=============================================================================== - - subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) - - ! input/output variables - type(ESMF_GridComp) :: gcomp - type(ESMF_State) :: importState, exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - ! local variables - type(ESMF_TimeInterval) :: timeStep - type(ESMF_TIME) :: currTime - integer :: current_ymd ! model date - integer :: current_year ! model year - integer :: current_mon ! model month - integer :: current_day ! model day - integer :: current_tod ! model sec into model date - integer(i8) :: stepno ! step number - real(r8) :: nextsw_cday ! calendar of next atm sw - character(CL) :: cvalue ! character string for input config - real(R8) :: orbEccen ! orb eccentricity (unist-less) - real(R8) :: orbMvelpp ! orb moving vernal eqa (radians) - real(R8) :: orbLambm0 ! orb mean long of perhelion (radians) - real(R8) :: orbObliqr ! orb obliquity (radians) - logical :: isPresent, isSet - real(R8) :: dayofYear - character(len=*), parameter :: subname=trim(modName)//':(InitializeRealize) ' - !------------------------------------------------------------------------------- - - rc = ESMF_SUCCESS - call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO) - - ! Initialize mesh, restart flag, compid, and logunit - call ESMF_TraceRegionEnter('datm_strdata_init') - call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'ATM', nx_global, ny_global, & - model_meshfile, model_maskfile, model_mesh, model_mask, model_frac, restart_read, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! Initialize stream data type - streamfilename = 'datm.streams'//trim(inst_suffix) -#ifndef DISABLE_FoX - streamfilename = trim(streamfilename)//'.xml' -#endif - call shr_strdata_init_from_config(sdat, streamfilename, model_mesh, clock, 'ATM', logunit, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_TraceRegionExit('datm_strdata_init') - - ! NUOPC_Realize "realizes" a previously advertised field in the importState and exportState - ! by replacing the advertised fields with the newly created fields of the same name. - call dshr_fldlist_realize( exportState, fldsExport, flds_scalar_name, flds_scalar_num, model_mesh, & - subname//':datmExport', rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_fldlist_realize( importState, fldsImport, flds_scalar_name, flds_scalar_num, model_mesh, & - subname//':datmImport', rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! Get the time to interpolate the stream data to - call ESMF_ClockGet( clock, currTime=currTime, timeStep=timeStep, advanceCount=stepno, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeGet(currTime, yy=current_year, mm=current_mon, dd=current_day, s=current_tod, & - dayofYear_r8=dayofYear, rc=rc ) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call shr_cal_ymd2date(current_year, current_mon, current_day, current_ymd) - - ! Get model timestep (idt is module variable) - call ESMF_TimeIntervalGet( timeStep, s=idt, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! Initialize and update orbital values - call dshr_orbital_init(gcomp, logunit, my_task == main_task, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_orbital_update(currTime, logunit, my_task == main_task, & - orbEccen, orbObliqr, orbLambm0, orbMvelpp, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! Run datm - call datm_comp_run(importstate, exportstate, current_ymd, current_tod, current_mon, & - orbEccen, orbMvelpp, orbLambm0, orbObliqr, restart_write=.false., rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! Add scalars to export state - call dshr_state_SetScalar(dble(nx_global),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dshr_state_SetScalar(dble(ny_global),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxNextSwCday", value=cvalue, & - isPresent=isPresent, isSet=isSet, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - if (isPresent .and. isSet) then - read (cvalue,*) flds_scalar_index_nextsw_cday - else - call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxNextSwCday') - endif - - nextsw_cday = getNextRadCDay(dayofYear, current_tod, stepno, idt, iradsw) - call dshr_state_SetScalar(nextsw_cday, flds_scalar_index_nextsw_cday, exportState, flds_scalar_name, flds_scalar_num, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - end subroutine InitializeRealize - - !=============================================================================== - subroutine ModelAdvance(gcomp, rc) - - ! input/output variables - type(ESMF_GridComp) :: gcomp - integer, intent(out) :: rc - - ! local variables - type(ESMF_State) :: importState, exportState - type(ESMF_Clock) :: clock - type(ESMF_Time) :: currTime - type(ESMF_Time) :: nextTime - type(ESMF_TimeInterval) :: timeStep - real(r8) :: nextsw_cday - logical :: restart_write ! restart alarm is ringing - integer :: next_ymd ! model date - integer :: next_tod ! model sec into model date - integer :: yr, mon, day ! year, month, day - integer(i8) :: stepno ! step number - real(R8) :: orbEccen ! orb eccentricity (unit-less) - real(R8) :: orbMvelpp ! orb moving vernal eq (radians) - real(R8) :: orbLambm0 ! orb mean long of perhelion (radians) - real(R8) :: orbObliqr ! orb obliquity (radians) - real(R8) :: dayofYear - character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' - !------------------------------------------------------------------------------- - - rc = ESMF_SUCCESS - - call ESMF_TraceRegionEnter(subname) - call shr_log_setLogUnit(logunit) - call memcheck(subname, 5, my_task==main_task) - - ! Query the Component for its clock, importState and exportState - call NUOPC_ModelGet(gcomp, modelClock=clock, importState=importState, exportState=exportState, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! For nuopc - the component clock is advanced at the end of the time interval - ! For these to match for now - need to advance nuopc one timestep ahead for - ! shr_strdata time interpolation - call ESMF_ClockGet( clock, currTime=currTime, timeStep=timeStep, advanceCount=stepno, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - nextTime = currTime + timeStep - call ESMF_TimeGet( nextTime, yy=yr, mm=mon, dd=day, s=next_tod, dayofYear_r8=dayofYear, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call shr_cal_ymd2date(yr, mon, day, next_ymd) - - ! Update the orbital values - call dshr_orbital_update(nextTime, logunit, my_task == main_task, & - orbEccen, orbObliqr, orbLambm0, orbMvelpp, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - restart_write = dshr_check_restart_alarm(clock, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! Run datm - call ESMF_TraceRegionEnter('datm_run') - call datm_comp_run(importstate, exportstate, next_ymd, next_tod, mon, & - orbEccen, orbMvelpp, orbLambm0, orbObliqr, restart_write, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_TraceRegionExit('datm_run') - - ! Update nextsw_cday for scalar data - ! Use nextYMD and nextTOD here since since the component - clock is advance at the END of the time interval - - nextsw_cday = getNextRadCDay(dayofYear, next_tod, stepno, idt, iradsw) - - call dshr_state_SetScalar(nextsw_cday, flds_scalar_index_nextsw_cday, exportState, flds_scalar_name, flds_scalar_num, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - call ESMF_TraceRegionExit(subname) - - end subroutine ModelAdvance - - !=============================================================================== - subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, target_mon, & - orbEccen, orbMvelpp, orbLambm0, orbObliqr, restart_write, rc) - - ! ---------------------------------- - ! run method for datm model - ! ---------------------------------- - - ! input/output variables - type(ESMF_State) , intent(inout) :: importState - type(ESMF_State) , intent(inout) :: exportState - integer , intent(in) :: target_ymd ! model date - integer , intent(in) :: target_tod ! model sec into model date - integer , intent(in) :: target_mon ! model month - real(R8) , intent(in) :: orbEccen ! orb eccentricity (unit-less) - real(R8) , intent(in) :: orbMvelpp ! orb moving vernal eq (radians) - real(R8) , intent(in) :: orbLambm0 ! orb mean long of perhelion (radians) - real(R8) , intent(in) :: orbObliqr ! orb obliquity (radians) - logical , intent(in) :: restart_write - integer , intent(out) :: rc - - ! local variables - logical :: first_time = .true. - character(*), parameter :: subName = '(datm_comp_run) ' - !------------------------------------------------------------------------------- - - rc = ESMF_SUCCESS - - call ESMF_TraceRegionEnter('DATM_RUN') - - !-------------------- - ! First time initialization - !-------------------- - - if (first_time) then - - ! Initialize dfields - call datm_init_dfields(rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - ! Initialize datamode module ponters - select case (trim(datamode)) - case('CORE2_NYF','CORE2_IAF') - call datm_datamode_core2_init_pointers(exportState, sdat, datamode, factorfn_mesh, factorfn_data, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('CORE_IAF_JRA') - call datm_datamode_jra_init_pointers(exportState, sdat, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('CORE_IAF_JRA55do') - call datm_datamode_jra55do_init_pointers(exportState, sdat, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('CLMNCEP') - call datm_datamode_clmncep_init_pointers(importState, exportState, sdat, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('CPLHIST') - call datm_datamode_cplhist_init_pointers(importState, exportState, sdat, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('ERA5') - call datm_datamode_era5_init_pointers(exportState, sdat, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - 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 - end select - - ! Read restart if needed - if (restart_read .and. .not. skip_restart_read) then - select case (trim(datamode)) - case('CORE2_NYF','CORE2_IAF') - call datm_datamode_core2_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) - case('CORE_IAF_JRA') - call datm_datamode_jra_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) - case('CORE_IAF_JRA55do') - call datm_datamode_jra55do_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) - case('CLMNCEP') - call datm_datamode_clmncep_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) - case('CPLHIST') - call datm_datamode_cplhist_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) - case('ERA5') - 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) - end select - end if - - ! reset first_time - first_time = .false. - end if - - !-------------------- - ! Advance datm streams - !-------------------- - - ! set data needed for cosz t-interp method - call shr_strdata_setOrbs(sdat, orbEccen, orbMvelpp, orbLambm0, orbObliqr, idt) - - ! time and spatially interpolate to model time and grid - call ESMF_TraceRegionEnter('datm_strdata_advance') - call shr_strdata_advance(sdat, target_ymd, target_tod, logunit, 'datm', rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_TraceRegionExit('datm_strdata_advance') - - ! copy all fields from streams to export state as default - ! This automatically will update the fields in the export state - call ESMF_TraceRegionEnter('datm_dfield_copy') - call dshr_dfield_copy(dfields, sdat, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_TraceRegionExit('datm_dfield_copy') - - ! Determine data model behavior based on the mode - call ESMF_TraceRegionEnter('datm_datamode') - select case (trim(datamode)) - case('CORE2_NYF','CORE2_IAF') - call datm_datamode_core2_advance(datamode, target_ymd, target_tod, target_mon, & - sdat%model_calendar, factorfn_mesh, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('CORE_IAF_JRA') - call datm_datamode_jra_advance(exportstate, target_ymd, target_tod, sdat%model_calendar, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('CORE_IAF_JRA55do') - call datm_datamode_jra55do_advance(exportstate, target_ymd, target_tod, sdat%model_calendar, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('CLMNCEP') - call datm_datamode_clmncep_advance(mainproc, logunit, mpicom, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('CPLHIST') - call datm_datamode_cplhist_advance(mainproc, logunit, mpicom, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('ERA5') - call datm_datamode_era5_advance(exportstate, mainproc, logunit, mpicom, target_ymd, & - target_tod, sdat%model_calendar, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - 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 - end select - - ! Write restarts if needed - if (restart_write) then - select case (trim(datamode)) - case('CORE2_NYF','CORE2_IAF') - call datm_datamode_core2_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - case('CORE_IAF_JRA') - call datm_datamode_jra_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - case('CORE_IAF_JRA55do') - call datm_datamode_jra55do_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - case('CLMNCEP') - call datm_datamode_clmncep_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - case('CPLHIST') - call datm_datamode_cplhist_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - case('ERA5') - call datm_datamode_era5_restart_write(case_name, inst_suffix, target_ymd, target_tod, & - logunit, my_task, sdat) - case('GEFS') - 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 - end select - end if - - ! Log output for model date - if (mainproc) write(logunit,*) 'atm : model date ', target_ymd, target_tod - - ! Diagnostics - if (diagnose_data) then - call dshr_state_diagnose(exportState, flds_scalar_name, subname//':ES', rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - end if - - call ESMF_TraceRegionExit('datm_datamode') - call ESMF_TraceRegionExit('DATM_RUN') - - !-------- - contains - !-------- - - subroutine datm_init_dfields(rc) - ! ----------------------------- - ! Initialize dfields arrays - ! (for export fields that have a corresponding stream field) - ! ----------------------------- - - ! input/output parameters - integer, intent(out) :: rc - - ! local variables - integer :: n - character(CS) :: strm_flds2(2) - character(CS) :: strm_flds3(3) - character(CS) :: strm_flds4(4) - integer :: rank - integer :: fieldcount - type(ESMF_Field) :: lfield - character(ESMF_MAXSTR) ,pointer :: lfieldnames(:) - character(*), parameter :: subName = "(datm_init_dfields) " - !------------------------------------------------------------------------------- - - rc = ESMF_SUCCESS - - call ESMF_StateGet(exportState, itemCount=fieldCount, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - allocate(lfieldnames(fieldCount)) - call ESMF_StateGet(exportState, itemNameList=lfieldnames, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - do n = 1, fieldCount - call ESMF_StateGet(exportState, itemName=trim(lfieldnames(n)), field=lfield, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_FieldGet(lfield, rank=rank, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (rank == 1) then - call dshr_dfield_add( dfields, sdat, trim(lfieldnames(n)), trim(lfieldnames(n)), & - exportState, logunit, mainproc, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - else if (rank == 2) then - ! The following maps stream input fields to export fields that have an ungridded dimension - ! TODO: in the future it might be better to change the format of the streams file to have two more entries - ! that could denote how the stream variables are mapped to export fields that have an ungridded dimension - - select case (trim(lfieldnames(n))) - case('Faxa_bcph') - strm_flds3 = (/'Faxa_bcphidry', 'Faxa_bcphodry', 'Faxa_bcphiwet'/) - call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds3, exportState, logunit, mainproc, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('Faxa_ocph') - strm_flds3 = (/'Faxa_ocphidry', 'Faxa_ocphodry', 'Faxa_ocphiwet'/) - call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds3, exportState, logunit, mainproc, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('Faxa_dstwet') - strm_flds4 = (/'Faxa_dstwet1', 'Faxa_dstwet2', 'Faxa_dstwet3', 'Faxa_dstwet4'/) - call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds4, exportState, logunit, mainproc, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('Faxa_dstdry') - strm_flds4 = (/'Faxa_dstdry1', 'Faxa_dstdry2', 'Faxa_dstdry3', 'Faxa_dstdry4'/) - call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds4, exportState, logunit, mainproc, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('Faxa_rainc_wiso') - strm_flds3 = (/'Faxa_rainc_16O', 'Faxa_rainc_18O', 'Faxa_rainc_HDO'/) - call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds3, exportState, logunit, mainproc, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('Faxa_rainl_wiso') - strm_flds3 = (/'Faxa_rainl_16O', 'Faxa_rainl_18O', 'Faxa_rainl_HDO'/) - call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds3, exportState, logunit, mainproc, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('Faxa_snowc_wiso') - strm_flds3 = (/'Faxa_snowc_16O', 'Faxa_snowc_18O', 'Faxa_snowc_HDO'/) - call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds3, exportState, logunit, mainproc, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('Faxa_snowl_wiso') - strm_flds3 = (/'Faxa_snowl_16O', 'Faxa_snowl_18O', 'Faxa_snowl_HDO'/) - call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds3, exportState, logunit, mainproc, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('Faxa_ndep') - strm_flds2 = (/'Faxa_ndep_nhx', 'Faxa_ndep_noy'/) - call dshr_dfield_add(dfields, sdat, trim(lfieldnames(n)), strm_flds2, exportState, logunit, mainproc, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - case('cpl_scalars') - continue - case default - call shr_sys_abort(subName//'field '//trim(lfieldnames(n))//' not recognized') - end select - end if - end do - end subroutine datm_init_dfields - - end subroutine datm_comp_run - - !=============================================================================== - real(R8) function getNextRadCDay( julday, tod, stepno, dtime, iradsw ) - - ! Return the calendar day of the next radiation time-step. - ! General Usage: nextswday = getNextRadCDay(curr_date) iradsw is - ! the frequency to update the next shortwave. in number of steps - ! (or hours if negative) Julian date. - ! -- values greater than 1 set - ! the next radiation to the present time plus 2 timesteps every iradsw - ! -- values less than 0 turn set the next radiation to the present time - ! plus two timesteps every -iradsw hours. - ! -- if iradsw is zero, the next radiation time is the - ! present time plus 1 timestep. - - ! input/output variables - real(r8) , intent(in) :: julday - integer , intent(in) :: tod - integer(i8) , intent(in) :: stepno - integer , intent(in) :: dtime - integer , intent(in) :: iradsw - - ! local variables - real(R8) :: nextsw_cday - integer :: liradsw - integer :: delta_radsw - character(*),parameter :: subName = '(getNextRadCDay) ' - !------------------------------------------------------------------------------- - - ! Note that stepno is obtained via the advancecount argument to - ! ESMF_GetClock and is the number of times the ESMF_Clock has been - ! advanced. The ESMF clock is actually advanced an additional time - ! (in order to trigger alarms) in the routine dshr_set_runclock - ! which is the specialized routine for the model_lable_SetRunClock. - ! This is called each time the ModelAdvance phase is called. Hence - ! stepno is not used to trigger the calculation of nextsw_cday. - - liradsw = iradsw - if (liradsw < 0) liradsw = nint((-liradsw *3600._r8)/dtime) - - if (liradsw > 1) then - delta_radsw = liradsw * dtime - if (mod(tod+dtime,delta_radsw) == 0 .and. stepno > 0) then - nextsw_cday = julday + 2*dtime/shr_const_cday - else - nextsw_cday = -1._r8 - end if - else - nextsw_cday = julday + dtime/shr_const_cday - end if - getNextRadCDay = nextsw_cday - - end function getNextRadCDay - - !=============================================================================== - subroutine ModelFinalize(gcomp, rc) - type(ESMF_GridComp) :: gcomp - integer, intent(out) :: rc - !------------------------------------------------------------------------------- - - rc = ESMF_SUCCESS - if (my_task == main_task) then - write(logunit,*) - write(logunit,*) 'datm : end of main integration loop' - write(logunit,*) - end if - end subroutine ModelFinalize - -#ifdef CESMCOUPLED -end module atm_comp_nuopc -#else -end module cdeps_datm_comp -#endif diff --git a/CDEPS/patches/atm_comp_nuopc.F90.patch b/CDEPS/patches/atm_comp_nuopc.F90.patch new file mode 100644 index 0000000..5f154d6 --- /dev/null +++ b/CDEPS/patches/atm_comp_nuopc.F90.patch @@ -0,0 +1,73 @@ +--- CDEPS/datm/atm_comp_nuopc.F90 2023-08-31 10:49:23.508874000 +1000 ++++ extra_sources/atm_comp_nuopc.F90 2023-08-31 10:48:55.428272000 +1000 +@@ -52,6 +52,12 @@ + use datm_datamode_jra_mod , only : datm_datamode_jra_restart_write + use datm_datamode_jra_mod , only : datm_datamode_jra_restart_read + ++ use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_advertise ++ use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_init_pointers ++ use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_advance ++ use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_restart_write ++ use datm_datamode_jra55do_mod , only : datm_datamode_jra55do_restart_read ++ + use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_advertise + use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_init_pointers + use datm_datamode_clmncep_mod , only : datm_datamode_clmncep_advance +@@ -342,6 +348,7 @@ + if ( trim(datamode) == 'CORE2_NYF' .or. & + trim(datamode) == 'CORE2_IAF' .or. & + trim(datamode) == 'CORE_IAF_JRA' .or. & ++ trim(datamode) == 'CORE_IAF_JRA55do'.or. & + trim(datamode) == 'CLMNCEP' .or. & + trim(datamode) == 'CPLHIST' .or. & + trim(datamode) == 'GEFS' .or. & +@@ -361,6 +368,10 @@ + call datm_datamode_jra_advertise(exportState, fldsExport, flds_scalar_name, & + flds_co2, flds_wiso, flds_presaero, flds_presndep, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return ++ case ('CORE_IAF_JRA55do') ++ call datm_datamode_jra55do_advertise(exportState, fldsExport, flds_scalar_name, & ++ flds_co2, flds_wiso, flds_presaero, flds_presndep, rc) ++ if (ChkErr(rc,__LINE__,u_FILE_u)) return + case ('CLMNCEP') + call datm_datamode_clmncep_advertise(exportState, fldsExport, flds_scalar_name, & + flds_co2, flds_wiso, flds_presaero, flds_presndep, flds_preso3, rc) +@@ -606,6 +617,9 @@ + case('CORE_IAF_JRA') + call datm_datamode_jra_init_pointers(exportState, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return ++ case('CORE_IAF_JRA55do') ++ call datm_datamode_jra55do_init_pointers(exportState, sdat, rc) ++ if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('CLMNCEP') + call datm_datamode_clmncep_init_pointers(importState, exportState, sdat, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return +@@ -630,6 +644,8 @@ + call datm_datamode_core2_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + case('CORE_IAF_JRA') + call datm_datamode_jra_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) ++ case('CORE_IAF_JRA55do') ++ call datm_datamode_jra55do_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + case('CLMNCEP') + call datm_datamode_clmncep_restart_read(restfilm, inst_suffix, logunit, my_task, mpicom, sdat) + case('CPLHIST') +@@ -677,6 +693,9 @@ + case('CORE_IAF_JRA') + call datm_datamode_jra_advance(exportstate, target_ymd, target_tod, sdat%model_calendar, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return ++ case('CORE_IAF_JRA55do') ++ call datm_datamode_jra55do_advance(exportstate, target_ymd, target_tod, sdat%model_calendar, rc) ++ if (ChkErr(rc,__LINE__,u_FILE_u)) return + case('CLMNCEP') + call datm_datamode_clmncep_advance(mainproc, logunit, mpicom, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return +@@ -705,6 +724,9 @@ + case('CORE_IAF_JRA') + call datm_datamode_jra_restart_write(case_name, inst_suffix, target_ymd, target_tod, & + logunit, my_task, sdat) ++ case('CORE_IAF_JRA55do') ++ call datm_datamode_jra55do_restart_write(case_name, inst_suffix, target_ymd, target_tod, & ++ logunit, my_task, sdat) + case('CLMNCEP') + call datm_datamode_clmncep_restart_write(case_name, inst_suffix, target_ymd, target_tod, & + logunit, my_task, sdat)