From 344d93bf0a86e957a07b3724e6382d26237928b3 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 8 Jun 2009 21:05:14 +0000 Subject: [PATCH 01/24] create a trunk dir From e6a42c42d8721b877e6458dc9dd06731bb28c11d Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Tue, 4 Feb 2020 21:41:34 -0700 Subject: [PATCH 02/24] updated buildlib.py to account for difference --- .../xatm/cime_config/buildlib | 1 + .../xatm/cime_config/buildnml | 27 + .../xatm/cime_config/config_component.xml | 25 + .../xatm/src/atm_comp_nuopc.F90 | 579 +++++++++++ .../xglc/cime_config/buildlib | 1 + .../xglc/cime_config/buildnml | 27 + .../xglc/cime_config/config_component.xml | 26 + .../xglc/src/glc_comp_nuopc.F90 | 521 ++++++++++ .../xice/cime_config/buildlib | 1 + .../xice/cime_config/buildnml | 27 + .../xice/cime_config/config_component.xml | 26 + .../xice/src/ice_comp_nuopc.F90 | 557 +++++++++++ .../xlnd/cime_config/buildlib | 1 + .../xlnd/cime_config/buildnml | 27 + .../xlnd/cime_config/config_component.xml | 26 + .../xlnd/src/lnd_comp_nuopc.F90 | 563 +++++++++++ .../xocn/cime_config/buildlib | 1 + .../xocn/cime_config/buildnml | 27 + .../xocn/cime_config/config_component.xml | 27 + .../xocn/src/ocn_comp_nuopc.F90 | 537 +++++++++++ .../xrof/cime_config/buildlib | 1 + .../xrof/cime_config/buildnml | 27 + .../xrof/cime_config/config_component.xml | 39 + .../xrof/src/rof_comp_nuopc.F90 | 511 ++++++++++ .../xshare/dead_methods_mod.F90 | 840 ++++++++++++++++ .../xshare/dead_nuopc_mod.F90 | 907 ++++++++++++++++++ .../xwav/cime_config/buildlib | 1 + .../xwav/cime_config/buildnml | 27 + .../xwav/cime_config/config_component.xml | 26 + .../xwav/src/wav_comp_nuopc.F90 | 518 ++++++++++ 30 files changed, 5924 insertions(+) create mode 120000 src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib create mode 100755 src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml create mode 100644 src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml create mode 100644 src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 create mode 120000 src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib create mode 100755 src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml create mode 100644 src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml create mode 100644 src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 create mode 120000 src/components/xcpl_comps_nuopc/xice/cime_config/buildlib create mode 100755 src/components/xcpl_comps_nuopc/xice/cime_config/buildnml create mode 100644 src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml create mode 100644 src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 create mode 120000 src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib create mode 100755 src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml create mode 100644 src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml create mode 100644 src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 create mode 120000 src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib create mode 100755 src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml create mode 100644 src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml create mode 100644 src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 create mode 120000 src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib create mode 100755 src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml create mode 100644 src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml create mode 100644 src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 create mode 100644 src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 create mode 100644 src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 create mode 120000 src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib create mode 100755 src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml create mode 100644 src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml create mode 100644 src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib new file mode 120000 index 000000000..9601a6fa7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib @@ -0,0 +1 @@ +../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml new file mode 100755 index 000000000..50a814c79 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +""" +build data model library +""" + +import sys, os + +_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) + +from standard_script_setup import * +from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.case import Case + +def buildnml(case, caseroot, compname): + if compname != "xatm": + raise AttributeError + build_xcpl_nml(case, caseroot, compname) + +def _main_func(): + caseroot = parse_input(sys.argv) + with Case(caseroot) as case: + buildnml(case, caseroot, "xatm") + +if __name__ == "__main__": + _main_func() diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml b/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml new file mode 100644 index 000000000..76c8be8c7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml @@ -0,0 +1,25 @@ + + + + + + + Dead atm component + + + + char + xatm + xatm + case_comp + env_case.xml + Name of atmosphere component + + + + ========================================= + XATM naming conventions in compset name + ========================================= + + + diff --git a/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 new file mode 100644 index 000000000..4cbea61d0 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 @@ -0,0 +1,579 @@ +module atm_comp_nuopc + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for XATM + !---------------------------------------------------------------------------- + + use ESMF + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index + use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + + implicit none + private ! except + + public :: SetServices + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + character(len=CL) :: 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 :: fldsToAtm_num = 0 + integer :: fldsFrAtm_num = 0 + type (fld_list_type) :: fldsToAtm(fldsMax) + type (fld_list_type) :: fldsFrAtm(fldsMax) + integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost + + real(r8), pointer :: gbuf(:,:) ! model info + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer , allocatable :: gindex(:) + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + integer :: inst_index ! number of current instance (ie. 1) + character(len=5) :: inst_suffix ! char string associated with instance (ie. "_0001" or "") + integer :: logunit ! logging unit number + logical :: mastertask + integer :: dbug = 1 + character(*),parameter :: modName = "(xatm_comp_nuopc)" + character(*),parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! 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=ModelInitPhase, 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=ModelSetRunClock, 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, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + 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 + type(ESMF_VM) :: vm + character(CS) :: stdname + integer :: n + integer :: lsize ! local array size + integer :: shrlogunit ! original log unit + character(CL) :: cvalue + character(len=CL) :: logmsg + logical :: isPresent, isSet + character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localpet=my_task, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + mastertask = (my_task==0) + + !---------------------------------------------------------------------------- + ! determine instance information + !---------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Initialize xatm + !---------------------------------------------------------------------------- + + call dead_init_nuopc('atm', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + allocate(gindex(lsize)) + allocate(lon(lsize)) + allocate(lat(lsize)) + + gindex(:) = gbuf(:,dead_grid_index) + lat(:) = gbuf(:,dead_grid_lat) + lon(:) = gbuf(:,dead_grid_lon) + + !-------------------------------- + ! advertise import and export fields + !-------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + flds_scalar_name = trim(cvalue) + call ESMF_LogWrite(trim(subname)//' flds_scalar_name = '//trim(flds_scalar_name), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldName') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldCount", 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_num + write(logmsg,*) flds_scalar_num + call ESMF_LogWrite(trim(subname)//' flds_scalar_num = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldCount') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNX", 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_nx + write(logmsg,*) flds_scalar_index_nx + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nx = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNX') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNY", 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_ny + write(logmsg,*) flds_scalar_index_ny + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_ny = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') + endif + + 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 + write(logmsg,*) flds_scalar_index_nextsw_cday + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nextsw_cday = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxNextSwCday') + endif + + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrAtm_num, fldsFrAtm, trim(flds_scalar_name)) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_topo' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_z' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_u' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_v' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_tbot' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_ptem' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_shum' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_pbot' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_dens' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_pslv' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainc' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainl' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowc' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowl' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_lwdn' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swndr' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swvdr' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swndf' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swvdf' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swnet' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_dstwet', ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_dstdry', ungridded_lbound=1, ungridded_ubound=4) + + call fld_list_add(fldsToAtm_num, fldsToAtm, trim(flds_scalar_name)) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_anidr' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_avsdf' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_anidf' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_avsdr' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_lfrac' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Si_ifrac' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_ofrac' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_tref' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_qref' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_t' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_t' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_fv' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_ram1' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_snowh' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Si_snowh' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_ssq' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_re' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_u10' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_taux' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_tauy' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_lat' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_sen' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_lwup' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_evap' ) + + do n = 1,fldsFrAtm_num + if(mastertask) write(logunit,*)'Advertising From Xatm ',trim(fldsFrAtm(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrAtm(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + + do n = 1,fldsToAtm_num + if(mastertask) write(logunit,*)'Advertising To Xatm',trim(fldsToAtm(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToAtm(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeAdvertise + + !=============================================================================== + + subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) + + ! input/output arguments + type(ESMF_GridComp) :: gcomp + type(ESMF_State) :: importState, exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + + ! local variables + type(ESMF_Mesh) :: Emesh + type(ESMF_Time) :: nextTime + real(r8) :: nextsw_cday + integer :: n + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize: xatm) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logUnit) + + !-------------------------------- + ! generate the mesh + !-------------------------------- + + call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! realize the actively coupled fields, now that a mesh is established + ! 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 fld_list_realize( & + state=exportState, & + fldList=fldsFrAtm, & + numflds=fldsFrAtm_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':datmExport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fld_list_realize( & + state=importState, & + fldList=fldsToAtm, & + numflds=fldsToAtm_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':datmImport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call state_setexport(exportState, rc=rc) + + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! Set time of next radiation computation + + call ESMF_ClockGetNextTime(clock, nextTime) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_TimeGet(nextTime, dayOfYear_r8=nextsw_cday) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call 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 + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call State_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeRealize + + !=============================================================================== + + subroutine ModelAdvance(gcomp, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + real(r8) :: nextsw_cday + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + if (dbug > 1) then + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + end if + call memcheck(subname, 3, mastertask) + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call 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 + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call state_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (mastertask) then + call log_clock_advance(clock, 'XATM', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) then + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + end if + + end subroutine ModelAdvance + + !=============================================================================== + + subroutine state_setexport(exportState, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer, intent(out) :: rc + + ! local variables + integer :: nf, nind + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Start from index 2 in order to Skip the scalar field here + do nf = 2,fldsFrAtm_num + if (fldsFrAtm(nf)%ungridded_ubound == 0) then + call field_setexport(exportState, trim(fldsFrAtm(nf)%stdname), lon, lat, nf=nf, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + do nind = 1,fldsFrAtm(nf)%ungridded_ubound + call field_setexport(exportState, trim(fldsFrAtm(nf)%stdname), lon, lat, nf=nf+nind-1, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + + end subroutine state_setexport + + !=============================================================================== + + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) + + use shr_const_mod , only : pi=>shr_const_pi + + ! intput/otuput variables + type(ESMF_State) , intent(inout) :: exportState + character(len=*) , intent(in) :: fldname + real(r8) , intent(in) :: lon(:) + real(r8) , intent(in) :: lat(:) + integer , intent(in) :: nf + integer, optional , intent(in) :: ungridded_index + integer , intent(out) :: rc + + ! local variables + integer :: i, ncomp + type(ESMF_Field) :: lfield + real(r8), pointer :: data1d(:) + real(r8), pointer :: data2d(:,:) + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemName=trim(fldname), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ncomp = 1 + if (present(ungridded_index)) then + call ESMF_FieldGet(lfield, farrayPtr=data2d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (gridToFieldMap == 1) then + do i = 1,size(data2d, dim=1) + data2d(i,ungridded_index) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + else if (gridToFieldMap == 2) then + do i = 1,size(data2d, dim=2) + data2d(ungridded_index,i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + else + call ESMF_FieldGet(lfield, farrayPtr=data1d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + do i = 1,size(data1d) + data1d(i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + + end subroutine field_setexport + + !=============================================================================== + + subroutine ModelFinalize(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' + !------------------------------------------------------------------------------- + + !-------------------------------- + ! Finalize routine + !-------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call dead_final_nuopc('atm', logunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelFinalize + +end module atm_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib new file mode 120000 index 000000000..9601a6fa7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib @@ -0,0 +1 @@ +../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml new file mode 100755 index 000000000..64077a469 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +""" +build data model library +""" + +import sys, os + +_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) + +from standard_script_setup import * +from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.case import Case + +def buildnml(case, caseroot, compname): + if compname != "xglc": + raise AttributeError + build_xcpl_nml(case, caseroot, compname) + +def _main_func(): + caseroot = parse_input(sys.argv) + with Case(caseroot) as case: + buildnml(case, caseroot, "xglc") + +if __name__ == "__main__": + _main_func() diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml b/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml new file mode 100644 index 000000000..f1765811b --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml @@ -0,0 +1,26 @@ + + + + + + + Dead land-ice component + + + + char + xglc + xglc + case_comp + env_case.xml + Name of land-ice component + + + + + ========================================= + XGLC naming conventions in compset name + ========================================= + + + diff --git a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 new file mode 100644 index 000000000..f381503f7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 @@ -0,0 +1,521 @@ +module glc_comp_nuopc + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for XGLC + !---------------------------------------------------------------------------- + + use ESMF + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index + use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + + implicit none + private ! except + + public :: SetServices + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + character(len=CL) :: flds_scalar_name = '' + integer :: flds_scalar_num = 0 + integer :: flds_scalar_index_nx = 0 + integer :: flds_scalar_index_ny = 0 + + integer :: fldsToGlc_num = 0 + integer :: fldsFrGlc_num = 0 + type (fld_list_type) :: fldsToGlc(fldsMax) + type (fld_list_type) :: fldsFrGlc(fldsMax) + integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost + + real(r8), pointer :: gbuf(:,:) ! model info + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer , allocatable :: gindex(:) + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + 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 + integer ,parameter :: master_task=0 ! task number of master task + logical :: mastertask + integer :: dbug = 1 + character(*),parameter :: modName = "(xglc_comp_nuopc)" + character(*),parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! 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=ModelInitPhase, 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=ModelSetRunClock, 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, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + 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 + type(ESMF_VM) :: vm + character(CS) :: stdname + integer :: n + integer :: lsize ! local array size + integer :: shrlogunit ! original log unit + character(CL) :: cvalue + character(len=CL) :: logmsg + logical :: isPresent, isSet + character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localpet=my_task, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + mastertask = my_task == master_task + + !---------------------------------------------------------------------------- + ! determine instance information + !---------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, my_task==master_task, logunit, shrlogunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Initialize xglc + !---------------------------------------------------------------------------- + + call dead_init_nuopc('glc', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + allocate(gindex(lsize)) + allocate(lon(lsize)) + allocate(lat(lsize)) + + gindex(:) = gbuf(:,dead_grid_index) + lat(:) = gbuf(:,dead_grid_lat) + lon(:) = gbuf(:,dead_grid_lon) + + !-------------------------------- + ! advertise import and export fields + !-------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + flds_scalar_name = trim(cvalue) + call ESMF_LogWrite(trim(subname)//' flds_scalar_name = '//trim(flds_scalar_name), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldName') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldCount", 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_num + write(logmsg,*) flds_scalar_num + call ESMF_LogWrite(trim(subname)//' flds_scalar_num = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldCount') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNX", 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_nx + write(logmsg,*) flds_scalar_index_nx + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nx = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNX') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNY", 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_ny + write(logmsg,*) flds_scalar_index_ny + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_ny = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') + endif + + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrGlc_num, fldsFrGlc, trim(flds_scalar_name)) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_icemask' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_icemask_coupled_fluxes' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_ice_covered' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_topo' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Flgg_hflx' ) + + call fld_list_add(fldsToGlc_num, fldsToGlc, trim(flds_scalar_name)) + call fld_list_add(fldsToGlc_num, fldsToGlc, 'Sl_tsrf') + call fld_list_add(fldsToGlc_num, fldsToGlc, 'Flgl_qice') + + do n = 1,fldsFrGlc_num + if (mastertask) write(logunit,*)'Advertising From Xglc ',trim(fldsFrGlc(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrglc(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + do n = 1,fldsToGlc_num + if (mastertask) write(logunit,*)'Advertising To Xglc ',trim(fldsToGlc(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToglc(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) + + 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_Mesh) :: Emesh + integer :: shrlogunit ! original log unit + integer :: n + character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! generate the mesh + ! grid_option specifies grid or mesh + !-------------------------------- + + call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! realize the actively coupled fields, now that a mesh is established + ! 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 fld_list_realize( & + state=ExportState, & + fldList=fldsFrGlc, & + numflds=fldsFrGlc_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':dglcExport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fld_list_realize( & + state=importState, & + fldList=fldsToGlc, & + numflds=fldsToGlc_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':dglcImport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! Pack export state + ! Copy from d2x to exportState + ! Set the coupling scalars + !-------------------------------- + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setscalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setscalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call state_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeRealize + + !=============================================================================== + + subroutine ModelAdvance(gcomp, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + integer :: n + integer :: shrlogunit ! original log unit + real(r8), pointer :: dataptr(:) + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + call memcheck(subname, 3, mastertask) + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call state_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (my_task == master_task) then + call log_clock_advance(clock, 'XGLC', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelAdvance + + !=============================================================================== + + subroutine state_setexport(exportState, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer, intent(out) :: rc + + ! local variables + integer :: nf, nind + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Start from index 2 in order to skip the scalar field + do nf = 2,fldsFrGlc_num + if (fldsFrGlc(nf)%ungridded_ubound == 0) then + call field_setexport(exportState, trim(fldsFrGlc(nf)%stdname), lon, lat, nf=nf, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + do nind = 1,fldsFrGlc(nf)%ungridded_ubound + call field_setexport(exportState, trim(fldsFrGlc(nf)%stdname), lon, lat, nf=nf+nind-1, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + + end subroutine state_setexport + + !=============================================================================== + + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) + + use shr_const_mod , only : pi=>shr_const_pi + + ! intput/otuput variables + type(ESMF_State) , intent(inout) :: exportState + character(len=*) , intent(in) :: fldname + real(r8) , intent(in) :: lon(:) + real(r8) , intent(in) :: lat(:) + integer , intent(in) :: nf + integer, optional , intent(in) :: ungridded_index + integer , intent(out) :: rc + + ! local variables + integer :: i, ncomp + type(ESMF_Field) :: lfield + real(r8), pointer :: data1d(:) + real(r8), pointer :: data2d(:,:) + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemName=trim(fldname), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ncomp = 5 + if (present(ungridded_index)) then + call ESMF_FieldGet(lfield, farrayPtr=data2d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (gridToFieldMap == 1) then + do i = 1,size(data2d, dim=1) + data2d(i,ungridded_index) = (nf*100) & + * cos (pi*lat(i)/180.0_R8) * cos (pi*lat(i)/180.0_R8) & + * sin (pi*lon(i)/180.0_R8) * sin (pi*lon(i)/180.0_R8) & + + (ncomp*10.0_R8) + enddo + else if (gridToFieldMap == 2) then + do i = 1,size(data2d, dim=2) + data2d(ungridded_index,i) = (nf*100) & + * cos (pi*lat(i)/180.0_R8) * cos (pi*lat(i)/180.0_R8) & + * sin (pi*lon(i)/180.0_R8) * sin (pi*lon(i)/180.0_R8) & + + (ncomp*10.0_R8) + end do + end if + else + call ESMF_FieldGet(lfield, farrayPtr=data1d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (fldname == 'Sg_icemask' .or. fldname == 'Sg_icemask_coupled_fluxes' .or. fldname == 'Sg_ice_covered') then + data1d(:) = 1._r8 + else + do i = 1,size(data1d) + data1d(i) = (nf*100) & + * cos (pi*lat(i)/180.0_R8) * cos (pi*lat(i)/180.0_R8) & + * sin (pi*lon(i)/180.0_R8) * sin (pi*lon(i)/180.0_R8) & + + (ncomp*10.0_R8) + end do + end if + end if + + end subroutine field_setexport + + !=============================================================================== + + subroutine ModelFinalize(gcomp, rc) + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' + !------------------------------------------------------------------------------- + + !-------------------------------- + ! Finalize routine + !-------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call dead_final_nuopc('glc', logunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelFinalize + + !=============================================================================== + +end module glc_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib b/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib new file mode 120000 index 000000000..9601a6fa7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib @@ -0,0 +1 @@ +../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml new file mode 100755 index 000000000..e023dc7c6 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +""" +build data model library +""" + +import sys, os + +_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) + +from standard_script_setup import * +from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.case import Case + +def buildnml(case, caseroot, compname): + if compname != "xice": + raise AttributeError + build_xcpl_nml(case, caseroot, compname) + +def _main_func(): + caseroot = parse_input(sys.argv) + with Case(caseroot) as case: + buildnml(case, caseroot, "xice") + +if __name__ == "__main__": + _main_func() diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml b/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml new file mode 100644 index 000000000..a3263a0ee --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml @@ -0,0 +1,26 @@ + + + + + + + Dead ice component + + + + char + xice + xice + case_comp + env_case.xml + Name of sea-ice component + + + + + ========================================= + XICE naming conventions in compset name + ========================================= + + + diff --git a/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 new file mode 100644 index 000000000..3537e8dd1 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 @@ -0,0 +1,557 @@ +module ice_comp_nuopc + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for XICE + !---------------------------------------------------------------------------- + + use ESMF + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index + use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + + implicit none + private ! except + + public :: SetServices + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + character(len=CL) :: flds_scalar_name = '' + integer :: flds_scalar_num = 0 + integer :: flds_scalar_index_nx = 0 + integer :: flds_scalar_index_ny = 0 + + integer :: fldsToIce_num = 0 + integer :: fldsFrIce_num = 0 + type (fld_list_type) :: fldsToIce(fldsMax) + type (fld_list_type) :: fldsFrIce(fldsMax) + integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost + + real(r8), pointer :: gbuf(:,:) ! model info + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer , allocatable :: gindex(:) + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + 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 + integer ,parameter :: master_task=0 ! task number of master task + logical :: mastertask + integer :: dbug = 1 + character(*),parameter :: modName = "(xice_comp_nuopc)" + character(*),parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! 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=ModelInitPhase, 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=ModelSetRunClock, 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, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + 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 + type(ESMF_VM) :: vm + character(CL) :: cvalue + character(CS) :: stdname + integer :: n + integer :: lsize ! local array size + integer :: shrlogunit ! original log unit + character(len=CL) :: logmsg + logical :: isPresent, isSet + character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localpet=my_task, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + mastertask = my_task == master_task + + !---------------------------------------------------------------------------- + ! determine instance information + !---------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, my_task==master_task, logunit, shrlogunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Initialize xice + !---------------------------------------------------------------------------- + + call dead_init_nuopc('ice', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + allocate(gindex(lsize)) + allocate(lon(lsize)) + allocate(lat(lsize)) + + gindex(:) = gbuf(:,dead_grid_index) + lat(:) = gbuf(:,dead_grid_lat) + lon(:) = gbuf(:,dead_grid_lon) + + !-------------------------------- + ! advertise import and export fields + !-------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + flds_scalar_name = trim(cvalue) + call ESMF_LogWrite(trim(subname)//' flds_scalar_name = '//trim(flds_scalar_name), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldName') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldCount", 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_num + write(logmsg,*) flds_scalar_num + call ESMF_LogWrite(trim(subname)//' flds_scalar_num = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldCount') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNX", 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_nx + write(logmsg,*) flds_scalar_index_nx + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nx = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNX') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNY", 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_ny + write(logmsg,*) flds_scalar_index_ny + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_ny = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') + endif + + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrIce_num, fldsFrIce, trim(flds_scalar_name)) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_imask' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_ifrac' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_t' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_tref' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_qref' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_snowh' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_u10' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_avsdr' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_anidr' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_avsdf' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_anidf' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_taux' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_tauy' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_lat' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_sen' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_lwup' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_evap' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_swnet' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_melth' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_swpen' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_meltw' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_salt' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_taux' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_tauy' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_bcpho' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_bcphi' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_flxdst' ) + + call fld_list_add(fldsToIce_num, fldsToIce, trim(flds_scalar_name)) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_dhdx' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_dhdy' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_t' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_s' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_u' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_v' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Fioo_q' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_z' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_u' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_v' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_ptem' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_shum' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_dens' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_tbot' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swvdr' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swndr' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swvdf' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swndf' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_lwdn' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_rain' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_snow' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_dstwet', ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_dstdry', ungridded_lbound=1, ungridded_ubound=4) + + do n = 1,fldsFrIce_num + if(mastertask) write(logunit,*)'Advertising From Xice ',trim(fldsFrIce(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrIce(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + do n = 1,fldsToIce_num + if(mastertask) write(logunit,*)'Advertising To Xice ',trim(fldsToIce(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToIce(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) + + end subroutine InitializeAdvertise + + !=============================================================================== + + subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) + type(ESMF_GridComp) :: gcomp + type(ESMF_State) :: importState, exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + + ! local variables + type(ESMF_Mesh) :: Emesh + integer :: shrlogunit ! original log unit + integer :: n + character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logUnit) + + !-------------------------------- + ! generate the mesh + !-------------------------------- + + call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! realize the actively coupled fields, now that a mesh is established + ! 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 fld_list_realize( & + state=ExportState, & + fldlist=fldsFrIce, & + numflds=fldsFrIce_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':diceExport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fld_list_realize( & + state=importState, & + fldList=fldsToIce, & + numflds=fldsToIce_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':diceImport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call State_SetExport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call State_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeRealize + + !=============================================================================== + + subroutine ModelAdvance(gcomp, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + call memcheck(subname, 3, mastertask) + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call State_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (my_task == master_task) then + call log_clock_advance(clock, 'XICE', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + endif + + call shr_file_setLogUnit (shrlogunit) + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelAdvance + + !=============================================================================== + + subroutine state_setexport(exportState, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer, intent(out) :: rc + + ! local variables + integer :: nf, nind + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Start from index 2 in order to skip the scalar field + do nf = 2,fldsFrIce_num + if (fldsFrIce(nf)%ungridded_ubound == 0) then + call field_setexport(exportState, trim(fldsFrIce(nf)%stdname), lon, lat, nf=nf, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + do nind = 1,fldsFrIce(nf)%ungridded_ubound + call field_setexport(exportState, trim(fldsFrIce(nf)%stdname), lon, lat, nf=nf+nind-1, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + + end subroutine state_setexport + + !=============================================================================== + + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) + + use shr_const_mod , only : pi=>shr_const_pi + + ! intput/otuput variables + type(ESMF_State) , intent(inout) :: exportState + character(len=*) , intent(in) :: fldname + real(r8) , intent(in) :: lon(:) + real(r8) , intent(in) :: lat(:) + integer , intent(in) :: nf + integer, optional , intent(in) :: ungridded_index + integer , intent(out) :: rc + + ! local variables + integer :: i, ncomp + type(ESMF_Field) :: lfield + real(r8), pointer :: data1d(:) + real(r8), pointer :: data2d(:,:) + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemName=trim(fldname), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ncomp = 3 + if (present(ungridded_index)) then + call ESMF_FieldGet(lfield, farrayPtr=data2d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (gridToFieldMap == 1) then + do i = 1,size(data2d, dim=1) + data2d(i,ungridded_index) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + else if (gridToFieldMap == 2) then + do i = 1,size(data2d, dim=2) + data2d(ungridded_index,i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + else + call ESMF_FieldGet(lfield, farrayPtr=data1d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + do i = 1,size(data1d) + data1d(i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + ! Reset some fields + if (fldname == 'Si_ifrac') then + do i = 1,size(data1d) + data1d(i) = min(1.0_R8,max(0.0_R8,data1d(i))) + end do + else if (fldname == 'Si_imask') then + do i = 1,size(data1d) + data1d(i) = float(nint(min(1.0_R8,max(0.0_R8,data1d(i))))) + end do + end if + end if + + end subroutine field_setexport + + !=============================================================================== + + subroutine ModelFinalize(gcomp, rc) + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' + !------------------------------------------------------------------------------- + + !-------------------------------- + ! Finalize routine + !-------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call dead_final_nuopc('ice', logunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelFinalize + +end module ice_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib new file mode 120000 index 000000000..9601a6fa7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib @@ -0,0 +1 @@ +../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml new file mode 100755 index 000000000..760d75e5c --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +""" +build data model library +""" + +import sys, os + +_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) + +from standard_script_setup import * +from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.case import Case + +def buildnml(case, caseroot, compname): + if compname != "xlnd": + raise AttributeError + build_xcpl_nml(case, caseroot, compname) + +def _main_func(): + caseroot = parse_input(sys.argv) + with Case(caseroot) as case: + buildnml(case, caseroot, "xlnd") + +if __name__ == "__main__": + _main_func() diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml b/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml new file mode 100644 index 000000000..8179d0310 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml @@ -0,0 +1,26 @@ + + + + + + + Dead land component + + + + + char + xlnd + xlnd + case_comp + env_case.xml + Name of land component + + + + ========================================= + XLND naming conventions in compset name + ========================================= + + + diff --git a/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 new file mode 100644 index 000000000..4e76678b8 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 @@ -0,0 +1,563 @@ +module lnd_comp_nuopc + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for XLND + !---------------------------------------------------------------------------- + + use ESMF + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index + use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + + implicit none + private ! except + + public :: SetServices + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + character(len=CL) :: 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._r8 + + integer :: fldsToLnd_num = 0 + integer :: fldsFrLnd_num = 0 + type (fld_list_type) :: fldsToLnd(fldsMax) + type (fld_list_type) :: fldsFrLnd(fldsMax) + integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost + integer :: glc_nec + + real(r8), pointer :: gbuf(:,:) ! model info + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer , allocatable :: gindex(:) + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + 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 + integer ,parameter :: master_task=0 ! task number of master task + logical :: mastertask + integer :: dbug = 1 + character(*),parameter :: modName = "(xlnd_comp_nuopc)" + character(*),parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! 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=ModelInitPhase, 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=ModelSetRunClock, 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, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + 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 + type(ESMF_VM) :: vm + character(CS) :: stdname + integer :: n + integer :: lsize ! local array size + integer :: shrlogunit ! original log unit + character(CL) :: cvalue + character(len=CL) :: logmsg + logical :: isPresent, isSet + character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localpet=my_task, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + mastertask = my_task == master_task + + !---------------------------------------------------------------------------- + ! determine instance information + !---------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Initialize xlnd + !---------------------------------------------------------------------------- + + call dead_init_nuopc('lnd', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + allocate(gindex(lsize)) + allocate(lon(lsize)) + allocate(lat(lsize)) + + gindex(:) = gbuf(:,dead_grid_index) + lat(:) = gbuf(:,dead_grid_lat) + lon(:) = gbuf(:,dead_grid_lon) + + !-------------------------------- + ! advertise import and export fields + !-------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + flds_scalar_name = trim(cvalue) + call ESMF_LogWrite(trim(subname)//' flds_scalar_name = '//trim(flds_scalar_name), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldName') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldCount", 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_num + write(logmsg,*) flds_scalar_num + call ESMF_LogWrite(trim(subname)//' flds_scalar_num = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldCount') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNX", 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_nx + write(logmsg,*) flds_scalar_index_nx + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nx = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNX') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNY", 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_ny + write(logmsg,*) flds_scalar_index_ny + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_ny = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') + end if + + if (nxg /= 0 .and. nyg /= 0) then + + call NUOPC_CompAttributeGet(gcomp, name='glc_nec', value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) glc_nec + call ESMF_LogWrite('glc_nec = '// trim(cvalue), ESMF_LOGMSG_INFO) + + call fld_list_add(fldsFrLnd_num, fldsFrlnd, trim(flds_scalar_name)) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_lfrin' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_t' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_tref' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_qref' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_avsdr' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_anidr' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_avsdf' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_anidf' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_snowh' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_u10' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_fv' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_ram1' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofsur' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofgwl' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofsub' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofi' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_irrig' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_taux' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_tauy' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_lat' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_sen' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_lwup' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_evap' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_swnet' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_flxdst' , ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flgl_qice_elev', ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_tsrf_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_topo_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + + call fld_list_add(fldsToLnd_num, fldsToLnd, trim(flds_scalar_name)) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_z' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_topo' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_u' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_v' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_ptem' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_pbot' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_tbot' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_shum' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Flrr_volr' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Flrr_volrmch' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_lwdn' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_rainc' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_rainl' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_snowc' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_snowl' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swndr' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swvdr' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swndf' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swvdf' ) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_dstwet' , ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_dstdry' , ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_topo_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_ice_covered_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsToLnd_num, fldsTolnd, 'Flgg_hflx_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + + do n = 1,fldsFrLnd_num + if (mastertask) write(logunit,*)'Advertising From Xlnd ',trim(fldsFrLnd(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrLnd(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + do n = 1,fldsToLnd_num + if(mastertask) write(logunit,*)'Advertising To Xlnd',trim(fldsToLnd(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToLnd(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + end if + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) + + end subroutine InitializeAdvertise + + !=============================================================================== + + subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) + + ! intput/output variables + type(ESMF_GridComp) :: gcomp + type(ESMF_State) :: importState, exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + + ! local variables + type(ESMF_Mesh) :: Emesh + integer :: shrlogunit ! original log unit + type(ESMF_VM) :: vm + integer :: n + logical :: connected ! is field connected? + character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logUnit) + + !-------------------------------- + ! generate the mesh + !-------------------------------- + + call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! realize the actively coupled fields, now that a mesh is established + ! 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 fld_list_realize( & + state=ExportState, & + fldlist=fldsFrLnd, & + numflds=fldsFrLnd_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':dlndExport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fld_list_realize( & + state=importState, & + fldList=fldsToLnd, & + numflds=fldsToLnd_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':dlndImport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call state_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeRealize + + !=============================================================================== + + subroutine ModelAdvance(gcomp, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + call memcheck(subname, 3, mastertask) + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call state_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (mastertask) then + call log_clock_advance(clock, 'LND', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + endif + + call shr_file_setLogUnit (shrlogunit) + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelAdvance + + !=============================================================================== + + subroutine state_setexport(exportState, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer, intent(out) :: rc + + ! local variables + integer :: nf, nind + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Start from index 2 in order to Skip the scalar field here + do nf = 2,fldsFrLnd_num + if (fldsFrLnd(nf)%ungridded_ubound == 0) then + call field_setexport(exportState, trim(fldsFrLnd(nf)%stdname), lon, lat, nf=nf, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + do nind = 1,fldsFrLnd(nf)%ungridded_ubound + call field_setexport(exportState, trim(fldsFrLnd(nf)%stdname), lon, lat, nf=nf+nind-1, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + + end subroutine state_setexport + + !=============================================================================== + + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) + + use shr_const_mod , only : pi=>shr_const_pi + + ! intput/otuput variables + type(ESMF_State) , intent(inout) :: exportState + character(len=*) , intent(in) :: fldname + real(r8) , intent(in) :: lon(:) + real(r8) , intent(in) :: lat(:) + integer , intent(in) :: nf + integer, optional , intent(in) :: ungridded_index + integer , intent(out) :: rc + + ! local variables + integer :: i, ncomp + type(ESMF_Field) :: lfield + real(r8), pointer :: data1d(:) + real(r8), pointer :: data2d(:,:) + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemName=trim(fldname), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ncomp = 2 + if (present(ungridded_index)) then + call ESMF_FieldGet(lfield, farrayPtr=data2d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (gridToFieldMap == 1) then + do i = 1,size(data2d, dim=1) + data2d(i,ungridded_index) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + else if (gridToFieldMap == 2) then + do i = 1,size(data2d, dim=2) + data2d(ungridded_index,i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + else + call ESMF_FieldGet(lfield, farrayPtr=data1d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (fldname == 'Sl_lfrin') then + data1d(:) = 1._r8 + else + do i = 1,size(data1d) + data1d(i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + end if + + end subroutine field_setexport + + !=============================================================================== + + subroutine ModelFinalize(gcomp, rc) + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' + !------------------------------------------------------------------------------- + + !-------------------------------- + ! Finalize routine + !-------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call dead_final_nuopc('lnd', logunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelFinalize + +end module lnd_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib new file mode 120000 index 000000000..9601a6fa7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib @@ -0,0 +1 @@ +../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml new file mode 100755 index 000000000..c6f945376 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +""" +build data model library +""" + +import sys, os + +_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) + +from standard_script_setup import * +from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.case import Case + +def buildnml(case, caseroot, compname): + if compname != "xocn": + raise AttributeError + build_xcpl_nml(case, caseroot, compname) + +def _main_func(): + caseroot = parse_input(sys.argv) + with Case(caseroot) as case: + buildnml(case, caseroot, "xocn") + +if __name__ == "__main__": + _main_func() diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml b/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml new file mode 100644 index 000000000..f68d1ff47 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml @@ -0,0 +1,27 @@ + + + + + + + Dead ocean component + + + + char + xocn + xocn + case_comp + env_case.xml + Name of ocean component + + + + + + ========================================= + XOCN naming conventions in compset name + ========================================= + + + diff --git a/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 new file mode 100644 index 000000000..2f3f037e3 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 @@ -0,0 +1,537 @@ +module ocn_comp_nuopc + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for XOCN + !---------------------------------------------------------------------------- + + use ESMF + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index + use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + + implicit none + private ! except + + public :: SetServices + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + character(len=CL) :: 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._r8 + + integer :: fldsToOcn_num = 0 + integer :: fldsFrOcn_num = 0 + type (fld_list_type) :: fldsToOcn(fldsMax) + type (fld_list_type) :: fldsFrOcn(fldsMax) + integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost + + real(r8), pointer :: gbuf(:,:) ! model info + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer , allocatable :: gindex(:) + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + integer :: inst_index ! number of current instance (ie. 1) + character(len=16) :: inst_name ! fullname of current instance (ie. "ocn_0001") + character(len=16) :: inst_suffix = "" ! char string associated with instance (ie. "_0001" or "") + integer :: logunit ! logging unit number + integer ,parameter :: master_task=0 ! task number of master task + logical :: mastertask + integer :: dbug = 1 + character(*),parameter :: modName = "(xocn_comp_nuopc)" + character(*),parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! 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=ModelInitPhase, 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=ModelSetRunClock, 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, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + 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 + type(ESMF_VM) :: vm + character(CS) :: stdname + integer :: n + integer :: lsize ! local array size + integer :: shrlogunit ! original log unit + character(CL) :: cvalue + character(len=CL) :: logmsg + logical :: isPresent, isSet + character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! generate local mpi comm + !---------------------------------------------------------------------------- + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localpet=my_task, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + mastertask = my_task == master_task + + !---------------------------------------------------------------------------- + ! determine instance information + !---------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, my_task==master_task, logunit, shrlogunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Initialize xocn + !---------------------------------------------------------------------------- + + call dead_init_nuopc('ocn', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + allocate(gindex(lsize)) + allocate(lon(lsize)) + allocate(lat(lsize)) + + gindex(:) = gbuf(:,dead_grid_index) + lat(:) = gbuf(:,dead_grid_lat) + lon(:) = gbuf(:,dead_grid_lon) + + !-------------------------------- + ! advertise import and export fields + !-------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + flds_scalar_name = trim(cvalue) + call ESMF_LogWrite(trim(subname)//' flds_scalar_name = '//trim(flds_scalar_name), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldName') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldCount", 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_num + write(logmsg,*) flds_scalar_num + call ESMF_LogWrite(trim(subname)//' flds_scalar_num = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldCount') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNX", 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_nx + write(logmsg,*) flds_scalar_index_nx + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nx = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNX') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNY", 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_ny + write(logmsg,*) flds_scalar_index_ny + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_ny = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') + endif + + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrOcn_num, fldsFrOcn, trim(flds_scalar_name)) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_omask" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_t" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_s" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_u" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_v" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_dhdx" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_dhdy" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_bldepth" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "Fioo_q" ) + + call fld_list_add(fldsToOcn_num, fldsToOcn, trim(flds_scalar_name)) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_rain" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_snow" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_lwdn" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swndr" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swvdr" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swndf" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swvdf" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_taux" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_tauy" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_sen" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_lat" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_lwup" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_evap" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Fioi_salt" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_rofl" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_rofi" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Sa_pslv" ) + + do n = 1,fldsFrOcn_num + if(mastertask) write(logunit,*)'Advertising From Xocn ',trim(fldsFrOcn(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrOcn(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + do n = 1,fldsToOcn_num + if(mastertask) write(logunit,*)'Advertising To Xocn',trim(fldsToOcn(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToOcn(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) + + 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_Mesh) :: Emesh + integer :: shrlogunit ! original log unit + integer :: n + character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize: xocn) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! generate the mesh + !-------------------------------- + + call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! realize the actively coupled fields, now that a mesh is established + ! 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 fld_list_realize( & + state=ExportState, & + fldlist=fldsFrOcn, & + numflds=fldsFrOcn_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':docnExport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fld_list_realize( & + state=importState, & + fldList=fldsToOcn, & + numflds=fldsToOcn_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':docnImport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call state_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeRealize + + !=============================================================================== + + subroutine ModelAdvance(gcomp, rc) + + ! intput/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + call memcheck(subname, 3, mastertask) + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call state_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (my_task == master_task) then + call log_clock_advance(clock, 'OCN', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + endif + + call shr_file_setLogUnit (shrlogunit) + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelAdvance + + !=============================================================================== + + subroutine state_setexport(exportState, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer, intent(out) :: rc + + ! local variables + integer :: nf, nind + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Start from index 2 in order to Skip the scalar field here + do nf = 2,fldsFrOcn_num + if (fldsFrOcn(nf)%ungridded_ubound == 0) then + call field_setexport(exportState, trim(fldsFrOcn(nf)%stdname), lon, lat, nf=nf, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + do nind = 1,fldsFrOcn(nf)%ungridded_ubound + call field_setexport(exportState, trim(fldsFrOcn(nf)%stdname), lon, lat, nf=nf, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + + end subroutine state_setexport + + !=============================================================================== + + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) + + use shr_const_mod , only : pi=>shr_const_pi + + ! intput/otuput variables + type(ESMF_State) , intent(inout) :: exportState + character(len=*) , intent(in) :: fldname + real(r8) , intent(in) :: lon(:) + real(r8) , intent(in) :: lat(:) + integer , intent(in) :: nf + integer, optional , intent(in) :: ungridded_index + integer , intent(out) :: rc + + ! local variables + integer :: i, ncomp + type(ESMF_Field) :: lfield + real(r8), pointer :: data1d(:) + real(r8), pointer :: data2d(:,:) + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemName=trim(fldname), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ncomp = 4 + if (present(ungridded_index)) then + call ESMF_FieldGet(lfield, farrayPtr=data2d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (gridToFieldMap == 1) then + do i = 1,size(data2d, dim=1) + data2d(i,ungridded_index) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + else if (gridToFieldMap == 2) then + do i = 1,size(data2d, dim=2) + data2d(ungridded_index,i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + else + call ESMF_FieldGet(lfield, farrayPtr=data1d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + do i = 1,size(data1d) + data1d(i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + + if (fldname == 'So_omask') then + do i = 1,size(data1d) + !data1d(i) = float(nint(min(1.0_R8,max(0.0_R8,data1d(i))))) + data1d(i) = 0._r8 + end do + end if + + end subroutine field_setexport + + !=============================================================================== + + subroutine ModelFinalize(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' + !------------------------------------------------------------------------------- + + !-------------------------------- + ! Finalize routine + !-------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call dead_final_nuopc('ocn', logunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelFinalize + + !=============================================================================== + +end module ocn_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib new file mode 120000 index 000000000..9601a6fa7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib @@ -0,0 +1 @@ +../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml new file mode 100755 index 000000000..182cf39ef --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +""" +build data model library +""" + +import sys, os + +_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) + +from standard_script_setup import * +from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.case import Case + +def buildnml(case, caseroot, compname): + if compname != "xrof": + raise AttributeError + build_xcpl_nml(case, caseroot, compname) + +def _main_func(): + caseroot = parse_input(sys.argv) + with Case(caseroot) as case: + buildnml(case, caseroot, "xrof") + +if __name__ == "__main__": + _main_func() diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml b/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml new file mode 100644 index 000000000..e1663cbbb --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml @@ -0,0 +1,39 @@ + + + + + + + Dead river component + + + + char + xrof + xrof + case_comp + env_case.xml + Name of river component + + + + char + ACTIVE,NULL + NULL + + ACTIVE + ACTIVE + + build_component_xrof + env_build.xml + mode for xrof flood feature, NULL means xrof flood is turned off + + + + + ========================================= + XROF naming conventions in compset name + ========================================= + + + diff --git a/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 new file mode 100644 index 000000000..0a50403eb --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 @@ -0,0 +1,511 @@ +module rof_comp_nuopc + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for XROF + !---------------------------------------------------------------------------- + + use ESMF + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index + use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + + implicit none + private ! except + + public :: SetServices + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + character(len=CL) :: 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 :: fldsToRof_num = 0 + integer :: fldsFrRof_num = 0 + type (fld_list_type) :: fldsToRof(fldsMax) + type (fld_list_type) :: fldsFrRof(fldsMax) + integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost + + real(r8), pointer :: gbuf(:,:) ! model info + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer , allocatable :: gindex(:) + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi + 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 + integer ,parameter :: master_task=0 ! task number of master task + logical :: mastertask + integer :: dbug = 1 + character(*),parameter :: modName = "(xrof_comp_nuopc)" + character(*),parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! 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=ModelInitPhase, 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=ModelSetRunClock, 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, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + 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 + type(ESMF_VM) :: vm + character(CS) :: stdname + integer :: n + integer :: lsize ! local array size + integer :: shrlogunit ! original log unit + character(CL) :: cvalue + character(len=CL) :: logmsg + logical :: isPresent, isSet + character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localpet=my_task, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + mastertask = my_task == master_task + + !---------------------------------------------------------------------------- + ! determine instance information + !---------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Initialize xrof + !---------------------------------------------------------------------------- + + call dead_init_nuopc('rof', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + allocate(gindex(lsize)) + allocate(lon(lsize)) + allocate(lat(lsize)) + + gindex(:) = gbuf(:,dead_grid_index) + lat(:) = gbuf(:,dead_grid_lat) + lon(:) = gbuf(:,dead_grid_lon) + + !-------------------------------- + ! advertise import and export fields + !-------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + flds_scalar_name = trim(cvalue) + call ESMF_LogWrite(trim(subname)//' flds_scalar_name = '//trim(flds_scalar_name), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldName') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldCount", 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_num + write(logmsg,*) flds_scalar_num + call ESMF_LogWrite(trim(subname)//' flds_scalar_num = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldCount') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNX", 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_nx + write(logmsg,*) flds_scalar_index_nx + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nx = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNX') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNY", 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_ny + write(logmsg,*) flds_scalar_index_ny + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_ny = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') + endif + + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrRof_num, fldsFrRof, trim(flds_scalar_name)) + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Forr_rofl') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Forr_rofi') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_flood') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_volr') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_volrmch') + + call fld_list_add(fldsToRof_num, fldsToRof, trim(flds_scalar_name)) + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofsur') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofgwl') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofsub') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofdto') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofi') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_irrig') + + do n = 1,fldsFrRof_num + if(mastertask) write(logunit,*)'Advertising From Xrof ',trim(fldsFrRof(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrRof(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + do n = 1,fldsToRof_num + if(mastertask) write(logunit,*)'Advertising To Xrof',trim(fldsToRof(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToRof(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) + + end subroutine InitializeAdvertise + + !=============================================================================== + + subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) + + ! input/output arguments + type(ESMF_GridComp) :: gcomp + type(ESMF_State) :: importState, exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + + ! local variables + type(ESMF_Mesh) :: Emesh + integer :: n + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logUnit) + + !-------------------------------- + ! generate the mesh + !-------------------------------- + + call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! realize the actively coupled fields, now that a mesh is established + ! 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 fld_list_realize( & + state=ExportState, & + fldlist=fldsFrRof, & + numflds=fldsFrRof_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':drofExport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fld_list_realize( & + state=importState, & + fldList=fldsToRof, & + numflds=fldsToRof_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':drofImport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call State_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeRealize + + !=============================================================================== + + subroutine ModelAdvance(gcomp, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + if (dbug > 5) then + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + end if + call memcheck(subname, 3, mastertask) + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetExport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call State_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (mastertask) then + call log_clock_advance(clock, 'XROF', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) then + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + end if + + end subroutine ModelAdvance + + !=============================================================================== + + subroutine state_setexport(exportState, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer, intent(out) :: rc + + ! local variables + integer :: nf, nind + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Start from index 2 in order to skip the scalar field + do nf = 2,fldsFrRof_num + if (fldsFrRof(nf)%ungridded_ubound == 0) then + call field_setexport(exportState, trim(fldsFrRof(nf)%stdname), lon, lat, nf=nf, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + do nind = 1,fldsFrRof(nf)%ungridded_ubound + call field_setexport(exportState, trim(fldsFrRof(nf)%stdname), lon, lat, nf=nf+nind-1, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + + end subroutine state_setexport + + !=============================================================================== + + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) + + use shr_const_mod , only : pi=>shr_const_pi + + ! intput/otuput variables + type(ESMF_State) , intent(inout) :: exportState + character(len=*) , intent(in) :: fldname + real(r8) , intent(in) :: lon(:) + real(r8) , intent(in) :: lat(:) + integer , intent(in) :: nf + integer, optional , intent(in) :: ungridded_index + integer , intent(out) :: rc + + ! local variables + integer :: i, ncomp + type(ESMF_Field) :: lfield + real(r8), pointer :: data1d(:) + real(r8), pointer :: data2d(:,:) + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemName=trim(fldname), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ncomp = 6 + if (present(ungridded_index)) then + call ESMF_FieldGet(lfield, farrayPtr=data2d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (gridToFieldMap == 1) then + do i = 1,size(data2d, dim=1) + data2d(i,ungridded_index) = (nf+1) * 1.0_r8 + end do + else if (gridToFieldMap == 2) then + do i = 1,size(data2d, dim=2) + data2d(ungridded_index,i) = (nf+1) * 1.0_r8 + end do + end if + else + call ESMF_FieldGet(lfield, farrayPtr=data1d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + do i = 1,size(data1d) + data1d(i) = (nf+1) * 1.0_r8 + end do + end if + + end subroutine field_setexport + + !=============================================================================== + + subroutine ModelFinalize(gcomp, rc) + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' + !------------------------------------------------------------------------------- + + !-------------------------------- + ! Finalize routine + !-------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call dead_final_nuopc('rof', logunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelFinalize + +end module rof_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 b/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 new file mode 100644 index 000000000..d8b55abd8 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 @@ -0,0 +1,840 @@ +module dead_methods_mod + + use ESMF , only : operator(<), operator(/=), operator(+) + use ESMF , only : operator(-), operator(*) , operator(>=) + use ESMF , only : operator(<=), operator(>), operator(==) + use ESMF , only : ESMF_LOGERR_PASSTHRU, ESMF_LogFoundError, ESMF_LOGMSG_ERROR, ESMF_MAXSTR + use ESMF , only : ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_FAILURE + use ESMF , only : ESMF_State, ESMF_StateGet + use ESMF , only : ESMF_Field, ESMF_FieldGet + use ESMF , only : ESMF_GridComp, ESMF_GridCompGet, ESMF_GridCompSet + use ESMF , only : ESMF_GeomType_Flag, ESMF_FieldStatus_Flag + use ESMF , only : ESMF_Mesh, ESMF_MeshGet + use ESMF , only : ESMF_GEOMTYPE_MESH, ESMF_GEOMTYPE_GRID, ESMF_FIELDSTATUS_COMPLETE + use ESMF , only : ESMF_Clock, ESMF_ClockCreate, ESMF_ClockGet, ESMF_ClockSet + use ESMF , only : ESMF_ClockPrint, ESMF_ClockAdvance + use ESMF , only : ESMF_Alarm, ESMF_AlarmCreate, ESMF_AlarmGet, ESMF_AlarmSet + use ESMF , only : ESMF_Calendar, ESMF_CALKIND_NOLEAP, ESMF_CALKIND_GREGORIAN + use ESMF , only : ESMF_Time, ESMF_TimeGet, ESMF_TimeSet + use ESMF , only : ESMF_TimeInterval, ESMF_TimeIntervalSet, ESMF_TimeIntervalGet + use ESMF , only : ESMF_VM, ESMF_VMGet, ESMF_VMBroadcast, ESMF_VMGetCurrent + use NUOPC , only : NUOPC_CompAttributeGet + use NUOPC_Model , only : NUOPC_ModelGet + use shr_kind_mod , only : r8 => shr_kind_r8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_sys_mod , only : shr_sys_abort + use shr_file_mod , only : shr_file_setlogunit, shr_file_getLogUnit + + implicit none + private + + public :: memcheck + public :: get_component_instance + public :: set_component_logging + public :: log_clock_advance + public :: state_getscalar + public :: state_setscalar + public :: state_diagnose + public :: alarmInit + public :: chkerr + + private :: timeInit + private :: field_getfldptr + + ! Clock and alarm options + character(len=*), private, parameter :: & + optNONE = "none" , & + optNever = "never" , & + optNSteps = "nsteps" , & + optNStep = "nstep" , & + optNSeconds = "nseconds" , & + optNSecond = "nsecond" , & + optNMinutes = "nminutes" , & + optNMinute = "nminute" , & + optNHours = "nhours" , & + optNHour = "nhour" , & + optNDays = "ndays" , & + optNDay = "nday" , & + optNMonths = "nmonths" , & + optNMonth = "nmonth" , & + optNYears = "nyears" , & + optNYear = "nyear" , & + optMonthly = "monthly" , & + optYearly = "yearly" , & + optDate = "date" , & + optIfdays0 = "ifdays0" + + ! Module data + integer, parameter :: SecPerDay = 86400 ! Seconds per day + integer, parameter :: memdebug_level=1 + character(len=1024) :: msgString + character(len=*), parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine memcheck(string, level, mastertask) + + ! input/output variables + character(len=*) , intent(in) :: string + integer , intent(in) :: level + logical , intent(in) :: mastertask + + ! local variables + integer :: ierr + integer, external :: GPTLprint_memusage + !----------------------------------------------------------------------- + + if ((mastertask .and. memdebug_level > level) .or. memdebug_level > level+1) then + ierr = GPTLprint_memusage(string) + endif + + end subroutine memcheck + +!=============================================================================== + + subroutine get_component_instance(gcomp, inst_suffix, inst_index, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + character(len=*) , intent(out) :: inst_suffix + integer , intent(out) :: inst_index + integer , intent(out) :: rc + + ! local variables + logical :: isPresent + character(len=4) :: cvalue + !----------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + call NUOPC_CompAttributeGet(gcomp, name="inst_suffix", isPresent=isPresent, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (isPresent) then + call NUOPC_CompAttributeGet(gcomp, name="inst_suffix", value=inst_suffix, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + cvalue = inst_suffix(2:) + read(cvalue, *) inst_index + else + inst_suffix = "" + inst_index=1 + endif + + end subroutine get_component_instance + +!=============================================================================== + + subroutine set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + logical, intent(in) :: mastertask + integer, intent(out) :: logunit + integer, intent(out) :: shrlogunit + integer, intent(out) :: rc + + ! local variables + character(len=CL) :: diro + character(len=CL) :: logfile + !----------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + shrlogunit = 6 + + if (mastertask) then + call NUOPC_CompAttributeGet(gcomp, name="diro", value=diro, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call NUOPC_CompAttributeGet(gcomp, name="logfile", value=logfile, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + open(newunit=logunit,file=trim(diro)//"/"//trim(logfile)) + else + logUnit = 6 + endif + + call shr_file_setLogUnit (logunit) + + end subroutine set_component_logging + +!=============================================================================== + + subroutine log_clock_advance(clock, component, logunit, rc) + + ! input/output variables + type(ESMF_Clock) :: clock + character(len=*) , intent(in) :: component + integer , intent(in) :: logunit + integer , intent(out) :: rc + + ! local variables + character(len=CL) :: cvalue, prestring + !----------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + write(prestring, *) "------>Advancing ",trim(component)," from: " + call ESMF_ClockPrint(clock, options="currTime", unit=cvalue, preString=trim(prestring), rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + write(logunit, *) trim(cvalue) + + call ESMF_ClockPrint(clock, options="stopTime", unit=cvalue, & + preString="--------------------------------> to: ", rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + write(logunit, *) trim(cvalue) + + end subroutine log_clock_advance + +!=============================================================================== + + subroutine state_getscalar(state, scalar_id, scalar_value, flds_scalar_name, flds_scalar_num, rc) + + ! ---------------------------------------------- + ! Get scalar data from State for a particular name and broadcast it to all other pets + ! ---------------------------------------------- + + ! input/output variables + type(ESMF_State), intent(in) :: state + integer, intent(in) :: scalar_id + real(r8), intent(out) :: scalar_value + character(len=*), intent(in) :: flds_scalar_name + integer, intent(in) :: flds_scalar_num + integer, intent(inout) :: rc + + ! local variables + integer :: mytask, ierr, len + type(ESMF_VM) :: vm + type(ESMF_Field) :: field + real(r8), pointer :: farrayptr(:,:) + real(r8) :: tmp(1) + character(len=*), parameter :: subname='(state_getscalar)' + ! ---------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_VMGetCurrent(vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localPet=mytask, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_StateGet(State, itemName=trim(flds_scalar_name), field=field, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (mytask == 0) then + call ESMF_FieldGet(field, farrayPtr = farrayptr, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (scalar_id < 0 .or. scalar_id > flds_scalar_num) then + call ESMF_LogWrite(trim(subname)//": ERROR in scalar_id", ESMF_LOGMSG_INFO, line=__LINE__, file=u_FILE_u) + rc = ESMF_FAILURE + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + endif + tmp(:) = farrayptr(scalar_id,:) + endif + call ESMF_VMBroadCast(vm, tmp, 1, 0, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + scalar_value = tmp(1) + + end subroutine state_getscalar + +!================================================================================ + + subroutine state_setscalar(scalar_value, scalar_id, State, flds_scalar_name, flds_scalar_num, rc) + + ! ---------------------------------------------- + ! Set scalar data from State for a particular name + ! ---------------------------------------------- + + ! input/output arguments + real(r8), intent(in) :: scalar_value + integer, intent(in) :: scalar_id + type(ESMF_State), intent(inout) :: State + character(len=*), intent(in) :: flds_scalar_name + integer, intent(in) :: flds_scalar_num + integer, intent(inout) :: rc + + ! local variables + integer :: mytask + type(ESMF_Field) :: lfield + type(ESMF_VM) :: vm + real(r8), pointer :: farrayptr(:,:) + character(len=*), parameter :: subname='(state_setscalar)' + ! ---------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_VMGetCurrent(vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localPet=mytask, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_StateGet(State, itemName=trim(flds_scalar_name), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (mytask == 0) then + call ESMF_FieldGet(lfield, farrayPtr = farrayptr, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (scalar_id < 0 .or. scalar_id > flds_scalar_num) then + call ESMF_LogWrite(trim(subname)//": ERROR in scalar_id", ESMF_LOGMSG_INFO) + rc = ESMF_FAILURE + return + endif + farrayptr(scalar_id,1) = scalar_value + endif + + end subroutine state_setscalar + +!=============================================================================== + + subroutine state_diagnose(State, string, rc) + + ! ---------------------------------------------- + ! Diagnose status of State + ! ---------------------------------------------- + + type(ESMF_State), intent(in) :: state + character(len=*), intent(in) :: string + integer , intent(out) :: rc + + ! local variables + integer :: i,j,n + type(ESMf_Field) :: lfield + integer :: fieldCount, lrank + character(ESMF_MAXSTR) ,pointer :: lfieldnamelist(:) + real(r8), pointer :: dataPtr1d(:) + real(r8), pointer :: dataPtr2d(:,:) + character(len=*),parameter :: subname='(state_diagnose)' + ! ---------------------------------------------- + + call ESMF_StateGet(state, itemCount=fieldCount, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + allocate(lfieldnamelist(fieldCount)) + + call ESMF_StateGet(state, itemNameList=lfieldnamelist, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + do n = 1, fieldCount + + call ESMF_StateGet(state, itemName=lfieldnamelist(n), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call field_getfldptr(lfield, fldptr1=dataPtr1d, fldptr2=dataPtr2d, rank=lrank, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (lrank == 0) then + ! no local data + elseif (lrank == 1) then + if (size(dataPtr1d) > 0) then + write(msgString,'(A,3g14.7,i8)') trim(string)//': '//trim(lfieldnamelist(n)), & + minval(dataPtr1d), maxval(dataPtr1d), sum(dataPtr1d), size(dataPtr1d) + else + write(msgString,'(A,a)') trim(string)//': '//trim(lfieldnamelist(n))," no data" + endif + elseif (lrank == 2) then + if (size(dataPtr2d) > 0) then + write(msgString,'(A,3g14.7,i8)') trim(string)//': '//trim(lfieldnamelist(n)), & + minval(dataPtr2d), maxval(dataPtr2d), sum(dataPtr2d), size(dataPtr2d) + else + write(msgString,'(A,a)') trim(string)//': '//trim(lfieldnamelist(n))," no data" + endif + else + call ESMF_LogWrite(trim(subname)//": ERROR rank not supported ", ESMF_LOGMSG_ERROR) + rc = ESMF_FAILURE + return + endif + call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) + enddo + + deallocate(lfieldnamelist) + + end subroutine state_diagnose + +!=============================================================================== + + subroutine field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) + + ! ---------------------------------------------- + ! for a field, determine rank and return fldptr1 or fldptr2 + ! abort is true by default and will abort if fldptr is not yet allocated in field + ! rank returns 0, 1, or 2. 0 means fldptr not allocated and abort=false + ! ---------------------------------------------- + + ! input/output variables + type(ESMF_Field) , intent(in) :: field + real(r8), pointer , intent(inout), optional :: fldptr1(:) + real(r8), pointer , intent(inout), optional :: fldptr2(:,:) + integer , intent(out) , optional :: rank + logical , intent(in) , optional :: abort + integer , intent(out) , optional :: rc + + ! local variables + type(ESMF_GeomType_Flag) :: geomtype + type(ESMF_FieldStatus_Flag) :: status + type(ESMF_Mesh) :: lmesh + integer :: lrank, nnodes, nelements + logical :: labort + character(len=*), parameter :: subname='(field_getfldptr)' + ! ---------------------------------------------- + + if (.not.present(rc)) then + call ESMF_LogWrite(trim(subname)//": ERROR rc not present ", & + ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) + rc = ESMF_FAILURE + return + endif + + rc = ESMF_SUCCESS + + labort = .true. + if (present(abort)) then + labort = abort + endif + lrank = -99 + + call ESMF_FieldGet(field, status=status, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (status /= ESMF_FIELDSTATUS_COMPLETE) then + lrank = 0 + if (labort) then + call ESMF_LogWrite(trim(subname)//": ERROR data not allocated ", ESMF_LOGMSG_INFO, rc=rc) + rc = ESMF_FAILURE + return + else + call ESMF_LogWrite(trim(subname)//": WARNING data not allocated ", ESMF_LOGMSG_INFO, rc=rc) + endif + else + + call ESMF_FieldGet(field, geomtype=geomtype, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (geomtype == ESMF_GEOMTYPE_GRID) then + call ESMF_FieldGet(field, rank=lrank, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + elseif (geomtype == ESMF_GEOMTYPE_MESH) then + call ESMF_FieldGet(field, rank=lrank, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldGet(field, mesh=lmesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_MeshGet(lmesh, numOwnedNodes=nnodes, numOwnedElements=nelements, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (nnodes == 0 .and. nelements == 0) lrank = 0 + else + call ESMF_LogWrite(trim(subname)//": ERROR geomtype not supported ", & + ESMF_LOGMSG_INFO, rc=rc) + rc = ESMF_FAILURE + return + endif ! geomtype + + if (lrank == 0) then + call ESMF_LogWrite(trim(subname)//": no local nodes or elements ", & + ESMF_LOGMSG_INFO) + elseif (lrank == 1) then + if (.not.present(fldptr1)) then + call ESMF_LogWrite(trim(subname)//": ERROR missing rank=1 array ", & + ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) + rc = ESMF_FAILURE + return + endif + call ESMF_FieldGet(field, farrayPtr=fldptr1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + elseif (lrank == 2) then + if (.not.present(fldptr2)) then + call ESMF_LogWrite(trim(subname)//": ERROR missing rank=2 array ", & + ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) + rc = ESMF_FAILURE + return + endif + call ESMF_FieldGet(field, farrayPtr=fldptr2, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + call ESMF_LogWrite(trim(subname)//": ERROR in rank ", & + ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) + rc = ESMF_FAILURE + return + endif + + endif ! status + + if (present(rank)) then + rank = lrank + endif + + end subroutine field_getfldptr + +!=============================================================================== + + subroutine alarmInit( clock, alarm, option, & + opt_n, opt_ymd, opt_tod, RefTime, alarmname, rc) + + ! Setup an alarm in a clock + ! Notes: The ringtime sent to AlarmCreate MUST be the next alarm + ! time. If you send an arbitrary but proper ringtime from the + ! past and the ring interval, the alarm will always go off on the + ! next clock advance and this will cause serious problems. Even + ! if it makes sense to initialize an alarm with some reference + ! time and the alarm interval, that reference time has to be + ! advance forward to be >= the current time. In the logic below + ! we set an appropriate "NextAlarm" and then we make sure to + ! advance it properly based on the ring interval. + + ! input/output variables + type(ESMF_Clock) , intent(inout) :: clock ! clock + type(ESMF_Alarm) , intent(inout) :: alarm ! alarm + character(len=*) , intent(in) :: option ! alarm option + integer , optional , intent(in) :: opt_n ! alarm freq + integer , optional , intent(in) :: opt_ymd ! alarm ymd + integer , optional , intent(in) :: opt_tod ! alarm tod (sec) + type(ESMF_Time) , optional , intent(in) :: RefTime ! ref time + character(len=*) , optional , intent(in) :: alarmname ! alarm name + integer , intent(inout) :: rc ! Return code + + ! local variables + type(ESMF_Calendar) :: cal ! calendar + integer :: lymd ! local ymd + integer :: ltod ! local tod + integer :: cyy,cmm,cdd,csec ! time info + character(len=64) :: lalarmname ! local alarm name + logical :: update_nextalarm ! update next alarm + type(ESMF_Time) :: CurrTime ! Current Time + type(ESMF_Time) :: NextAlarm ! Next restart alarm time + type(ESMF_TimeInterval) :: AlarmInterval ! Alarm interval + integer :: sec + character(len=*), parameter :: subname = '(set_alarmInit): ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + lalarmname = 'alarm_unknown' + if (present(alarmname)) lalarmname = trim(alarmname) + ltod = 0 + if (present(opt_tod)) ltod = opt_tod + lymd = -1 + if (present(opt_ymd)) lymd = opt_ymd + + call ESMF_ClockGet(clock, CurrTime=CurrTime, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_TimeGet(CurrTime, yy=cyy, mm=cmm, dd=cdd, s=csec, rc=rc ) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! initial guess of next alarm, this will be updated below + if (present(RefTime)) then + NextAlarm = RefTime + else + NextAlarm = CurrTime + endif + + ! Determine calendar + call ESMF_ClockGet(clock, calendar=cal) + + ! Determine inputs for call to create alarm + selectcase (trim(option)) + + case (optNONE) + call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_TimeSet( NextAlarm, yy=9999, mm=12, dd=1, s=0, calendar=cal, rc=rc ) + if (chkerr(rc,__LINE__,u_FILE_u)) return + update_nextalarm = .false. + + case (optNever) + call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_TimeSet( NextAlarm, yy=9999, mm=12, dd=1, s=0, calendar=cal, rc=rc ) + if (chkerr(rc,__LINE__,u_FILE_u)) return + update_nextalarm = .false. + + case (optDate) + if (.not. present(opt_ymd)) then + call shr_sys_abort(subname//trim(option)//' requires opt_ymd') + end if + if (lymd < 0 .or. ltod < 0) then + call shr_sys_abort(subname//trim(option)//'opt_ymd, opt_tod invalid') + end if + call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call timeInit(NextAlarm, lymd, cal, ltod, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + update_nextalarm = .false. + + case (optIfdays0) + if (.not. present(opt_ymd)) then + call shr_sys_abort(subname//trim(option)//' requires opt_ymd') + end if + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_TimeSet( NextAlarm, yy=cyy, mm=cmm, dd=opt_n, s=0, calendar=cal, rc=rc ) + if (chkerr(rc,__LINE__,u_FILE_u)) return + update_nextalarm = .true. + + case (optNSteps) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNStep) + if (.not.present(opt_n)) call shr_sys_abort(subname//trim(option)//' requires opt_n') + if (opt_n <= 0) call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNSeconds) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNSecond) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNMinutes) + call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNMinute) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNHours) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNHour) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNDays) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNDay) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNMonths) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNMonth) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optMonthly) + call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_TimeSet( NextAlarm, yy=cyy, mm=cmm, dd=1, s=0, calendar=cal, rc=rc ) + if (chkerr(rc,__LINE__,u_FILE_u)) return + update_nextalarm = .true. + + case (optNYears) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNYear) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optYearly) + call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_TimeSet( NextAlarm, yy=cyy, mm=1, dd=1, s=0, calendar=cal, rc=rc ) + if (chkerr(rc,__LINE__,u_FILE_u)) return + update_nextalarm = .true. + + case default + call shr_sys_abort(subname//'unknown option '//trim(option)) + + end select + + ! -------------------------------------------------------------------------------- + ! --- AlarmInterval and NextAlarm should be set --- + ! -------------------------------------------------------------------------------- + + ! --- advance Next Alarm so it won't ring on first timestep for + ! --- most options above. go back one alarminterval just to be careful + + if (update_nextalarm) then + NextAlarm = NextAlarm - AlarmInterval + do while (NextAlarm <= CurrTime) + NextAlarm = NextAlarm + AlarmInterval + enddo + endif + + alarm = ESMF_AlarmCreate( name=lalarmname, clock=clock, ringTime=NextAlarm, & + ringInterval=AlarmInterval, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + end subroutine alarmInit + +!=============================================================================== + + subroutine timeInit( Time, ymd, cal, tod, rc) + + ! Create the ESMF_Time object corresponding to the given input time, + ! given in YMD (Year Month Day) and TOD (Time-of-day) format. + ! Set the time by an integer as YYYYMMDD and integer seconds in the day + + ! input/output parameters: + type(ESMF_Time) , intent(inout) :: Time ! ESMF time + integer , intent(in) :: ymd ! year, month, day YYYYMMDD + type(ESMF_Calendar) , intent(in) :: cal ! ESMF calendar + integer , intent(in) :: tod ! time of day in seconds + integer , intent(out) :: rc + + ! local variables + integer :: year, mon, day ! year, month, day as integers + integer :: tdate ! temporary date + integer :: date ! coded-date (yyyymmdd) + character(len=*), parameter :: subname='(timeInit)' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + if ( (ymd < 0) .or. (tod < 0) .or. (tod > SecPerDay) )then + call shr_sys_abort( subname//'ERROR yymmdd is a negative number or time-of-day out of bounds' ) + end if + + tdate = abs(date) + year = int(tdate/10000) + if (date < 0) year = -year + mon = int( mod(tdate,10000)/ 100) + day = mod(tdate, 100) + + call ESMF_TimeSet( Time, yy=year, mm=mon, dd=day, s=tod, calendar=cal, rc=rc ) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + end subroutine timeInit + +!=============================================================================== + + logical function chkerr(rc, line, file) + + integer, intent(in) :: rc + integer, intent(in) :: line + character(len=*), intent(in) :: file + + integer :: lrc + + chkerr = .false. + lrc = rc + if (ESMF_LogFoundError(rcToCheck=lrc, msg=ESMF_LOGERR_PASSTHRU, line=line, file=file)) then + chkerr = .true. + endif + end function chkerr + +!=============================================================================== + +end module dead_methods_mod diff --git a/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 b/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 new file mode 100644 index 000000000..981113760 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 @@ -0,0 +1,907 @@ +module dead_nuopc_mod + + use ESMF , only : ESMF_Gridcomp, ESMF_State, ESMF_StateGet + use ESMF , only : ESMF_Clock, ESMF_Time, ESMF_TimeInterval, ESMF_Alarm + use ESMF , only : ESMF_GridCompGet, ESMF_ClockGet, ESMF_ClockSet, ESMF_ClockAdvance, ESMF_AlarmSet + use ESMF , only : ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_METHOD_INITIALIZE + use ESMF , only : ESMF_FAILURE, ESMF_LOGMSG_ERROR + use ESMF , only : ESMF_VMGetCurrent, ESMF_VM, ESMF_VMBroadcast, ESMF_VMGet + use ESMF , only : ESMF_VM, ESMF_VMGetCurrent, ESMF_VmGet + use ESMF , only : operator(/=), operator(==), operator(+) + 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 dead_methods_mod , only : chkerr, alarmInit + + implicit none + private + + public :: dead_init_nuopc + public :: dead_final_nuopc + public :: dead_meshinit + public :: ModelInitPhase + public :: ModelSetRunClock + public :: fld_list_add + public :: fld_list_realize + + ! !PUBLIC DATA MEMBERS: + integer, public :: dead_grid_lat = 1 ! lat from component + integer, public :: dead_grid_lon = 2 ! lon from component + integer, public :: dead_grid_area = 3 ! area from component + integer, public :: dead_grid_mask = 4 ! mask, 0 = inactive cell + integer, public :: dead_grid_frac = 5 ! fractional area coverage + integer, public :: dead_grid_index = 6 ! global index + integer, public :: dead_grid_total = 6 + + type fld_list_type + character(len=128) :: stdname + integer :: ungridded_lbound = 0 + integer :: ungridded_ubound = 0 + end type fld_list_type + public :: fld_list_type + + integer, parameter, public :: fldsMax = 100 + integer :: dbug_flag = 0 + character(*), parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine dead_read_inparms(model, inst_suffix, logunit, & + nxg, nyg, decomp_type, nproc_x, seg_len) + + ! input/output variables + character(len=*) , intent(in) :: model + character(len=*) , intent(in) :: inst_suffix ! char string associated with instance + integer , intent(in) :: logunit ! logging unit number + integer , intent(out) :: nproc_x + integer , intent(out) :: seg_len + integer , intent(out) :: nxg ! global dim i-direction + integer , intent(out) :: nyg ! global dim j-direction + integer , intent(out) :: decomp_type ! decomposition type + + ! local variables + type(ESMF_VM) :: vm + character(CL) :: fileName ! generic file name + integer :: nunit ! unit number + integer :: unitn ! Unit for namelist file + integer :: tmp(5) ! array for broadcast + integer :: localPet ! mpi id of current task in current context + integer :: rc ! return code + character(*), parameter :: F00 = "('(dead_read_inparms) ',8a)" + character(*), parameter :: F01 = "('(dead_read_inparms) ',a,a,4i8)" + character(*), parameter :: F03 = "('(dead_read_inparms) ',a,a,i8,a)" + character(*), parameter :: subName = "(dead_read_inpamrs) " + !------------------------------------------------------------------------------- + + ! read the input parms (used to configure model) + nxg = -9999 + nyg = -9999 + nproc_x = -9999 + seg_len = -9999 + decomp_type = -9999 + + call ESMF_VMGetCurrent(vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMGet(vm, localPet=localPet, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (localPet==0) then + open(newunit=unitn, file='x'//model//'_in'//trim(inst_suffix), status='old' ) + read(unitn,*) nxg + read(unitn,*) nyg + read(unitn,*) decomp_type + read(unitn,*) nproc_x + read(unitn,*) seg_len + close (unitn) + endif + + tmp(1) = nxg + tmp(2) = nyg + tmp(3) = decomp_type + tmp(4) = nproc_x + tmp(5) = seg_len + + call ESMF_VMBroadcast(vm, tmp, 6, 0, rc=rc) + + nxg = tmp(1) + nyg = tmp(2) + decomp_type = tmp(3) + nproc_x = tmp(4) + seg_len = tmp(5) + + if (localPet==0) then + write(logunit,*)' Read in X'//model//' input from file= x'//model//'_in' + write(logunit,F00) model + write(logunit,F00) model,' Model : ',model + write(logunit,F01) model,' NGX : ',nxg + write(logunit,F01) model,' NGY : ',nyg + write(logunit,F01) model,' Decomposition : ',decomp_type + write(logunit,F03) model,' Num pes in X : ',nproc_x,' (type 3 only)' + write(logunit,F03) model,' Segment Length : ',seg_len,' (type 11 only)' + write(logunit,F00) model,' inst_suffix : ',trim(inst_suffix) + write(logunit,F00) model + end if + + end subroutine dead_read_inparms + + !=============================================================================== + + subroutine dead_setNewGrid(decomp_type, nxg, nyg, logunit, lsize, gbuf, seg_len, nproc_x) + + ! This sets up some defaults. The user may want to overwrite some + ! of these fields in the main program after initialization in complete. + + use shr_const_mod , only : shr_const_pi, shr_const_rearth + + ! input/output parameters: + integer , intent(in) :: decomp_type ! + integer , intent(in) :: nxg,nyg ! global grid sizes + integer , intent(in) :: logunit ! output logunit + integer , intent(out) :: lsize ! local grid sizes + real(R8), pointer :: gbuf(:,:) ! output data + integer , intent(in),optional :: seg_len ! seg len decomp setting + integer , intent(in),optional :: nproc_x ! 2d decomp setting + + ! local + type(ESMF_VM) :: vm + integer :: rc + integer :: mype + integer :: totpe ! total number of pes + logical :: found + integer :: i,j,ig,jg + integer :: n,ng,is,ie,js,je,nx,ny + integer :: npesx,npesy,mypex,mypey,nxp,nyp + real(R8) :: hscore,bscore + real(R8) :: dx,dy,deg2rad,ys,yc,yn,area,re + integer, allocatable :: gindex(:) + character(*), parameter :: F00 = "('(dead_setNewGrid) ',8a)" + character(*), parameter :: F01 = "('(dead_setNewGrid) ',a,4i8)" + character(*), parameter :: subName = "(dead_setNewGrid) " + !------------------------------------------------------------------------------- + + call ESMF_VMGetCurrent(vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMGet(vm, localPet=mype, peCount=totpe, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if ( decomp_type == 1 .or. & + decomp_type == 2 .or. & + decomp_type == 3 .or. & + decomp_type == 4 .or. & + decomp_type == 11) then + else + ! invalid decomposition type + if (mype == 0) then + write(logunit,F01) 'ERROR: invalid decomp_type = ',decomp_type + end if + call shr_sys_abort(subName//'invalid decomp_type') + endif + + if (nxg*nyg == 0) then + lsize = 0 + allocate(gbuf(lsize,dead_grid_total)) + if (mype == 0) then + write(logunit,*) subname,' grid size is zero, lsize = ',lsize + end if + return + endif + + found = .false. + + if (decomp_type == 1) then ! 1d decomp by lat + npesx = 1 + npesy = totpe + found = .true. + elseif (decomp_type == 2) then ! 1d decomp by lon + npesx = totpe + npesy = 1 + found = .true. + elseif (decomp_type == 3) then ! 2d decomp + if (present(nproc_x)) then + if ( nproc_x > 0 ) then + npesx=nproc_x + npesy=totpe/npesx + if ( npesx*npesy /= totpe) then + write(logunit,F00) 'ERROR: uneven decomposition' + call shr_sys_abort(subName//'uneven decomp') + end if + found = .true. + endif + endif + if (.not.found) then ! narrow blocks + do nx = 1,totpe + ny = totpe/nx + if (nx*ny == totpe) then + npesx = nx + npesy = ny + found = .true. + endif + enddo + endif + elseif (decomp_type == 4) then ! 2d evenly divisible square block decomp + hscore = nxg*nyg + do nx = 1,totpe + ny = totpe/nx + if (nx*ny == totpe .and. mod(nxg,nx) == 0 .and. mod(nyg,ny) == 0) then + bscore = ((nxg*ny*1.0_r8) / (nyg*nx*1.0_r8)) - 1.0_r8 + bscore = bscore * bscore + if (bscore < hscore .or. .not.found) then + hscore = bscore + npesx = nx + npesy = ny + found = .true. + endif + endif + enddo + endif + + if (found) then + nx = nxg/npesx + mypex = mod(mype,npesx) + mypey = mype/npesx + is = (mypex ) * (nx) + 1 + ie = (mypex + 1) * (nx) + + ny = nyg/npesy + js = (mypey ) * (ny) + 1 + je = (mypey + 1) * (ny) + + nxp = nxg - (nx*npesx) ! extra lons not accounted for yet + nyp = nyg - (ny*npesy) ! extra lats not accounted for yet + + is = is + min(mypex,nxp) ! add them to first few pes and shift everything + ie = ie + min(mypex+1,nxp) + js = js + min(mypey,nyp) ! add them to first few pes and shift everything + je = je + min(mypey+1,nyp) + + lsize = (ie - is + 1) * (je - js + 1) + + allocate(gindex(lsize)) + n = 0 + do j = js,je + do i = is,ie + n = n + 1 + gindex(n) = (j-1)*nxg + i + enddo + enddo + endif + + if (.not.found) then + !------------------------------------------------------------------------- + ! type 11 general segment decomp + !------------------------------------------------------------------------- + nx = nxg*nyg / (totpe*13) + 1 ! 13 segments per pe (arbitrary) + ! nx override with seg_len + if (present(seg_len)) then + if (seg_len > 0) nx = seg_len + endif + + n = 0 + i = 0 + lsize = 0 + do while (n < nxg*nyg) + ny = min(nx,nxg*nyg-n) + do j = 1,ny + n = n + 1 + if (mype == mod(i,totpe)) then + lsize = lsize + 1 + endif + enddo + i = i + 1 + enddo + + allocate(gindex(lsize)) + + n = 0 + i = 0 + lsize = 0 + do while (n < nxg*nyg) + ny = min(nx,nxg*nyg-n) + do j = 1,ny + n = n + 1 + if (mype == mod(i,totpe)) then + lsize = lsize + 1 + gindex(lsize) = n + endif + enddo + i = i + 1 + enddo + + if (mype == 0) then + write(logunit,*) 'dead_setNewGrid decomp seg ',mype,lsize,nx + end if + + found = .true. + + endif + + if ( .not.found ) then + write(logunit,F01) 'ERROR: with decomp nxg,nyg,totpe=',nxg,nyg,totpe + call shr_sys_abort(subName//'decomp') + endif + + deg2rad = shr_const_pi / 180.0_R8 + re = shr_const_rearth + + allocate(gbuf(lsize,dead_grid_total)) + gbuf = -888.0_R8 + if (mype == 0) then + write(logunit,*) subname,' Decomp is ',decomp_type,' lsize = ',lsize + end if + + n=0 + dx = 360.0_R8/nxg * deg2rad + do n = 1,lsize + ig = mod((gindex(n)-1),nxg) + 1 + jg = (gindex(n)-1)/nxg + 1 + + ys = -90.0_R8 + (jg-1.0_R8)*180.0_R8/(nyg) + yc = -90.0_R8 + (jg-0.5_R8)*180.0_R8/(nyg) + yn = -90.0_R8 + (jg-0.0_R8)*180.0_R8/(nyg) + dy = sin(yn*deg2rad) - sin(ys*deg2rad) + area = dx*dy*re*re + + gbuf(n,dead_grid_lon ) = (ig-1.0_R8)*360.0_R8/(nxg) + gbuf(n,dead_grid_lat ) = yc + gbuf(n,dead_grid_index) = gindex(n) + gbuf(n,dead_grid_area ) = area + gbuf(n,dead_grid_mask ) = 0 + gbuf(n,dead_grid_frac ) = 1.0_R8 + enddo + + deallocate(gindex) + + end subroutine dead_setNewGrid + + !=============================================================================== + + subroutine dead_init_nuopc(model, inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + ! input/output parameters: + character(len=*) , intent(in) :: model + character(len=*) , intent(in) :: inst_suffix ! char string associated with instance + integer , intent(in) :: logunit ! logging unit number + integer , intent(out) :: lsize ! logging unit number + real(r8) , pointer :: gbuf(:,:) ! model grid + integer , pointer :: gindex(:) ! global index space + integer , intent(out) :: nxg ! global dim i-direction + integer , intent(out) :: nyg ! global dim j-direction + + !--- local variables --- + integer :: local_comm ! local communicator + integer :: nproc_x + integer :: seg_len + integer :: decomp_type + character(*), parameter :: subName = "(dead_init_nuopc) " + !------------------------------------------------------------------------------- + + ! Read input parms + call dead_read_inparms(model, inst_suffix, logunit, nxg, nyg, decomp_type, nproc_x, seg_len) + + ! Initialize grid + call dead_setNewGrid(decomp_type, nxg, nyg, logunit, lsize, gbuf, seg_len, nproc_x) + + end subroutine dead_init_nuopc + + !=============================================================================== + + subroutine dead_final_nuopc(model, logunit) + + ! finalize method for xcpl component + + ! input/output parameters: + character(len=*) , intent(in) :: model + integer , intent(in) :: logunit ! logging unit number + + ! local variables + type(ESMF_VM) :: vm + integer :: rc + integer :: localPet + character(*), parameter :: F00 = "('(dead_comp_final) ',8a)" + character(*), parameter :: F91 = "('(dead_comp_final) ',73('-'))" + character(*), parameter :: subName = "(dead_comp_final) " + !------------------------------------------------------------------------------- + + call ESMF_VMGetCurrent(vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMGet(vm, localPet=localPet, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (localPet==0) then + write(logunit,F91) + write(logunit,F00) trim(model),': end of main integration loop' + write(logunit,F91) + end if + + end subroutine dead_final_nuopc + + !=============================================================================== + + subroutine fld_list_add(num, fldlist, stdname, ungridded_lbound, ungridded_ubound) + + ! input/output variables + integer , intent(inout) :: num + type(fld_list_type) , intent(inout) :: fldlist(:) + character(len=*) , intent(in) :: stdname + integer, optional , intent(in) :: ungridded_lbound + integer, optional , intent(in) :: ungridded_ubound + + ! local variables + character(len=*), parameter :: subname='(dead_nuopc_mod:fld_list_add)' + !------------------------------------------------------------------------------- + + ! Set up a list of field information + num = num + 1 + if (num > fldsMax) then + call ESMF_LogWrite(trim(subname)//": ERROR num > fldsMax "//trim(stdname), & + ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__) + return + endif + fldlist(num)%stdname = trim(stdname) + + if (present(ungridded_lbound) .and. present(ungridded_ubound)) then + fldlist(num)%ungridded_lbound = ungridded_lbound + fldlist(num)%ungridded_ubound = ungridded_ubound + end if + + end subroutine fld_list_add + + !=============================================================================== + + subroutine fld_list_realize(state, fldList, numflds, flds_scalar_name, flds_scalar_num, mesh, tag, rc) + + use NUOPC , only : NUOPC_IsConnected, NUOPC_Realize + use ESMF , only : ESMF_MeshLoc_Element, ESMF_FieldCreate, ESMF_TYPEKIND_R8 + use ESMF , only : ESMF_MAXSTR, ESMF_Field, ESMF_State, ESMF_Mesh, ESMF_StateRemove + use ESMF , only : ESMF_LogFoundError, ESMF_LOGMSG_INFO, ESMF_SUCCESS + use ESMF , only : ESMF_LogWrite, ESMF_LOGMSG_ERROR, ESMF_LOGERR_PASSTHRU + + type(ESMF_State) , intent(inout) :: state + type(fld_list_type) , intent(in) :: fldList(:) + integer , intent(in) :: numflds + character(len=*) , intent(in) :: flds_scalar_name + integer , intent(in) :: flds_scalar_num + character(len=*) , intent(in) :: tag + type(ESMF_Mesh) , intent(in) :: mesh + integer , intent(inout) :: rc + + ! local variables + integer :: n + type(ESMF_Field) :: field + character(len=80) :: stdname + integer :: gridtoFieldMap=2 + character(len=*),parameter :: subname='(dead_nuopc_mod:fld_list_realize)' + ! ---------------------------------------------- + + rc = ESMF_SUCCESS + + do n = 1, numflds + stdname = fldList(n)%stdname + if (NUOPC_IsConnected(state, fieldName=stdname)) then + if (stdname == trim(flds_scalar_name)) then + call ESMF_LogWrite(trim(subname)//trim(tag)//" Field = "//trim(stdname)//" is connected on root pe", & + ESMF_LOGMSG_INFO) + ! Create the scalar field + call SetScalarField(field, flds_scalar_name, flds_scalar_num, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + else + call ESMF_LogWrite(trim(subname)//trim(tag)//" Field = "//trim(stdname)//" is connected using mesh", & + ESMF_LOGMSG_INFO) + ! Create the field + if (fldlist(n)%ungridded_lbound > 0 .and. fldlist(n)%ungridded_ubound > 0) then + field = ESMF_FieldCreate(mesh, ESMF_TYPEKIND_R8, name=stdname, meshloc=ESMF_MESHLOC_ELEMENT, & + ungriddedLbound=(/fldlist(n)%ungridded_lbound/), & + ungriddedUbound=(/fldlist(n)%ungridded_ubound/), & + gridToFieldMap=(/gridToFieldMap/), rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + field = ESMF_FieldCreate(mesh, ESMF_TYPEKIND_R8, name=stdname, meshloc=ESMF_MESHLOC_ELEMENT, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + end if + endif + + ! NOW call NUOPC_Realize + call NUOPC_Realize(state, field=field, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + else + if (stdname /= trim(flds_scalar_name)) then + call ESMF_LogWrite(subname // trim(tag) // " Field = "// trim(stdname) // " is not connected.", & + ESMF_LOGMSG_INFO) + call ESMF_StateRemove(state, (/stdname/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + end if + end if + end do + + contains !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + subroutine SetScalarField(field, flds_scalar_name, flds_scalar_num, rc) + ! ---------------------------------------------- + ! create a field with scalar data on the root pe + ! ---------------------------------------------- + + use ESMF, only : ESMF_Field, ESMF_DistGrid, ESMF_Grid + use ESMF, only : ESMF_DistGridCreate, ESMF_GridCreate, ESMF_LogFoundError, ESMF_LOGERR_PASSTHRU + use ESMF, only : ESMF_FieldCreate, ESMF_GridCreate, ESMF_TYPEKIND_R8 + + type(ESMF_Field) , intent(inout) :: field + character(len=*) , intent(in) :: flds_scalar_name + integer , intent(in) :: flds_scalar_num + integer , intent(inout) :: rc + + ! local variables + type(ESMF_Distgrid) :: distgrid + type(ESMF_Grid) :: grid + character(len=*), parameter :: subname='(dead_nuopc_mod:SetScalarField)' + ! ---------------------------------------------- + + rc = ESMF_SUCCESS + + ! create a DistGrid with a single index space element, which gets mapped onto DE 0. + distgrid = ESMF_DistGridCreate(minIndex=(/1/), maxIndex=(/1/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + + grid = ESMF_GridCreate(distgrid, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + + field = ESMF_FieldCreate(name=trim(flds_scalar_name), grid=grid, typekind=ESMF_TYPEKIND_R8, & + ungriddedLBound=(/1/), ungriddedUBound=(/flds_scalar_num/), gridToFieldMap=(/2/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + + end subroutine SetScalarField + + end subroutine fld_list_realize + + !=============================================================================== + + subroutine ModelInitPhase(gcomp, importState, exportState, clock, rc) + + use NUOPC, only : NUOPC_CompFilterPhaseMap + + type(ESMF_GridComp) :: gcomp + type(ESMF_State) :: importState, exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Switch to IPDv01 by filtering all other phaseMap entries + call NUOPC_CompFilterPhaseMap(gcomp, ESMF_METHOD_INITIALIZE, acceptStringList=(/"IPDv01p"/), rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + end subroutine ModelInitPhase + + !=============================================================================== + + subroutine ModelSetRunClock(gcomp, rc) + + use ESMF , only : ESMF_ClockGetAlarmList, ESMF_ALARMLIST_ALL + use NUOPC_Model , only : NUOPC_ModelGet + use NUOPC , only : NUOPC_CompAttributeGet + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: mclock, dclock + type(ESMF_Time) :: mcurrtime, dcurrtime + type(ESMF_Time) :: mstoptime + type(ESMF_TimeInterval) :: mtimestep, dtimestep + character(len=256) :: cvalue + character(len=256) :: restart_option ! Restart option units + integer :: restart_n ! Number until restart interval + integer :: restart_ymd ! Restart date (YYYYMMDD) + type(ESMF_ALARM) :: restart_alarm + character(len=128) :: name + integer :: alarmcount + character(len=*),parameter :: subname='dead_nuopc_mod:(ModelSetRunClock) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug_flag > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO) + + ! query the Component for its clocks + call NUOPC_ModelGet(gcomp, driverClock=dclock, modelClock=mclock, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_ClockGet(dclock, currTime=dcurrtime, timeStep=dtimestep, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_ClockGet(mclock, currTime=mcurrtime, timeStep=mtimestep, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! force model clock currtime and timestep to match driver and set stoptime + !-------------------------------- + + mstoptime = mcurrtime + dtimestep + call ESMF_ClockSet(mclock, currTime=dcurrtime, timeStep=dtimestep, stopTime=mstoptime, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! set restart alarm + !-------------------------------- + + call ESMF_ClockGetAlarmList(mclock, alarmlistflag=ESMF_ALARMLIST_ALL, alarmCount=alarmCount, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (alarmCount == 0) then + + call ESMF_GridCompGet(gcomp, name=name, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_LogWrite(subname//'setting alarms for' // trim(name), ESMF_LOGMSG_INFO) + + call NUOPC_CompAttributeGet(gcomp, name="restart_option", value=restart_option, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call NUOPC_CompAttributeGet(gcomp, name="restart_n", value=cvalue, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) restart_n + + call NUOPC_CompAttributeGet(gcomp, name="restart_ymd", value=cvalue, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) restart_ymd + + call alarmInit(mclock, restart_alarm, restart_option, & + opt_n = restart_n, & + opt_ymd = restart_ymd, & + RefTime = mcurrTime, & + alarmname = 'alarm_restart', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_AlarmSet(restart_alarm, clock=mclock, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + end if + + !-------------------------------- + ! Advance model clock to trigger alarms then reset model clock back to currtime + !-------------------------------- + + call ESMF_ClockAdvance(mclock,rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_ClockSet(mclock, currTime=dcurrtime, timeStep=dtimestep, stopTime=mstoptime, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (dbug_flag > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO) + + end subroutine ModelSetRunClock + + !=============================================================================== + + subroutine dead_meshinit(gcomp, nx_global, ny_global, gindex, lon, lat, Emesh, rc) + + !----------------------------------------- + ! create an Emesh object for Fields + !----------------------------------------- + + use ESMF , only : ESMF_GridComp, ESMF_VM, ESMF_Mesh + use ESMF , only : ESMF_VMGet, ESMF_GridCompGet, ESMF_VMBroadCast, ESMF_VMAllGatherV + use ESMF , only : ESMF_SUCCESS, ESMF_LOGMSG_INFO, ESMF_LogWrite + use ESMF , only : ESMF_VMGather, ESMF_LogFoundError, ESMF_LOGERR_PASSTHRU + use ESMF , only : ESMF_MeshCreate, ESMF_COORDSYS_SPH_DEG, ESMF_REDUCE_SUM + use ESMF , only : ESMF_VMAllReduce, ESMF_MESHELEMTYPE_QUAD + + ! input/output arguments + type(ESMF_GridComp) :: gcomp + integer , intent(in) :: nx_global + integer , intent(in) :: ny_global + integer , intent(in) :: gindex(:) + real(r8), pointer , intent(in) :: lon(:) + real(r8), pointer , intent(in) :: lat(:) + type(ESMF_Mesh) , intent(inout) :: Emesh + integer , intent(inout) :: rc + + ! local variables + integer :: n,n1,n2,de + integer :: iam + integer :: lsize + integer :: numTotElems, numNodes, numConn, nodeindx + integer :: iur,iul,ill,ilr + integer :: xid, yid, xid0, yid0 + real(r8) :: lonur, lonul, lonll, lonlr + integer, pointer :: iurpts(:) + integer, pointer :: elemIds(:) + integer, pointer :: elemTypes(:) + integer, pointer :: elemConn(:) + real(r8),pointer :: elemCoords(:) + integer, pointer :: nodeIds(:) + integer, pointer :: nodeOwners(:) + real(r8),pointer :: nodeCoords(:) + real(r8),pointer :: latG(:) + real(r8),pointer :: lonG(:) + integer ,pointer :: pes_local(:) + integer ,pointer :: pes_global(:) + integer, pointer :: recvOffsets(:) + integer, pointer :: recvCounts(:) + integer :: sendData(1) + type(ESMF_VM) :: vm + integer :: petCount + character(len=*),parameter :: subname='(dead_MeshInit)' + !-------------------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_LogWrite(subname, ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + lsize = size(gindex) + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, petCount=petCount, localpet=iam, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + allocate(latG(nx_global*ny_global)) + allocate(lonG(nx_global*ny_global)) + + allocate(recvoffsets(petCount)) + allocate(recvCounts(petCount)) + + sendData(1) = lsize + call ESMF_VMGather(vm, sendData=sendData, recvData=recvCounts, count=1, rootPet=0, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMBroadCast(vm, bcstData=recvCounts, count=petCount, rootPet=0, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + recvoffsets(1) = 0 + do n = 2,petCount + recvoffsets(n) = recvoffsets(n-1) + recvCounts(n-1) + end do + + call ESMF_VMAllGatherV(vm, lat, lsize, latG, recvCounts, recvOffsets, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMAllGatherV(vm, lon, lsize, lonG, recvCounts, recvOffsets, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + deallocate(recvoffsets) + deallocate(recvCounts) + + ! assumes quadrilaterals for each gridcell (element) + ! element index matches gsmap index value + ! nodeid at lower left of each gridcell matches gsmap index value + ! assumes wrap around in x direction but no wrap in y direction + ! node ids need to be described in counter clockwise direction + ! node id associated with lower left cell is assigned to local PET + ! node ids at top of y boundary assigned to the element to the right + + numTotElems = lsize + + allocate(elemIds(numTotElems)) + allocate(elemTypes(numTotElems)) + elemTypes=(/ESMF_MESHELEMTYPE_QUAD/) + allocate(elemConn(4*numTotElems)) + allocate(elemCoords(2*numTotElems)) + + allocate(nodeIds(numTotElems*4)) + nodeIds = -99 + + elemIds(:) = gindex(:) + numNodes = 0 + numConn = 0 + + do n = 1,numTotElems + elemTypes(n) = ESMF_MESHELEMTYPE_QUAD + elemCoords(2*n-1) = lon(n) + elemCoords(2*n) = lat(n) + + do n1 = 1,4 + + numNodes = numNodes + 1 + nodeindx = numNodes + if (n1 == 1 .or. n1 == 3) xid = mod(elemIds(n)-1,nx_global) + 1 + if (n1 == 2 .or. n1 == 4) xid = mod(elemIds(n) ,nx_global) + 1 + if (n1 == 1 .or. n1 == 2) yid = (elemIds(n)-1)/nx_global + 1 + if (n1 == 3 .or. n1 == 4) yid = (elemIds(n)-1)/nx_global + 2 + nodeIds(numNodes) = (yid-1) * nx_global + xid + n2 = 0 + do while (n2 < numNodes - 1 .and. nodeindx == numNodes) + n2 = n2 + 1 + if (nodeIds(numNodes) == nodeIds(n2)) nodeindx = n2 + enddo + if (nodeindx /= numNodes) then + numNodes = numNodes - 1 + endif + + numConn = numConn + 1 + elemConn(numConn) = nodeindx + enddo + enddo + + + allocate(nodeCoords(2*numNodes)) + allocate(nodeOwners(numNodes)) + allocate(iurpts(numNodes)) + + do n = 1,numNodes + + xid0 = mod(nodeIds(n)-1, nx_global) + 1 + yid0 = (nodeIds(n)-1) / nx_global + 1 + + xid = xid0 + yid = max(min(yid0,ny_global),1) + iur = (yid-1) * nx_global + xid + iurpts(n) = iur + + xid = mod(xid0 - 2 + nx_global, nx_global) + 1 + yid = max(min(yid0,ny_global),1) + iul = (yid-1) * nx_global + xid + + xid = mod(xid0 - 2 + nx_global, nx_global) + 1 + yid = max(min(yid0-1,ny_global),1) + ill = (yid-1) * nx_global + xid + + xid = xid0 + yid = max(min(yid0-1,ny_global),1) + ilr = (yid-1) * nx_global + xid + + ! write(tmpstr,'(2a,8i6)') subname,' nodecoord = ',n,nodeIds(n),xid0,yid0,iur,iul,ill,ilr + ! call ESMF_LogWrite(trim(tmpstr), ESMF_LOGMSG_INFO) + + ! need to normalize lon values to same 360 degree setting, use lonur as reference value + lonur = lonG(iur) + lonul = lonG(iul) + lonll = lonG(ill) + lonlr = lonG(ilr) + + if (abs(lonul + 360._r8 - lonur) < abs(lonul - lonur)) lonul = lonul + 360._r8 + if (abs(lonul - 360._r8 - lonur) < abs(lonul - lonur)) lonul = lonul - 360._r8 + if (abs(lonll + 360._r8 - lonur) < abs(lonll - lonur)) lonll = lonll + 360._r8 + if (abs(lonll - 360._r8 - lonur) < abs(lonll - lonur)) lonll = lonll - 360._r8 + if (abs(lonlr + 360._r8 - lonur) < abs(lonlr - lonur)) lonlr = lonlr + 360._r8 + if (abs(lonlr - 360._r8 - lonur) < abs(lonlr - lonur)) lonlr = lonlr - 360._r8 + + nodeCoords(2*n-1) = 0.25_r8 * (lonur + lonul + lonll + lonlr) + nodeCoords(2*n) = 0.25_r8 * (latG(iur) + latG(iul) + latG(ill) + latG(ilr)) + enddo + + deallocate(lonG) + deallocate(latG) + + ! Determine the pes that own each index of iurpts (nodeOwners) + + allocate(pes_local(nx_global*ny_global)) + allocate(pes_global(nx_global*ny_global)) + pes_local(:) = 0 + do n = 1,lsize + pes_local(gindex(n)) = iam + end do + + call ESMF_VMAllReduce(vm, sendData=pes_local, recvData=pes_global, count=nx_global*ny_global, & + reduceflag=ESMF_REDUCE_SUM, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + do n = 1,numNodes + nodeOwners(n) = pes_global(iurpts(n)) + end do + deallocate(pes_local) + deallocate(pes_global) + + Emesh = ESMF_MeshCreate(parametricDim=2, & + spatialDim=2, & + coordSys=ESMF_COORDSYS_SPH_DEG, & + nodeIds=nodeIds(1:numNodes), & + nodeCoords=nodeCoords, & + nodeOwners=nodeOwners, & + elementIds=elemIds,& + elementTypes=elemTypes, & + elementConn=elemConn, & + elementCoords=elemCoords, & + rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + deallocate(iurpts) + deallocate(nodeIds, nodeCoords, nodeOwners) + deallocate(elemIds, elemTypes, elemConn, elemCoords) + + end subroutine dead_meshinit + +end module dead_nuopc_mod diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib new file mode 120000 index 000000000..9601a6fa7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib @@ -0,0 +1 @@ +../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml new file mode 100755 index 000000000..b7b8576ba --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +""" +build data model library +""" + +import sys, os + +_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) + +from standard_script_setup import * +from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.case import Case + +def buildnml(case, caseroot, compname): + if compname != "xwav": + raise AttributeError + build_xcpl_nml(case, caseroot, compname) + +def _main_func(): + caseroot = parse_input(sys.argv) + with Case(caseroot) as case: + buildnml(case, caseroot, "xwav") + +if __name__ == "__main__": + _main_func() diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml b/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml new file mode 100644 index 000000000..e82944fd3 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml @@ -0,0 +1,26 @@ + + + + + + + Dead wave component + + + + + char + xwav + xwav + case_comp + env_case.xml + Name of wave component + + + + ========================================= + XWAV naming conventions in compset name + ========================================= + + + diff --git a/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 new file mode 100644 index 000000000..174847a95 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 @@ -0,0 +1,518 @@ +module wav_comp_nuopc + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for XWAV + !---------------------------------------------------------------------------- + + use ESMF + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index + use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + + implicit none + private ! except + + public :: SetServices + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + character(len=CL) :: 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 :: fldsToWav_num = 0 + integer :: fldsFrWav_num = 0 + type (fld_list_type) :: fldsToWav(fldsMax) + type (fld_list_type) :: fldsFrWav(fldsMax) + integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost + + real(r8), pointer :: gbuf(:,:) ! model info + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer , allocatable :: gindex(:) + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + 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 :: mastertask + integer :: dbug = 1 + character(*),parameter :: modName = "(xwav_comp_nuopc)" + character(*),parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! 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=ModelInitPhase, 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=ModelSetRunClock, 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, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + 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 + type(ESMF_VM) :: vm + character(CS) :: stdname + integer :: n + integer :: lsize ! local array size + integer :: shrlogunit ! original log unit + character(CL) :: cvalue + character(len=CL) :: logmsg + logical :: isPresent, isSet + character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localpet=my_task, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + mastertask = (my_task == 0) + + !---------------------------------------------------------------------------- + ! determine instance information + !--------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Initialize xwav + !---------------------------------------------------------------------------- + + call dead_init_nuopc('wav', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + allocate(gindex(lsize)) + allocate(lon(lsize)) + allocate(lat(lsize)) + + gindex(:) = gbuf(:,dead_grid_index) + lat(:) = gbuf(:,dead_grid_lat) + lon(:) = gbuf(:,dead_grid_lon) + + !-------------------------------- + ! advertise import and export fields + !-------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + flds_scalar_name = trim(cvalue) + call ESMF_LogWrite(trim(subname)//' flds_scalar_name = '//trim(flds_scalar_name), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldName') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldCount", 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_num + write(logmsg,*) flds_scalar_num + call ESMF_LogWrite(trim(subname)//' flds_scalar_num = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldCount') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNX", 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_nx + write(logmsg,*) flds_scalar_index_nx + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nx = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNX') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNY", 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_ny + write(logmsg,*) flds_scalar_index_ny + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_ny = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') + endif + + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrWav_num, fldsFrWav, trim(flds_scalar_name)) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_lamult' ) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_ustokes' ) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_vstokes' ) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_hstokes' ) + + call fld_list_add(fldsToWav_num, fldsToWav, trim(flds_scalar_name)) + call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_u' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_v' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_tbot' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'Si_ifrac' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_t' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_u' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_v' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_bldepth' ) + + do n = 1,fldsFrWav_num + if (mastertask) write(logunit,*)'Advertising From Xwav ',trim(fldsFrWav(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrWav(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + do n = 1,fldsToWav_num + if(mastertask) write(logunit,*)'Advertising To Xwav ',trim(fldsToWav(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToWav(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) + + 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_Mesh) :: Emesh + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! generate the mesh + !-------------------------------- + + call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! realize the actively coupled fields, now that a mesh is established + ! 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 fld_list_realize( & + state=ExportState, & + fldlist=fldsFrWav, & + numflds=fldsFrWav_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':dwavExport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fld_list_realize( & + state=importState, & + fldList=fldsToWav, & + numflds=fldsToWav_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':dwavImport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call State_SetExport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call State_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + + call shr_file_setLogUnit (shrlogunit) + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeRealize + + !=============================================================================== + + subroutine ModelAdvance(gcomp, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + if (dbug > 5) then + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + end if + call memcheck(subname, 3, mastertask) + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call State_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if ( mastertask) then + call log_clock_advance(clock, 'XWAV', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) then + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + end if + + end subroutine ModelAdvance + + !=============================================================================== + + subroutine state_setexport(exportState, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer , intent(out) :: rc + + ! local variables + integer :: nf, nind, nfstart, ubound + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + nfstart = 0 ! for fields that have ubound > 0 + do nf = 2,fldsFrWav_num ! Start from index 2 in order to skip the scalar field + ubound = fldsFrWav(nf)%ungridded_ubound + if (ubound == 0) then + call field_setexport(exportState, trim(fldsFrWav(nf)%stdname), lon, lat, nf=nf, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + nfstart = nfstart + nf + ubound - 1 + do nind = 1,ubound + call field_setexport(exportState, trim(fldsFrWav(nf)%stdname), lon, lat, nf=nfstart+nind-1, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + + end subroutine state_setexport + + !=============================================================================== + + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) + + use shr_const_mod , only : pi=>shr_const_pi + + ! intput/otuput variables + type(ESMF_State) , intent(inout) :: exportState + character(len=*) , intent(in) :: fldname + real(r8) , intent(in) :: lon(:) + real(r8) , intent(in) :: lat(:) + integer , intent(in) :: nf + integer, optional , intent(in) :: ungridded_index + integer , intent(out) :: rc + + ! local variables + integer :: i, ncomp + type(ESMF_Field) :: lfield + real(r8), pointer :: data1d(:) + real(r8), pointer :: data2d(:,:) + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemName=trim(fldname), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ncomp = 7 + if (present(ungridded_index)) then + call ESMF_FieldGet(lfield, farrayPtr=data2d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (gridToFieldMap == 1) then + do i = 1,size(data2d, dim=1) + data2d(i,ungridded_index) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + else if (gridToFieldMap == 2) then + do i = 1,size(data2d, dim=2) + data2d(ungridded_index,i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + else + call ESMF_FieldGet(lfield, farrayPtr=data1d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + do i = 1,size(data1d) + data1d(i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + + end subroutine field_setexport + + !=============================================================================== + + subroutine ModelFinalize(gcomp, rc) + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' + !------------------------------------------------------------------------------- + + !-------------------------------- + ! Finalize routine + !-------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call dead_final_nuopc('wav', logunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelFinalize + +end module wav_comp_nuopc From a44968e920d9a20eec2b84eb1087616626b5f94a Mon Sep 17 00:00:00 2001 From: James Foucar Date: Mon, 16 Mar 2020 14:02:03 -0600 Subject: [PATCH 03/24] Add cmake buildlib files --- src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake | 1 + src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake | 1 + src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake | 1 + src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake | 1 + src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake | 1 + src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake | 1 + src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake | 1 + 7 files changed, 7 insertions(+) create mode 120000 src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake create mode 120000 src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake create mode 120000 src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake create mode 120000 src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake create mode 120000 src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake create mode 120000 src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake create mode 120000 src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake new file mode 120000 index 000000000..292ce33d2 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake @@ -0,0 +1 @@ +../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake new file mode 120000 index 000000000..292ce33d2 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake @@ -0,0 +1 @@ +../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake b/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake new file mode 120000 index 000000000..292ce33d2 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake @@ -0,0 +1 @@ +../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake new file mode 120000 index 000000000..292ce33d2 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake @@ -0,0 +1 @@ +../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake new file mode 120000 index 000000000..292ce33d2 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake @@ -0,0 +1 @@ +../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake new file mode 120000 index 000000000..292ce33d2 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake @@ -0,0 +1 @@ +../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake new file mode 120000 index 000000000..292ce33d2 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake @@ -0,0 +1 @@ +../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file From cf6ea57eade8e808dda5efd33d3ed59e5c25c36f Mon Sep 17 00:00:00 2001 From: James Foucar Date: Tue, 21 Apr 2020 13:39:50 -0600 Subject: [PATCH 04/24] Merge branch 'jgfouca/branch-for-to-acme-2020-04-14' into master (PR #3547) Update CIME to ESMCI cime5.8.20 Squash merge of jgfouca/branch-for-to-acme-2020-04-14 This is the first cime update in half a year, lots of changes. Features: * allow for specification of vertical grid in ATM_GRID * if no env vars, print comment to assist user in env_mach_specific.xml * case.setup: add --keep option for clean/reset actions to keep local changes to generated files * case.setup: refresh build Macros when doing a reset/clean * cprnc: cime will build a copy in sharelibs if no global version available * check_input_data: add ftp timeout, make sure failover to svn is working * added support for new OMIP compsets in POP as well as better handling of the different versions of JRA forcings * Pio2 updated to latest master * reorganize mct and nuopc data, xcpl and stub components based on coupler * new auto-triaging feature for tests, will report potentially broken commits to TestStatus.log * coupler: Allow writing T-forcing cplhist files even when running with SGLC * Add support for UFS model! Not really relevant to E3SM, but is a major development in CIME * archiver: Extend archiving support to accept a regex pattern * coupler: Update for compatibility with latest CMEPS Bug fixes: * check_input_data: fix issue with pop input files that should not be found * fix default for PIO_REARRANGER * docn: Small fix to allow scam to run with aquaplanet * fix issue with resubmit on systems that use ssh * fix misleading output in CaseStatus * Update description for FORCE_BUILD_SMP * archiver: pop dd history files were not identified by get_extension * NOTE: MPAS history files are now being processed as they should have been all along * Improve scripts_regression_tests test cleanup * dlnd: Some gnu tests were giving an error of different character lengths in dlnd. * coupler: seq flux should be initialized even if for some reason the namelist isn't read * env_batch.xml: we can now handle the case where multiple queues have the same name * ERI: fix tests that were less than a day, or with START_TOD nonzero * test hist: Exclude .ref1 and .ref2 from TestStatus files * coupler: fix issue with e3sm field Fixes: #2324 [BFB] --- .../xatm/cime_config/buildlib | 1 + .../xatm/cime_config/buildlib_cmake | 1 + .../xatm/cime_config/buildnml | 27 + .../xatm/cime_config/config_component.xml | 25 + .../xatm/src/atm_comp_nuopc.F90 | 579 +++++++++++ .../xglc/cime_config/buildlib | 1 + .../xglc/cime_config/buildlib_cmake | 1 + .../xglc/cime_config/buildnml | 27 + .../xglc/cime_config/config_component.xml | 26 + .../xglc/src/glc_comp_nuopc.F90 | 521 ++++++++++ .../xice/cime_config/buildlib | 1 + .../xice/cime_config/buildlib_cmake | 1 + .../xice/cime_config/buildnml | 27 + .../xice/cime_config/config_component.xml | 26 + .../xice/src/ice_comp_nuopc.F90 | 557 +++++++++++ .../xlnd/cime_config/buildlib | 1 + .../xlnd/cime_config/buildlib_cmake | 1 + .../xlnd/cime_config/buildnml | 27 + .../xlnd/cime_config/config_component.xml | 26 + .../xlnd/src/lnd_comp_nuopc.F90 | 563 +++++++++++ .../xocn/cime_config/buildlib | 1 + .../xocn/cime_config/buildlib_cmake | 1 + .../xocn/cime_config/buildnml | 27 + .../xocn/cime_config/config_component.xml | 27 + .../xocn/src/ocn_comp_nuopc.F90 | 537 +++++++++++ .../xrof/cime_config/buildlib | 1 + .../xrof/cime_config/buildlib_cmake | 1 + .../xrof/cime_config/buildnml | 27 + .../xrof/cime_config/config_component.xml | 39 + .../xrof/src/rof_comp_nuopc.F90 | 511 ++++++++++ .../xshare/dead_methods_mod.F90 | 840 ++++++++++++++++ .../xshare/dead_nuopc_mod.F90 | 907 ++++++++++++++++++ .../xwav/cime_config/buildlib | 1 + .../xwav/cime_config/buildlib_cmake | 1 + .../xwav/cime_config/buildnml | 27 + .../xwav/cime_config/config_component.xml | 26 + .../xwav/src/wav_comp_nuopc.F90 | 518 ++++++++++ 37 files changed, 5931 insertions(+) create mode 120000 src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib create mode 120000 src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake create mode 100755 src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml create mode 100644 src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml create mode 100644 src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 create mode 120000 src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib create mode 120000 src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake create mode 100755 src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml create mode 100644 src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml create mode 100644 src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 create mode 120000 src/components/xcpl_comps_nuopc/xice/cime_config/buildlib create mode 120000 src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake create mode 100755 src/components/xcpl_comps_nuopc/xice/cime_config/buildnml create mode 100644 src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml create mode 100644 src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 create mode 120000 src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib create mode 120000 src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake create mode 100755 src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml create mode 100644 src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml create mode 100644 src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 create mode 120000 src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib create mode 120000 src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake create mode 100755 src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml create mode 100644 src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml create mode 100644 src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 create mode 120000 src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib create mode 120000 src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake create mode 100755 src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml create mode 100644 src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml create mode 100644 src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 create mode 100644 src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 create mode 100644 src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 create mode 120000 src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib create mode 120000 src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake create mode 100755 src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml create mode 100644 src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml create mode 100644 src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib new file mode 120000 index 000000000..9601a6fa7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib @@ -0,0 +1 @@ +../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake new file mode 120000 index 000000000..292ce33d2 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake @@ -0,0 +1 @@ +../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml new file mode 100755 index 000000000..50a814c79 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +""" +build data model library +""" + +import sys, os + +_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) + +from standard_script_setup import * +from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.case import Case + +def buildnml(case, caseroot, compname): + if compname != "xatm": + raise AttributeError + build_xcpl_nml(case, caseroot, compname) + +def _main_func(): + caseroot = parse_input(sys.argv) + with Case(caseroot) as case: + buildnml(case, caseroot, "xatm") + +if __name__ == "__main__": + _main_func() diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml b/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml new file mode 100644 index 000000000..76c8be8c7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml @@ -0,0 +1,25 @@ + + + + + + + Dead atm component + + + + char + xatm + xatm + case_comp + env_case.xml + Name of atmosphere component + + + + ========================================= + XATM naming conventions in compset name + ========================================= + + + diff --git a/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 new file mode 100644 index 000000000..4cbea61d0 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 @@ -0,0 +1,579 @@ +module atm_comp_nuopc + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for XATM + !---------------------------------------------------------------------------- + + use ESMF + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index + use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + + implicit none + private ! except + + public :: SetServices + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + character(len=CL) :: 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 :: fldsToAtm_num = 0 + integer :: fldsFrAtm_num = 0 + type (fld_list_type) :: fldsToAtm(fldsMax) + type (fld_list_type) :: fldsFrAtm(fldsMax) + integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost + + real(r8), pointer :: gbuf(:,:) ! model info + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer , allocatable :: gindex(:) + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + integer :: inst_index ! number of current instance (ie. 1) + character(len=5) :: inst_suffix ! char string associated with instance (ie. "_0001" or "") + integer :: logunit ! logging unit number + logical :: mastertask + integer :: dbug = 1 + character(*),parameter :: modName = "(xatm_comp_nuopc)" + character(*),parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! 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=ModelInitPhase, 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=ModelSetRunClock, 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, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + 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 + type(ESMF_VM) :: vm + character(CS) :: stdname + integer :: n + integer :: lsize ! local array size + integer :: shrlogunit ! original log unit + character(CL) :: cvalue + character(len=CL) :: logmsg + logical :: isPresent, isSet + character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localpet=my_task, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + mastertask = (my_task==0) + + !---------------------------------------------------------------------------- + ! determine instance information + !---------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Initialize xatm + !---------------------------------------------------------------------------- + + call dead_init_nuopc('atm', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + allocate(gindex(lsize)) + allocate(lon(lsize)) + allocate(lat(lsize)) + + gindex(:) = gbuf(:,dead_grid_index) + lat(:) = gbuf(:,dead_grid_lat) + lon(:) = gbuf(:,dead_grid_lon) + + !-------------------------------- + ! advertise import and export fields + !-------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + flds_scalar_name = trim(cvalue) + call ESMF_LogWrite(trim(subname)//' flds_scalar_name = '//trim(flds_scalar_name), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldName') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldCount", 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_num + write(logmsg,*) flds_scalar_num + call ESMF_LogWrite(trim(subname)//' flds_scalar_num = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldCount') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNX", 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_nx + write(logmsg,*) flds_scalar_index_nx + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nx = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNX') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNY", 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_ny + write(logmsg,*) flds_scalar_index_ny + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_ny = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') + endif + + 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 + write(logmsg,*) flds_scalar_index_nextsw_cday + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nextsw_cday = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxNextSwCday') + endif + + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrAtm_num, fldsFrAtm, trim(flds_scalar_name)) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_topo' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_z' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_u' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_v' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_tbot' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_ptem' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_shum' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_pbot' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_dens' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_pslv' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainc' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainl' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowc' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowl' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_lwdn' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swndr' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swvdr' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swndf' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swvdf' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swnet' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_dstwet', ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_dstdry', ungridded_lbound=1, ungridded_ubound=4) + + call fld_list_add(fldsToAtm_num, fldsToAtm, trim(flds_scalar_name)) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_anidr' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_avsdf' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_anidf' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_avsdr' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_lfrac' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Si_ifrac' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_ofrac' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_tref' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_qref' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_t' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_t' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_fv' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_ram1' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_snowh' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Si_snowh' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_ssq' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_re' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_u10' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_taux' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_tauy' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_lat' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_sen' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_lwup' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_evap' ) + + do n = 1,fldsFrAtm_num + if(mastertask) write(logunit,*)'Advertising From Xatm ',trim(fldsFrAtm(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrAtm(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + + do n = 1,fldsToAtm_num + if(mastertask) write(logunit,*)'Advertising To Xatm',trim(fldsToAtm(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToAtm(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeAdvertise + + !=============================================================================== + + subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) + + ! input/output arguments + type(ESMF_GridComp) :: gcomp + type(ESMF_State) :: importState, exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + + ! local variables + type(ESMF_Mesh) :: Emesh + type(ESMF_Time) :: nextTime + real(r8) :: nextsw_cday + integer :: n + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize: xatm) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logUnit) + + !-------------------------------- + ! generate the mesh + !-------------------------------- + + call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! realize the actively coupled fields, now that a mesh is established + ! 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 fld_list_realize( & + state=exportState, & + fldList=fldsFrAtm, & + numflds=fldsFrAtm_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':datmExport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fld_list_realize( & + state=importState, & + fldList=fldsToAtm, & + numflds=fldsToAtm_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':datmImport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call state_setexport(exportState, rc=rc) + + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! Set time of next radiation computation + + call ESMF_ClockGetNextTime(clock, nextTime) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_TimeGet(nextTime, dayOfYear_r8=nextsw_cday) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call 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 + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call State_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeRealize + + !=============================================================================== + + subroutine ModelAdvance(gcomp, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + real(r8) :: nextsw_cday + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + if (dbug > 1) then + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + end if + call memcheck(subname, 3, mastertask) + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call 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 + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call state_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (mastertask) then + call log_clock_advance(clock, 'XATM', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) then + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + end if + + end subroutine ModelAdvance + + !=============================================================================== + + subroutine state_setexport(exportState, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer, intent(out) :: rc + + ! local variables + integer :: nf, nind + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Start from index 2 in order to Skip the scalar field here + do nf = 2,fldsFrAtm_num + if (fldsFrAtm(nf)%ungridded_ubound == 0) then + call field_setexport(exportState, trim(fldsFrAtm(nf)%stdname), lon, lat, nf=nf, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + do nind = 1,fldsFrAtm(nf)%ungridded_ubound + call field_setexport(exportState, trim(fldsFrAtm(nf)%stdname), lon, lat, nf=nf+nind-1, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + + end subroutine state_setexport + + !=============================================================================== + + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) + + use shr_const_mod , only : pi=>shr_const_pi + + ! intput/otuput variables + type(ESMF_State) , intent(inout) :: exportState + character(len=*) , intent(in) :: fldname + real(r8) , intent(in) :: lon(:) + real(r8) , intent(in) :: lat(:) + integer , intent(in) :: nf + integer, optional , intent(in) :: ungridded_index + integer , intent(out) :: rc + + ! local variables + integer :: i, ncomp + type(ESMF_Field) :: lfield + real(r8), pointer :: data1d(:) + real(r8), pointer :: data2d(:,:) + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemName=trim(fldname), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ncomp = 1 + if (present(ungridded_index)) then + call ESMF_FieldGet(lfield, farrayPtr=data2d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (gridToFieldMap == 1) then + do i = 1,size(data2d, dim=1) + data2d(i,ungridded_index) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + else if (gridToFieldMap == 2) then + do i = 1,size(data2d, dim=2) + data2d(ungridded_index,i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + else + call ESMF_FieldGet(lfield, farrayPtr=data1d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + do i = 1,size(data1d) + data1d(i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + + end subroutine field_setexport + + !=============================================================================== + + subroutine ModelFinalize(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' + !------------------------------------------------------------------------------- + + !-------------------------------- + ! Finalize routine + !-------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call dead_final_nuopc('atm', logunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelFinalize + +end module atm_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib new file mode 120000 index 000000000..9601a6fa7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib @@ -0,0 +1 @@ +../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake new file mode 120000 index 000000000..292ce33d2 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake @@ -0,0 +1 @@ +../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml new file mode 100755 index 000000000..64077a469 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +""" +build data model library +""" + +import sys, os + +_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) + +from standard_script_setup import * +from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.case import Case + +def buildnml(case, caseroot, compname): + if compname != "xglc": + raise AttributeError + build_xcpl_nml(case, caseroot, compname) + +def _main_func(): + caseroot = parse_input(sys.argv) + with Case(caseroot) as case: + buildnml(case, caseroot, "xglc") + +if __name__ == "__main__": + _main_func() diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml b/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml new file mode 100644 index 000000000..f1765811b --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml @@ -0,0 +1,26 @@ + + + + + + + Dead land-ice component + + + + char + xglc + xglc + case_comp + env_case.xml + Name of land-ice component + + + + + ========================================= + XGLC naming conventions in compset name + ========================================= + + + diff --git a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 new file mode 100644 index 000000000..f381503f7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 @@ -0,0 +1,521 @@ +module glc_comp_nuopc + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for XGLC + !---------------------------------------------------------------------------- + + use ESMF + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index + use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + + implicit none + private ! except + + public :: SetServices + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + character(len=CL) :: flds_scalar_name = '' + integer :: flds_scalar_num = 0 + integer :: flds_scalar_index_nx = 0 + integer :: flds_scalar_index_ny = 0 + + integer :: fldsToGlc_num = 0 + integer :: fldsFrGlc_num = 0 + type (fld_list_type) :: fldsToGlc(fldsMax) + type (fld_list_type) :: fldsFrGlc(fldsMax) + integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost + + real(r8), pointer :: gbuf(:,:) ! model info + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer , allocatable :: gindex(:) + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + 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 + integer ,parameter :: master_task=0 ! task number of master task + logical :: mastertask + integer :: dbug = 1 + character(*),parameter :: modName = "(xglc_comp_nuopc)" + character(*),parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! 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=ModelInitPhase, 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=ModelSetRunClock, 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, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + 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 + type(ESMF_VM) :: vm + character(CS) :: stdname + integer :: n + integer :: lsize ! local array size + integer :: shrlogunit ! original log unit + character(CL) :: cvalue + character(len=CL) :: logmsg + logical :: isPresent, isSet + character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localpet=my_task, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + mastertask = my_task == master_task + + !---------------------------------------------------------------------------- + ! determine instance information + !---------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, my_task==master_task, logunit, shrlogunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Initialize xglc + !---------------------------------------------------------------------------- + + call dead_init_nuopc('glc', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + allocate(gindex(lsize)) + allocate(lon(lsize)) + allocate(lat(lsize)) + + gindex(:) = gbuf(:,dead_grid_index) + lat(:) = gbuf(:,dead_grid_lat) + lon(:) = gbuf(:,dead_grid_lon) + + !-------------------------------- + ! advertise import and export fields + !-------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + flds_scalar_name = trim(cvalue) + call ESMF_LogWrite(trim(subname)//' flds_scalar_name = '//trim(flds_scalar_name), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldName') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldCount", 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_num + write(logmsg,*) flds_scalar_num + call ESMF_LogWrite(trim(subname)//' flds_scalar_num = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldCount') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNX", 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_nx + write(logmsg,*) flds_scalar_index_nx + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nx = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNX') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNY", 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_ny + write(logmsg,*) flds_scalar_index_ny + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_ny = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') + endif + + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrGlc_num, fldsFrGlc, trim(flds_scalar_name)) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_icemask' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_icemask_coupled_fluxes' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_ice_covered' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_topo' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Flgg_hflx' ) + + call fld_list_add(fldsToGlc_num, fldsToGlc, trim(flds_scalar_name)) + call fld_list_add(fldsToGlc_num, fldsToGlc, 'Sl_tsrf') + call fld_list_add(fldsToGlc_num, fldsToGlc, 'Flgl_qice') + + do n = 1,fldsFrGlc_num + if (mastertask) write(logunit,*)'Advertising From Xglc ',trim(fldsFrGlc(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrglc(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + do n = 1,fldsToGlc_num + if (mastertask) write(logunit,*)'Advertising To Xglc ',trim(fldsToGlc(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToglc(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) + + 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_Mesh) :: Emesh + integer :: shrlogunit ! original log unit + integer :: n + character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! generate the mesh + ! grid_option specifies grid or mesh + !-------------------------------- + + call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! realize the actively coupled fields, now that a mesh is established + ! 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 fld_list_realize( & + state=ExportState, & + fldList=fldsFrGlc, & + numflds=fldsFrGlc_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':dglcExport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fld_list_realize( & + state=importState, & + fldList=fldsToGlc, & + numflds=fldsToGlc_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':dglcImport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! Pack export state + ! Copy from d2x to exportState + ! Set the coupling scalars + !-------------------------------- + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setscalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setscalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call state_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeRealize + + !=============================================================================== + + subroutine ModelAdvance(gcomp, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + integer :: n + integer :: shrlogunit ! original log unit + real(r8), pointer :: dataptr(:) + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + call memcheck(subname, 3, mastertask) + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call state_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (my_task == master_task) then + call log_clock_advance(clock, 'XGLC', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelAdvance + + !=============================================================================== + + subroutine state_setexport(exportState, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer, intent(out) :: rc + + ! local variables + integer :: nf, nind + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Start from index 2 in order to skip the scalar field + do nf = 2,fldsFrGlc_num + if (fldsFrGlc(nf)%ungridded_ubound == 0) then + call field_setexport(exportState, trim(fldsFrGlc(nf)%stdname), lon, lat, nf=nf, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + do nind = 1,fldsFrGlc(nf)%ungridded_ubound + call field_setexport(exportState, trim(fldsFrGlc(nf)%stdname), lon, lat, nf=nf+nind-1, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + + end subroutine state_setexport + + !=============================================================================== + + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) + + use shr_const_mod , only : pi=>shr_const_pi + + ! intput/otuput variables + type(ESMF_State) , intent(inout) :: exportState + character(len=*) , intent(in) :: fldname + real(r8) , intent(in) :: lon(:) + real(r8) , intent(in) :: lat(:) + integer , intent(in) :: nf + integer, optional , intent(in) :: ungridded_index + integer , intent(out) :: rc + + ! local variables + integer :: i, ncomp + type(ESMF_Field) :: lfield + real(r8), pointer :: data1d(:) + real(r8), pointer :: data2d(:,:) + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemName=trim(fldname), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ncomp = 5 + if (present(ungridded_index)) then + call ESMF_FieldGet(lfield, farrayPtr=data2d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (gridToFieldMap == 1) then + do i = 1,size(data2d, dim=1) + data2d(i,ungridded_index) = (nf*100) & + * cos (pi*lat(i)/180.0_R8) * cos (pi*lat(i)/180.0_R8) & + * sin (pi*lon(i)/180.0_R8) * sin (pi*lon(i)/180.0_R8) & + + (ncomp*10.0_R8) + enddo + else if (gridToFieldMap == 2) then + do i = 1,size(data2d, dim=2) + data2d(ungridded_index,i) = (nf*100) & + * cos (pi*lat(i)/180.0_R8) * cos (pi*lat(i)/180.0_R8) & + * sin (pi*lon(i)/180.0_R8) * sin (pi*lon(i)/180.0_R8) & + + (ncomp*10.0_R8) + end do + end if + else + call ESMF_FieldGet(lfield, farrayPtr=data1d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (fldname == 'Sg_icemask' .or. fldname == 'Sg_icemask_coupled_fluxes' .or. fldname == 'Sg_ice_covered') then + data1d(:) = 1._r8 + else + do i = 1,size(data1d) + data1d(i) = (nf*100) & + * cos (pi*lat(i)/180.0_R8) * cos (pi*lat(i)/180.0_R8) & + * sin (pi*lon(i)/180.0_R8) * sin (pi*lon(i)/180.0_R8) & + + (ncomp*10.0_R8) + end do + end if + end if + + end subroutine field_setexport + + !=============================================================================== + + subroutine ModelFinalize(gcomp, rc) + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' + !------------------------------------------------------------------------------- + + !-------------------------------- + ! Finalize routine + !-------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call dead_final_nuopc('glc', logunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelFinalize + + !=============================================================================== + +end module glc_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib b/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib new file mode 120000 index 000000000..9601a6fa7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib @@ -0,0 +1 @@ +../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake b/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake new file mode 120000 index 000000000..292ce33d2 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake @@ -0,0 +1 @@ +../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml new file mode 100755 index 000000000..e023dc7c6 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +""" +build data model library +""" + +import sys, os + +_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) + +from standard_script_setup import * +from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.case import Case + +def buildnml(case, caseroot, compname): + if compname != "xice": + raise AttributeError + build_xcpl_nml(case, caseroot, compname) + +def _main_func(): + caseroot = parse_input(sys.argv) + with Case(caseroot) as case: + buildnml(case, caseroot, "xice") + +if __name__ == "__main__": + _main_func() diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml b/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml new file mode 100644 index 000000000..a3263a0ee --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml @@ -0,0 +1,26 @@ + + + + + + + Dead ice component + + + + char + xice + xice + case_comp + env_case.xml + Name of sea-ice component + + + + + ========================================= + XICE naming conventions in compset name + ========================================= + + + diff --git a/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 new file mode 100644 index 000000000..3537e8dd1 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 @@ -0,0 +1,557 @@ +module ice_comp_nuopc + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for XICE + !---------------------------------------------------------------------------- + + use ESMF + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index + use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + + implicit none + private ! except + + public :: SetServices + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + character(len=CL) :: flds_scalar_name = '' + integer :: flds_scalar_num = 0 + integer :: flds_scalar_index_nx = 0 + integer :: flds_scalar_index_ny = 0 + + integer :: fldsToIce_num = 0 + integer :: fldsFrIce_num = 0 + type (fld_list_type) :: fldsToIce(fldsMax) + type (fld_list_type) :: fldsFrIce(fldsMax) + integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost + + real(r8), pointer :: gbuf(:,:) ! model info + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer , allocatable :: gindex(:) + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + 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 + integer ,parameter :: master_task=0 ! task number of master task + logical :: mastertask + integer :: dbug = 1 + character(*),parameter :: modName = "(xice_comp_nuopc)" + character(*),parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! 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=ModelInitPhase, 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=ModelSetRunClock, 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, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + 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 + type(ESMF_VM) :: vm + character(CL) :: cvalue + character(CS) :: stdname + integer :: n + integer :: lsize ! local array size + integer :: shrlogunit ! original log unit + character(len=CL) :: logmsg + logical :: isPresent, isSet + character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localpet=my_task, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + mastertask = my_task == master_task + + !---------------------------------------------------------------------------- + ! determine instance information + !---------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, my_task==master_task, logunit, shrlogunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Initialize xice + !---------------------------------------------------------------------------- + + call dead_init_nuopc('ice', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + allocate(gindex(lsize)) + allocate(lon(lsize)) + allocate(lat(lsize)) + + gindex(:) = gbuf(:,dead_grid_index) + lat(:) = gbuf(:,dead_grid_lat) + lon(:) = gbuf(:,dead_grid_lon) + + !-------------------------------- + ! advertise import and export fields + !-------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + flds_scalar_name = trim(cvalue) + call ESMF_LogWrite(trim(subname)//' flds_scalar_name = '//trim(flds_scalar_name), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldName') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldCount", 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_num + write(logmsg,*) flds_scalar_num + call ESMF_LogWrite(trim(subname)//' flds_scalar_num = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldCount') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNX", 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_nx + write(logmsg,*) flds_scalar_index_nx + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nx = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNX') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNY", 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_ny + write(logmsg,*) flds_scalar_index_ny + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_ny = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') + endif + + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrIce_num, fldsFrIce, trim(flds_scalar_name)) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_imask' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_ifrac' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_t' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_tref' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_qref' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_snowh' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_u10' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_avsdr' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_anidr' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_avsdf' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_anidf' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_taux' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_tauy' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_lat' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_sen' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_lwup' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_evap' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_swnet' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_melth' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_swpen' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_meltw' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_salt' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_taux' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_tauy' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_bcpho' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_bcphi' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_flxdst' ) + + call fld_list_add(fldsToIce_num, fldsToIce, trim(flds_scalar_name)) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_dhdx' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_dhdy' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_t' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_s' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_u' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_v' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Fioo_q' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_z' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_u' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_v' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_ptem' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_shum' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_dens' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_tbot' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swvdr' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swndr' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swvdf' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swndf' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_lwdn' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_rain' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_snow' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_dstwet', ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_dstdry', ungridded_lbound=1, ungridded_ubound=4) + + do n = 1,fldsFrIce_num + if(mastertask) write(logunit,*)'Advertising From Xice ',trim(fldsFrIce(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrIce(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + do n = 1,fldsToIce_num + if(mastertask) write(logunit,*)'Advertising To Xice ',trim(fldsToIce(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToIce(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) + + end subroutine InitializeAdvertise + + !=============================================================================== + + subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) + type(ESMF_GridComp) :: gcomp + type(ESMF_State) :: importState, exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + + ! local variables + type(ESMF_Mesh) :: Emesh + integer :: shrlogunit ! original log unit + integer :: n + character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logUnit) + + !-------------------------------- + ! generate the mesh + !-------------------------------- + + call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! realize the actively coupled fields, now that a mesh is established + ! 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 fld_list_realize( & + state=ExportState, & + fldlist=fldsFrIce, & + numflds=fldsFrIce_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':diceExport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fld_list_realize( & + state=importState, & + fldList=fldsToIce, & + numflds=fldsToIce_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':diceImport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call State_SetExport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call State_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeRealize + + !=============================================================================== + + subroutine ModelAdvance(gcomp, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + call memcheck(subname, 3, mastertask) + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call State_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (my_task == master_task) then + call log_clock_advance(clock, 'XICE', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + endif + + call shr_file_setLogUnit (shrlogunit) + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelAdvance + + !=============================================================================== + + subroutine state_setexport(exportState, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer, intent(out) :: rc + + ! local variables + integer :: nf, nind + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Start from index 2 in order to skip the scalar field + do nf = 2,fldsFrIce_num + if (fldsFrIce(nf)%ungridded_ubound == 0) then + call field_setexport(exportState, trim(fldsFrIce(nf)%stdname), lon, lat, nf=nf, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + do nind = 1,fldsFrIce(nf)%ungridded_ubound + call field_setexport(exportState, trim(fldsFrIce(nf)%stdname), lon, lat, nf=nf+nind-1, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + + end subroutine state_setexport + + !=============================================================================== + + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) + + use shr_const_mod , only : pi=>shr_const_pi + + ! intput/otuput variables + type(ESMF_State) , intent(inout) :: exportState + character(len=*) , intent(in) :: fldname + real(r8) , intent(in) :: lon(:) + real(r8) , intent(in) :: lat(:) + integer , intent(in) :: nf + integer, optional , intent(in) :: ungridded_index + integer , intent(out) :: rc + + ! local variables + integer :: i, ncomp + type(ESMF_Field) :: lfield + real(r8), pointer :: data1d(:) + real(r8), pointer :: data2d(:,:) + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemName=trim(fldname), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ncomp = 3 + if (present(ungridded_index)) then + call ESMF_FieldGet(lfield, farrayPtr=data2d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (gridToFieldMap == 1) then + do i = 1,size(data2d, dim=1) + data2d(i,ungridded_index) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + else if (gridToFieldMap == 2) then + do i = 1,size(data2d, dim=2) + data2d(ungridded_index,i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + else + call ESMF_FieldGet(lfield, farrayPtr=data1d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + do i = 1,size(data1d) + data1d(i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + ! Reset some fields + if (fldname == 'Si_ifrac') then + do i = 1,size(data1d) + data1d(i) = min(1.0_R8,max(0.0_R8,data1d(i))) + end do + else if (fldname == 'Si_imask') then + do i = 1,size(data1d) + data1d(i) = float(nint(min(1.0_R8,max(0.0_R8,data1d(i))))) + end do + end if + end if + + end subroutine field_setexport + + !=============================================================================== + + subroutine ModelFinalize(gcomp, rc) + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' + !------------------------------------------------------------------------------- + + !-------------------------------- + ! Finalize routine + !-------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call dead_final_nuopc('ice', logunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelFinalize + +end module ice_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib new file mode 120000 index 000000000..9601a6fa7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib @@ -0,0 +1 @@ +../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake new file mode 120000 index 000000000..292ce33d2 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake @@ -0,0 +1 @@ +../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml new file mode 100755 index 000000000..760d75e5c --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +""" +build data model library +""" + +import sys, os + +_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) + +from standard_script_setup import * +from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.case import Case + +def buildnml(case, caseroot, compname): + if compname != "xlnd": + raise AttributeError + build_xcpl_nml(case, caseroot, compname) + +def _main_func(): + caseroot = parse_input(sys.argv) + with Case(caseroot) as case: + buildnml(case, caseroot, "xlnd") + +if __name__ == "__main__": + _main_func() diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml b/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml new file mode 100644 index 000000000..8179d0310 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml @@ -0,0 +1,26 @@ + + + + + + + Dead land component + + + + + char + xlnd + xlnd + case_comp + env_case.xml + Name of land component + + + + ========================================= + XLND naming conventions in compset name + ========================================= + + + diff --git a/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 new file mode 100644 index 000000000..4e76678b8 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 @@ -0,0 +1,563 @@ +module lnd_comp_nuopc + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for XLND + !---------------------------------------------------------------------------- + + use ESMF + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index + use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + + implicit none + private ! except + + public :: SetServices + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + character(len=CL) :: 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._r8 + + integer :: fldsToLnd_num = 0 + integer :: fldsFrLnd_num = 0 + type (fld_list_type) :: fldsToLnd(fldsMax) + type (fld_list_type) :: fldsFrLnd(fldsMax) + integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost + integer :: glc_nec + + real(r8), pointer :: gbuf(:,:) ! model info + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer , allocatable :: gindex(:) + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + 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 + integer ,parameter :: master_task=0 ! task number of master task + logical :: mastertask + integer :: dbug = 1 + character(*),parameter :: modName = "(xlnd_comp_nuopc)" + character(*),parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! 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=ModelInitPhase, 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=ModelSetRunClock, 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, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + 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 + type(ESMF_VM) :: vm + character(CS) :: stdname + integer :: n + integer :: lsize ! local array size + integer :: shrlogunit ! original log unit + character(CL) :: cvalue + character(len=CL) :: logmsg + logical :: isPresent, isSet + character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localpet=my_task, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + mastertask = my_task == master_task + + !---------------------------------------------------------------------------- + ! determine instance information + !---------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Initialize xlnd + !---------------------------------------------------------------------------- + + call dead_init_nuopc('lnd', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + allocate(gindex(lsize)) + allocate(lon(lsize)) + allocate(lat(lsize)) + + gindex(:) = gbuf(:,dead_grid_index) + lat(:) = gbuf(:,dead_grid_lat) + lon(:) = gbuf(:,dead_grid_lon) + + !-------------------------------- + ! advertise import and export fields + !-------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + flds_scalar_name = trim(cvalue) + call ESMF_LogWrite(trim(subname)//' flds_scalar_name = '//trim(flds_scalar_name), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldName') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldCount", 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_num + write(logmsg,*) flds_scalar_num + call ESMF_LogWrite(trim(subname)//' flds_scalar_num = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldCount') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNX", 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_nx + write(logmsg,*) flds_scalar_index_nx + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nx = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNX') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNY", 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_ny + write(logmsg,*) flds_scalar_index_ny + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_ny = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') + end if + + if (nxg /= 0 .and. nyg /= 0) then + + call NUOPC_CompAttributeGet(gcomp, name='glc_nec', value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) glc_nec + call ESMF_LogWrite('glc_nec = '// trim(cvalue), ESMF_LOGMSG_INFO) + + call fld_list_add(fldsFrLnd_num, fldsFrlnd, trim(flds_scalar_name)) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_lfrin' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_t' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_tref' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_qref' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_avsdr' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_anidr' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_avsdf' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_anidf' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_snowh' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_u10' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_fv' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_ram1' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofsur' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofgwl' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofsub' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofi' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_irrig' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_taux' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_tauy' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_lat' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_sen' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_lwup' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_evap' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_swnet' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_flxdst' , ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flgl_qice_elev', ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_tsrf_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_topo_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + + call fld_list_add(fldsToLnd_num, fldsToLnd, trim(flds_scalar_name)) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_z' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_topo' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_u' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_v' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_ptem' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_pbot' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_tbot' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_shum' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Flrr_volr' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Flrr_volrmch' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_lwdn' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_rainc' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_rainl' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_snowc' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_snowl' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swndr' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swvdr' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swndf' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swvdf' ) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_dstwet' , ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_dstdry' , ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_topo_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_ice_covered_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsToLnd_num, fldsTolnd, 'Flgg_hflx_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + + do n = 1,fldsFrLnd_num + if (mastertask) write(logunit,*)'Advertising From Xlnd ',trim(fldsFrLnd(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrLnd(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + do n = 1,fldsToLnd_num + if(mastertask) write(logunit,*)'Advertising To Xlnd',trim(fldsToLnd(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToLnd(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + end if + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) + + end subroutine InitializeAdvertise + + !=============================================================================== + + subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) + + ! intput/output variables + type(ESMF_GridComp) :: gcomp + type(ESMF_State) :: importState, exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + + ! local variables + type(ESMF_Mesh) :: Emesh + integer :: shrlogunit ! original log unit + type(ESMF_VM) :: vm + integer :: n + logical :: connected ! is field connected? + character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logUnit) + + !-------------------------------- + ! generate the mesh + !-------------------------------- + + call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! realize the actively coupled fields, now that a mesh is established + ! 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 fld_list_realize( & + state=ExportState, & + fldlist=fldsFrLnd, & + numflds=fldsFrLnd_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':dlndExport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fld_list_realize( & + state=importState, & + fldList=fldsToLnd, & + numflds=fldsToLnd_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':dlndImport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call state_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeRealize + + !=============================================================================== + + subroutine ModelAdvance(gcomp, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + call memcheck(subname, 3, mastertask) + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call state_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (mastertask) then + call log_clock_advance(clock, 'LND', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + endif + + call shr_file_setLogUnit (shrlogunit) + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelAdvance + + !=============================================================================== + + subroutine state_setexport(exportState, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer, intent(out) :: rc + + ! local variables + integer :: nf, nind + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Start from index 2 in order to Skip the scalar field here + do nf = 2,fldsFrLnd_num + if (fldsFrLnd(nf)%ungridded_ubound == 0) then + call field_setexport(exportState, trim(fldsFrLnd(nf)%stdname), lon, lat, nf=nf, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + do nind = 1,fldsFrLnd(nf)%ungridded_ubound + call field_setexport(exportState, trim(fldsFrLnd(nf)%stdname), lon, lat, nf=nf+nind-1, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + + end subroutine state_setexport + + !=============================================================================== + + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) + + use shr_const_mod , only : pi=>shr_const_pi + + ! intput/otuput variables + type(ESMF_State) , intent(inout) :: exportState + character(len=*) , intent(in) :: fldname + real(r8) , intent(in) :: lon(:) + real(r8) , intent(in) :: lat(:) + integer , intent(in) :: nf + integer, optional , intent(in) :: ungridded_index + integer , intent(out) :: rc + + ! local variables + integer :: i, ncomp + type(ESMF_Field) :: lfield + real(r8), pointer :: data1d(:) + real(r8), pointer :: data2d(:,:) + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemName=trim(fldname), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ncomp = 2 + if (present(ungridded_index)) then + call ESMF_FieldGet(lfield, farrayPtr=data2d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (gridToFieldMap == 1) then + do i = 1,size(data2d, dim=1) + data2d(i,ungridded_index) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + else if (gridToFieldMap == 2) then + do i = 1,size(data2d, dim=2) + data2d(ungridded_index,i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + else + call ESMF_FieldGet(lfield, farrayPtr=data1d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (fldname == 'Sl_lfrin') then + data1d(:) = 1._r8 + else + do i = 1,size(data1d) + data1d(i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + end if + + end subroutine field_setexport + + !=============================================================================== + + subroutine ModelFinalize(gcomp, rc) + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' + !------------------------------------------------------------------------------- + + !-------------------------------- + ! Finalize routine + !-------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call dead_final_nuopc('lnd', logunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelFinalize + +end module lnd_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib new file mode 120000 index 000000000..9601a6fa7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib @@ -0,0 +1 @@ +../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake new file mode 120000 index 000000000..292ce33d2 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake @@ -0,0 +1 @@ +../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml new file mode 100755 index 000000000..c6f945376 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +""" +build data model library +""" + +import sys, os + +_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) + +from standard_script_setup import * +from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.case import Case + +def buildnml(case, caseroot, compname): + if compname != "xocn": + raise AttributeError + build_xcpl_nml(case, caseroot, compname) + +def _main_func(): + caseroot = parse_input(sys.argv) + with Case(caseroot) as case: + buildnml(case, caseroot, "xocn") + +if __name__ == "__main__": + _main_func() diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml b/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml new file mode 100644 index 000000000..f68d1ff47 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml @@ -0,0 +1,27 @@ + + + + + + + Dead ocean component + + + + char + xocn + xocn + case_comp + env_case.xml + Name of ocean component + + + + + + ========================================= + XOCN naming conventions in compset name + ========================================= + + + diff --git a/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 new file mode 100644 index 000000000..2f3f037e3 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 @@ -0,0 +1,537 @@ +module ocn_comp_nuopc + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for XOCN + !---------------------------------------------------------------------------- + + use ESMF + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index + use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + + implicit none + private ! except + + public :: SetServices + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + character(len=CL) :: 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._r8 + + integer :: fldsToOcn_num = 0 + integer :: fldsFrOcn_num = 0 + type (fld_list_type) :: fldsToOcn(fldsMax) + type (fld_list_type) :: fldsFrOcn(fldsMax) + integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost + + real(r8), pointer :: gbuf(:,:) ! model info + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer , allocatable :: gindex(:) + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + integer :: inst_index ! number of current instance (ie. 1) + character(len=16) :: inst_name ! fullname of current instance (ie. "ocn_0001") + character(len=16) :: inst_suffix = "" ! char string associated with instance (ie. "_0001" or "") + integer :: logunit ! logging unit number + integer ,parameter :: master_task=0 ! task number of master task + logical :: mastertask + integer :: dbug = 1 + character(*),parameter :: modName = "(xocn_comp_nuopc)" + character(*),parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! 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=ModelInitPhase, 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=ModelSetRunClock, 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, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + 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 + type(ESMF_VM) :: vm + character(CS) :: stdname + integer :: n + integer :: lsize ! local array size + integer :: shrlogunit ! original log unit + character(CL) :: cvalue + character(len=CL) :: logmsg + logical :: isPresent, isSet + character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! generate local mpi comm + !---------------------------------------------------------------------------- + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localpet=my_task, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + mastertask = my_task == master_task + + !---------------------------------------------------------------------------- + ! determine instance information + !---------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, my_task==master_task, logunit, shrlogunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Initialize xocn + !---------------------------------------------------------------------------- + + call dead_init_nuopc('ocn', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + allocate(gindex(lsize)) + allocate(lon(lsize)) + allocate(lat(lsize)) + + gindex(:) = gbuf(:,dead_grid_index) + lat(:) = gbuf(:,dead_grid_lat) + lon(:) = gbuf(:,dead_grid_lon) + + !-------------------------------- + ! advertise import and export fields + !-------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + flds_scalar_name = trim(cvalue) + call ESMF_LogWrite(trim(subname)//' flds_scalar_name = '//trim(flds_scalar_name), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldName') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldCount", 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_num + write(logmsg,*) flds_scalar_num + call ESMF_LogWrite(trim(subname)//' flds_scalar_num = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldCount') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNX", 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_nx + write(logmsg,*) flds_scalar_index_nx + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nx = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNX') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNY", 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_ny + write(logmsg,*) flds_scalar_index_ny + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_ny = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') + endif + + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrOcn_num, fldsFrOcn, trim(flds_scalar_name)) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_omask" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_t" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_s" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_u" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_v" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_dhdx" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_dhdy" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_bldepth" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "Fioo_q" ) + + call fld_list_add(fldsToOcn_num, fldsToOcn, trim(flds_scalar_name)) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_rain" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_snow" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_lwdn" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swndr" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swvdr" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swndf" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swvdf" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_taux" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_tauy" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_sen" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_lat" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_lwup" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_evap" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Fioi_salt" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_rofl" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_rofi" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Sa_pslv" ) + + do n = 1,fldsFrOcn_num + if(mastertask) write(logunit,*)'Advertising From Xocn ',trim(fldsFrOcn(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrOcn(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + do n = 1,fldsToOcn_num + if(mastertask) write(logunit,*)'Advertising To Xocn',trim(fldsToOcn(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToOcn(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) + + 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_Mesh) :: Emesh + integer :: shrlogunit ! original log unit + integer :: n + character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize: xocn) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! generate the mesh + !-------------------------------- + + call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! realize the actively coupled fields, now that a mesh is established + ! 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 fld_list_realize( & + state=ExportState, & + fldlist=fldsFrOcn, & + numflds=fldsFrOcn_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':docnExport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fld_list_realize( & + state=importState, & + fldList=fldsToOcn, & + numflds=fldsToOcn_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':docnImport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call state_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeRealize + + !=============================================================================== + + subroutine ModelAdvance(gcomp, rc) + + ! intput/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + call memcheck(subname, 3, mastertask) + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call state_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (my_task == master_task) then + call log_clock_advance(clock, 'OCN', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + endif + + call shr_file_setLogUnit (shrlogunit) + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelAdvance + + !=============================================================================== + + subroutine state_setexport(exportState, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer, intent(out) :: rc + + ! local variables + integer :: nf, nind + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Start from index 2 in order to Skip the scalar field here + do nf = 2,fldsFrOcn_num + if (fldsFrOcn(nf)%ungridded_ubound == 0) then + call field_setexport(exportState, trim(fldsFrOcn(nf)%stdname), lon, lat, nf=nf, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + do nind = 1,fldsFrOcn(nf)%ungridded_ubound + call field_setexport(exportState, trim(fldsFrOcn(nf)%stdname), lon, lat, nf=nf, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + + end subroutine state_setexport + + !=============================================================================== + + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) + + use shr_const_mod , only : pi=>shr_const_pi + + ! intput/otuput variables + type(ESMF_State) , intent(inout) :: exportState + character(len=*) , intent(in) :: fldname + real(r8) , intent(in) :: lon(:) + real(r8) , intent(in) :: lat(:) + integer , intent(in) :: nf + integer, optional , intent(in) :: ungridded_index + integer , intent(out) :: rc + + ! local variables + integer :: i, ncomp + type(ESMF_Field) :: lfield + real(r8), pointer :: data1d(:) + real(r8), pointer :: data2d(:,:) + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemName=trim(fldname), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ncomp = 4 + if (present(ungridded_index)) then + call ESMF_FieldGet(lfield, farrayPtr=data2d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (gridToFieldMap == 1) then + do i = 1,size(data2d, dim=1) + data2d(i,ungridded_index) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + else if (gridToFieldMap == 2) then + do i = 1,size(data2d, dim=2) + data2d(ungridded_index,i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + else + call ESMF_FieldGet(lfield, farrayPtr=data1d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + do i = 1,size(data1d) + data1d(i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + + if (fldname == 'So_omask') then + do i = 1,size(data1d) + !data1d(i) = float(nint(min(1.0_R8,max(0.0_R8,data1d(i))))) + data1d(i) = 0._r8 + end do + end if + + end subroutine field_setexport + + !=============================================================================== + + subroutine ModelFinalize(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' + !------------------------------------------------------------------------------- + + !-------------------------------- + ! Finalize routine + !-------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call dead_final_nuopc('ocn', logunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelFinalize + + !=============================================================================== + +end module ocn_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib new file mode 120000 index 000000000..9601a6fa7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib @@ -0,0 +1 @@ +../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake new file mode 120000 index 000000000..292ce33d2 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake @@ -0,0 +1 @@ +../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml new file mode 100755 index 000000000..182cf39ef --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +""" +build data model library +""" + +import sys, os + +_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) + +from standard_script_setup import * +from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.case import Case + +def buildnml(case, caseroot, compname): + if compname != "xrof": + raise AttributeError + build_xcpl_nml(case, caseroot, compname) + +def _main_func(): + caseroot = parse_input(sys.argv) + with Case(caseroot) as case: + buildnml(case, caseroot, "xrof") + +if __name__ == "__main__": + _main_func() diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml b/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml new file mode 100644 index 000000000..e1663cbbb --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml @@ -0,0 +1,39 @@ + + + + + + + Dead river component + + + + char + xrof + xrof + case_comp + env_case.xml + Name of river component + + + + char + ACTIVE,NULL + NULL + + ACTIVE + ACTIVE + + build_component_xrof + env_build.xml + mode for xrof flood feature, NULL means xrof flood is turned off + + + + + ========================================= + XROF naming conventions in compset name + ========================================= + + + diff --git a/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 new file mode 100644 index 000000000..0a50403eb --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 @@ -0,0 +1,511 @@ +module rof_comp_nuopc + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for XROF + !---------------------------------------------------------------------------- + + use ESMF + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index + use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + + implicit none + private ! except + + public :: SetServices + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + character(len=CL) :: 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 :: fldsToRof_num = 0 + integer :: fldsFrRof_num = 0 + type (fld_list_type) :: fldsToRof(fldsMax) + type (fld_list_type) :: fldsFrRof(fldsMax) + integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost + + real(r8), pointer :: gbuf(:,:) ! model info + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer , allocatable :: gindex(:) + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi + 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 + integer ,parameter :: master_task=0 ! task number of master task + logical :: mastertask + integer :: dbug = 1 + character(*),parameter :: modName = "(xrof_comp_nuopc)" + character(*),parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! 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=ModelInitPhase, 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=ModelSetRunClock, 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, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + 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 + type(ESMF_VM) :: vm + character(CS) :: stdname + integer :: n + integer :: lsize ! local array size + integer :: shrlogunit ! original log unit + character(CL) :: cvalue + character(len=CL) :: logmsg + logical :: isPresent, isSet + character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localpet=my_task, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + mastertask = my_task == master_task + + !---------------------------------------------------------------------------- + ! determine instance information + !---------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Initialize xrof + !---------------------------------------------------------------------------- + + call dead_init_nuopc('rof', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + allocate(gindex(lsize)) + allocate(lon(lsize)) + allocate(lat(lsize)) + + gindex(:) = gbuf(:,dead_grid_index) + lat(:) = gbuf(:,dead_grid_lat) + lon(:) = gbuf(:,dead_grid_lon) + + !-------------------------------- + ! advertise import and export fields + !-------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + flds_scalar_name = trim(cvalue) + call ESMF_LogWrite(trim(subname)//' flds_scalar_name = '//trim(flds_scalar_name), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldName') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldCount", 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_num + write(logmsg,*) flds_scalar_num + call ESMF_LogWrite(trim(subname)//' flds_scalar_num = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldCount') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNX", 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_nx + write(logmsg,*) flds_scalar_index_nx + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nx = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNX') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNY", 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_ny + write(logmsg,*) flds_scalar_index_ny + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_ny = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') + endif + + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrRof_num, fldsFrRof, trim(flds_scalar_name)) + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Forr_rofl') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Forr_rofi') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_flood') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_volr') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_volrmch') + + call fld_list_add(fldsToRof_num, fldsToRof, trim(flds_scalar_name)) + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofsur') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofgwl') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofsub') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofdto') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofi') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_irrig') + + do n = 1,fldsFrRof_num + if(mastertask) write(logunit,*)'Advertising From Xrof ',trim(fldsFrRof(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrRof(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + do n = 1,fldsToRof_num + if(mastertask) write(logunit,*)'Advertising To Xrof',trim(fldsToRof(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToRof(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) + + end subroutine InitializeAdvertise + + !=============================================================================== + + subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) + + ! input/output arguments + type(ESMF_GridComp) :: gcomp + type(ESMF_State) :: importState, exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + + ! local variables + type(ESMF_Mesh) :: Emesh + integer :: n + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logUnit) + + !-------------------------------- + ! generate the mesh + !-------------------------------- + + call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! realize the actively coupled fields, now that a mesh is established + ! 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 fld_list_realize( & + state=ExportState, & + fldlist=fldsFrRof, & + numflds=fldsFrRof_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':drofExport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fld_list_realize( & + state=importState, & + fldList=fldsToRof, & + numflds=fldsToRof_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':drofImport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call State_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeRealize + + !=============================================================================== + + subroutine ModelAdvance(gcomp, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + if (dbug > 5) then + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + end if + call memcheck(subname, 3, mastertask) + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetExport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call State_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (mastertask) then + call log_clock_advance(clock, 'XROF', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) then + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + end if + + end subroutine ModelAdvance + + !=============================================================================== + + subroutine state_setexport(exportState, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer, intent(out) :: rc + + ! local variables + integer :: nf, nind + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Start from index 2 in order to skip the scalar field + do nf = 2,fldsFrRof_num + if (fldsFrRof(nf)%ungridded_ubound == 0) then + call field_setexport(exportState, trim(fldsFrRof(nf)%stdname), lon, lat, nf=nf, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + do nind = 1,fldsFrRof(nf)%ungridded_ubound + call field_setexport(exportState, trim(fldsFrRof(nf)%stdname), lon, lat, nf=nf+nind-1, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + + end subroutine state_setexport + + !=============================================================================== + + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) + + use shr_const_mod , only : pi=>shr_const_pi + + ! intput/otuput variables + type(ESMF_State) , intent(inout) :: exportState + character(len=*) , intent(in) :: fldname + real(r8) , intent(in) :: lon(:) + real(r8) , intent(in) :: lat(:) + integer , intent(in) :: nf + integer, optional , intent(in) :: ungridded_index + integer , intent(out) :: rc + + ! local variables + integer :: i, ncomp + type(ESMF_Field) :: lfield + real(r8), pointer :: data1d(:) + real(r8), pointer :: data2d(:,:) + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemName=trim(fldname), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ncomp = 6 + if (present(ungridded_index)) then + call ESMF_FieldGet(lfield, farrayPtr=data2d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (gridToFieldMap == 1) then + do i = 1,size(data2d, dim=1) + data2d(i,ungridded_index) = (nf+1) * 1.0_r8 + end do + else if (gridToFieldMap == 2) then + do i = 1,size(data2d, dim=2) + data2d(ungridded_index,i) = (nf+1) * 1.0_r8 + end do + end if + else + call ESMF_FieldGet(lfield, farrayPtr=data1d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + do i = 1,size(data1d) + data1d(i) = (nf+1) * 1.0_r8 + end do + end if + + end subroutine field_setexport + + !=============================================================================== + + subroutine ModelFinalize(gcomp, rc) + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' + !------------------------------------------------------------------------------- + + !-------------------------------- + ! Finalize routine + !-------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call dead_final_nuopc('rof', logunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelFinalize + +end module rof_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 b/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 new file mode 100644 index 000000000..d8b55abd8 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 @@ -0,0 +1,840 @@ +module dead_methods_mod + + use ESMF , only : operator(<), operator(/=), operator(+) + use ESMF , only : operator(-), operator(*) , operator(>=) + use ESMF , only : operator(<=), operator(>), operator(==) + use ESMF , only : ESMF_LOGERR_PASSTHRU, ESMF_LogFoundError, ESMF_LOGMSG_ERROR, ESMF_MAXSTR + use ESMF , only : ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_FAILURE + use ESMF , only : ESMF_State, ESMF_StateGet + use ESMF , only : ESMF_Field, ESMF_FieldGet + use ESMF , only : ESMF_GridComp, ESMF_GridCompGet, ESMF_GridCompSet + use ESMF , only : ESMF_GeomType_Flag, ESMF_FieldStatus_Flag + use ESMF , only : ESMF_Mesh, ESMF_MeshGet + use ESMF , only : ESMF_GEOMTYPE_MESH, ESMF_GEOMTYPE_GRID, ESMF_FIELDSTATUS_COMPLETE + use ESMF , only : ESMF_Clock, ESMF_ClockCreate, ESMF_ClockGet, ESMF_ClockSet + use ESMF , only : ESMF_ClockPrint, ESMF_ClockAdvance + use ESMF , only : ESMF_Alarm, ESMF_AlarmCreate, ESMF_AlarmGet, ESMF_AlarmSet + use ESMF , only : ESMF_Calendar, ESMF_CALKIND_NOLEAP, ESMF_CALKIND_GREGORIAN + use ESMF , only : ESMF_Time, ESMF_TimeGet, ESMF_TimeSet + use ESMF , only : ESMF_TimeInterval, ESMF_TimeIntervalSet, ESMF_TimeIntervalGet + use ESMF , only : ESMF_VM, ESMF_VMGet, ESMF_VMBroadcast, ESMF_VMGetCurrent + use NUOPC , only : NUOPC_CompAttributeGet + use NUOPC_Model , only : NUOPC_ModelGet + use shr_kind_mod , only : r8 => shr_kind_r8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_sys_mod , only : shr_sys_abort + use shr_file_mod , only : shr_file_setlogunit, shr_file_getLogUnit + + implicit none + private + + public :: memcheck + public :: get_component_instance + public :: set_component_logging + public :: log_clock_advance + public :: state_getscalar + public :: state_setscalar + public :: state_diagnose + public :: alarmInit + public :: chkerr + + private :: timeInit + private :: field_getfldptr + + ! Clock and alarm options + character(len=*), private, parameter :: & + optNONE = "none" , & + optNever = "never" , & + optNSteps = "nsteps" , & + optNStep = "nstep" , & + optNSeconds = "nseconds" , & + optNSecond = "nsecond" , & + optNMinutes = "nminutes" , & + optNMinute = "nminute" , & + optNHours = "nhours" , & + optNHour = "nhour" , & + optNDays = "ndays" , & + optNDay = "nday" , & + optNMonths = "nmonths" , & + optNMonth = "nmonth" , & + optNYears = "nyears" , & + optNYear = "nyear" , & + optMonthly = "monthly" , & + optYearly = "yearly" , & + optDate = "date" , & + optIfdays0 = "ifdays0" + + ! Module data + integer, parameter :: SecPerDay = 86400 ! Seconds per day + integer, parameter :: memdebug_level=1 + character(len=1024) :: msgString + character(len=*), parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine memcheck(string, level, mastertask) + + ! input/output variables + character(len=*) , intent(in) :: string + integer , intent(in) :: level + logical , intent(in) :: mastertask + + ! local variables + integer :: ierr + integer, external :: GPTLprint_memusage + !----------------------------------------------------------------------- + + if ((mastertask .and. memdebug_level > level) .or. memdebug_level > level+1) then + ierr = GPTLprint_memusage(string) + endif + + end subroutine memcheck + +!=============================================================================== + + subroutine get_component_instance(gcomp, inst_suffix, inst_index, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + character(len=*) , intent(out) :: inst_suffix + integer , intent(out) :: inst_index + integer , intent(out) :: rc + + ! local variables + logical :: isPresent + character(len=4) :: cvalue + !----------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + call NUOPC_CompAttributeGet(gcomp, name="inst_suffix", isPresent=isPresent, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (isPresent) then + call NUOPC_CompAttributeGet(gcomp, name="inst_suffix", value=inst_suffix, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + cvalue = inst_suffix(2:) + read(cvalue, *) inst_index + else + inst_suffix = "" + inst_index=1 + endif + + end subroutine get_component_instance + +!=============================================================================== + + subroutine set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + logical, intent(in) :: mastertask + integer, intent(out) :: logunit + integer, intent(out) :: shrlogunit + integer, intent(out) :: rc + + ! local variables + character(len=CL) :: diro + character(len=CL) :: logfile + !----------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + shrlogunit = 6 + + if (mastertask) then + call NUOPC_CompAttributeGet(gcomp, name="diro", value=diro, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call NUOPC_CompAttributeGet(gcomp, name="logfile", value=logfile, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + open(newunit=logunit,file=trim(diro)//"/"//trim(logfile)) + else + logUnit = 6 + endif + + call shr_file_setLogUnit (logunit) + + end subroutine set_component_logging + +!=============================================================================== + + subroutine log_clock_advance(clock, component, logunit, rc) + + ! input/output variables + type(ESMF_Clock) :: clock + character(len=*) , intent(in) :: component + integer , intent(in) :: logunit + integer , intent(out) :: rc + + ! local variables + character(len=CL) :: cvalue, prestring + !----------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + write(prestring, *) "------>Advancing ",trim(component)," from: " + call ESMF_ClockPrint(clock, options="currTime", unit=cvalue, preString=trim(prestring), rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + write(logunit, *) trim(cvalue) + + call ESMF_ClockPrint(clock, options="stopTime", unit=cvalue, & + preString="--------------------------------> to: ", rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + write(logunit, *) trim(cvalue) + + end subroutine log_clock_advance + +!=============================================================================== + + subroutine state_getscalar(state, scalar_id, scalar_value, flds_scalar_name, flds_scalar_num, rc) + + ! ---------------------------------------------- + ! Get scalar data from State for a particular name and broadcast it to all other pets + ! ---------------------------------------------- + + ! input/output variables + type(ESMF_State), intent(in) :: state + integer, intent(in) :: scalar_id + real(r8), intent(out) :: scalar_value + character(len=*), intent(in) :: flds_scalar_name + integer, intent(in) :: flds_scalar_num + integer, intent(inout) :: rc + + ! local variables + integer :: mytask, ierr, len + type(ESMF_VM) :: vm + type(ESMF_Field) :: field + real(r8), pointer :: farrayptr(:,:) + real(r8) :: tmp(1) + character(len=*), parameter :: subname='(state_getscalar)' + ! ---------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_VMGetCurrent(vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localPet=mytask, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_StateGet(State, itemName=trim(flds_scalar_name), field=field, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (mytask == 0) then + call ESMF_FieldGet(field, farrayPtr = farrayptr, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (scalar_id < 0 .or. scalar_id > flds_scalar_num) then + call ESMF_LogWrite(trim(subname)//": ERROR in scalar_id", ESMF_LOGMSG_INFO, line=__LINE__, file=u_FILE_u) + rc = ESMF_FAILURE + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + endif + tmp(:) = farrayptr(scalar_id,:) + endif + call ESMF_VMBroadCast(vm, tmp, 1, 0, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + scalar_value = tmp(1) + + end subroutine state_getscalar + +!================================================================================ + + subroutine state_setscalar(scalar_value, scalar_id, State, flds_scalar_name, flds_scalar_num, rc) + + ! ---------------------------------------------- + ! Set scalar data from State for a particular name + ! ---------------------------------------------- + + ! input/output arguments + real(r8), intent(in) :: scalar_value + integer, intent(in) :: scalar_id + type(ESMF_State), intent(inout) :: State + character(len=*), intent(in) :: flds_scalar_name + integer, intent(in) :: flds_scalar_num + integer, intent(inout) :: rc + + ! local variables + integer :: mytask + type(ESMF_Field) :: lfield + type(ESMF_VM) :: vm + real(r8), pointer :: farrayptr(:,:) + character(len=*), parameter :: subname='(state_setscalar)' + ! ---------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_VMGetCurrent(vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localPet=mytask, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_StateGet(State, itemName=trim(flds_scalar_name), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (mytask == 0) then + call ESMF_FieldGet(lfield, farrayPtr = farrayptr, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (scalar_id < 0 .or. scalar_id > flds_scalar_num) then + call ESMF_LogWrite(trim(subname)//": ERROR in scalar_id", ESMF_LOGMSG_INFO) + rc = ESMF_FAILURE + return + endif + farrayptr(scalar_id,1) = scalar_value + endif + + end subroutine state_setscalar + +!=============================================================================== + + subroutine state_diagnose(State, string, rc) + + ! ---------------------------------------------- + ! Diagnose status of State + ! ---------------------------------------------- + + type(ESMF_State), intent(in) :: state + character(len=*), intent(in) :: string + integer , intent(out) :: rc + + ! local variables + integer :: i,j,n + type(ESMf_Field) :: lfield + integer :: fieldCount, lrank + character(ESMF_MAXSTR) ,pointer :: lfieldnamelist(:) + real(r8), pointer :: dataPtr1d(:) + real(r8), pointer :: dataPtr2d(:,:) + character(len=*),parameter :: subname='(state_diagnose)' + ! ---------------------------------------------- + + call ESMF_StateGet(state, itemCount=fieldCount, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + allocate(lfieldnamelist(fieldCount)) + + call ESMF_StateGet(state, itemNameList=lfieldnamelist, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + do n = 1, fieldCount + + call ESMF_StateGet(state, itemName=lfieldnamelist(n), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call field_getfldptr(lfield, fldptr1=dataPtr1d, fldptr2=dataPtr2d, rank=lrank, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (lrank == 0) then + ! no local data + elseif (lrank == 1) then + if (size(dataPtr1d) > 0) then + write(msgString,'(A,3g14.7,i8)') trim(string)//': '//trim(lfieldnamelist(n)), & + minval(dataPtr1d), maxval(dataPtr1d), sum(dataPtr1d), size(dataPtr1d) + else + write(msgString,'(A,a)') trim(string)//': '//trim(lfieldnamelist(n))," no data" + endif + elseif (lrank == 2) then + if (size(dataPtr2d) > 0) then + write(msgString,'(A,3g14.7,i8)') trim(string)//': '//trim(lfieldnamelist(n)), & + minval(dataPtr2d), maxval(dataPtr2d), sum(dataPtr2d), size(dataPtr2d) + else + write(msgString,'(A,a)') trim(string)//': '//trim(lfieldnamelist(n))," no data" + endif + else + call ESMF_LogWrite(trim(subname)//": ERROR rank not supported ", ESMF_LOGMSG_ERROR) + rc = ESMF_FAILURE + return + endif + call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) + enddo + + deallocate(lfieldnamelist) + + end subroutine state_diagnose + +!=============================================================================== + + subroutine field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) + + ! ---------------------------------------------- + ! for a field, determine rank and return fldptr1 or fldptr2 + ! abort is true by default and will abort if fldptr is not yet allocated in field + ! rank returns 0, 1, or 2. 0 means fldptr not allocated and abort=false + ! ---------------------------------------------- + + ! input/output variables + type(ESMF_Field) , intent(in) :: field + real(r8), pointer , intent(inout), optional :: fldptr1(:) + real(r8), pointer , intent(inout), optional :: fldptr2(:,:) + integer , intent(out) , optional :: rank + logical , intent(in) , optional :: abort + integer , intent(out) , optional :: rc + + ! local variables + type(ESMF_GeomType_Flag) :: geomtype + type(ESMF_FieldStatus_Flag) :: status + type(ESMF_Mesh) :: lmesh + integer :: lrank, nnodes, nelements + logical :: labort + character(len=*), parameter :: subname='(field_getfldptr)' + ! ---------------------------------------------- + + if (.not.present(rc)) then + call ESMF_LogWrite(trim(subname)//": ERROR rc not present ", & + ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) + rc = ESMF_FAILURE + return + endif + + rc = ESMF_SUCCESS + + labort = .true. + if (present(abort)) then + labort = abort + endif + lrank = -99 + + call ESMF_FieldGet(field, status=status, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (status /= ESMF_FIELDSTATUS_COMPLETE) then + lrank = 0 + if (labort) then + call ESMF_LogWrite(trim(subname)//": ERROR data not allocated ", ESMF_LOGMSG_INFO, rc=rc) + rc = ESMF_FAILURE + return + else + call ESMF_LogWrite(trim(subname)//": WARNING data not allocated ", ESMF_LOGMSG_INFO, rc=rc) + endif + else + + call ESMF_FieldGet(field, geomtype=geomtype, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (geomtype == ESMF_GEOMTYPE_GRID) then + call ESMF_FieldGet(field, rank=lrank, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + elseif (geomtype == ESMF_GEOMTYPE_MESH) then + call ESMF_FieldGet(field, rank=lrank, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldGet(field, mesh=lmesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_MeshGet(lmesh, numOwnedNodes=nnodes, numOwnedElements=nelements, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (nnodes == 0 .and. nelements == 0) lrank = 0 + else + call ESMF_LogWrite(trim(subname)//": ERROR geomtype not supported ", & + ESMF_LOGMSG_INFO, rc=rc) + rc = ESMF_FAILURE + return + endif ! geomtype + + if (lrank == 0) then + call ESMF_LogWrite(trim(subname)//": no local nodes or elements ", & + ESMF_LOGMSG_INFO) + elseif (lrank == 1) then + if (.not.present(fldptr1)) then + call ESMF_LogWrite(trim(subname)//": ERROR missing rank=1 array ", & + ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) + rc = ESMF_FAILURE + return + endif + call ESMF_FieldGet(field, farrayPtr=fldptr1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + elseif (lrank == 2) then + if (.not.present(fldptr2)) then + call ESMF_LogWrite(trim(subname)//": ERROR missing rank=2 array ", & + ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) + rc = ESMF_FAILURE + return + endif + call ESMF_FieldGet(field, farrayPtr=fldptr2, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + call ESMF_LogWrite(trim(subname)//": ERROR in rank ", & + ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) + rc = ESMF_FAILURE + return + endif + + endif ! status + + if (present(rank)) then + rank = lrank + endif + + end subroutine field_getfldptr + +!=============================================================================== + + subroutine alarmInit( clock, alarm, option, & + opt_n, opt_ymd, opt_tod, RefTime, alarmname, rc) + + ! Setup an alarm in a clock + ! Notes: The ringtime sent to AlarmCreate MUST be the next alarm + ! time. If you send an arbitrary but proper ringtime from the + ! past and the ring interval, the alarm will always go off on the + ! next clock advance and this will cause serious problems. Even + ! if it makes sense to initialize an alarm with some reference + ! time and the alarm interval, that reference time has to be + ! advance forward to be >= the current time. In the logic below + ! we set an appropriate "NextAlarm" and then we make sure to + ! advance it properly based on the ring interval. + + ! input/output variables + type(ESMF_Clock) , intent(inout) :: clock ! clock + type(ESMF_Alarm) , intent(inout) :: alarm ! alarm + character(len=*) , intent(in) :: option ! alarm option + integer , optional , intent(in) :: opt_n ! alarm freq + integer , optional , intent(in) :: opt_ymd ! alarm ymd + integer , optional , intent(in) :: opt_tod ! alarm tod (sec) + type(ESMF_Time) , optional , intent(in) :: RefTime ! ref time + character(len=*) , optional , intent(in) :: alarmname ! alarm name + integer , intent(inout) :: rc ! Return code + + ! local variables + type(ESMF_Calendar) :: cal ! calendar + integer :: lymd ! local ymd + integer :: ltod ! local tod + integer :: cyy,cmm,cdd,csec ! time info + character(len=64) :: lalarmname ! local alarm name + logical :: update_nextalarm ! update next alarm + type(ESMF_Time) :: CurrTime ! Current Time + type(ESMF_Time) :: NextAlarm ! Next restart alarm time + type(ESMF_TimeInterval) :: AlarmInterval ! Alarm interval + integer :: sec + character(len=*), parameter :: subname = '(set_alarmInit): ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + lalarmname = 'alarm_unknown' + if (present(alarmname)) lalarmname = trim(alarmname) + ltod = 0 + if (present(opt_tod)) ltod = opt_tod + lymd = -1 + if (present(opt_ymd)) lymd = opt_ymd + + call ESMF_ClockGet(clock, CurrTime=CurrTime, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_TimeGet(CurrTime, yy=cyy, mm=cmm, dd=cdd, s=csec, rc=rc ) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! initial guess of next alarm, this will be updated below + if (present(RefTime)) then + NextAlarm = RefTime + else + NextAlarm = CurrTime + endif + + ! Determine calendar + call ESMF_ClockGet(clock, calendar=cal) + + ! Determine inputs for call to create alarm + selectcase (trim(option)) + + case (optNONE) + call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_TimeSet( NextAlarm, yy=9999, mm=12, dd=1, s=0, calendar=cal, rc=rc ) + if (chkerr(rc,__LINE__,u_FILE_u)) return + update_nextalarm = .false. + + case (optNever) + call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_TimeSet( NextAlarm, yy=9999, mm=12, dd=1, s=0, calendar=cal, rc=rc ) + if (chkerr(rc,__LINE__,u_FILE_u)) return + update_nextalarm = .false. + + case (optDate) + if (.not. present(opt_ymd)) then + call shr_sys_abort(subname//trim(option)//' requires opt_ymd') + end if + if (lymd < 0 .or. ltod < 0) then + call shr_sys_abort(subname//trim(option)//'opt_ymd, opt_tod invalid') + end if + call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call timeInit(NextAlarm, lymd, cal, ltod, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + update_nextalarm = .false. + + case (optIfdays0) + if (.not. present(opt_ymd)) then + call shr_sys_abort(subname//trim(option)//' requires opt_ymd') + end if + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_TimeSet( NextAlarm, yy=cyy, mm=cmm, dd=opt_n, s=0, calendar=cal, rc=rc ) + if (chkerr(rc,__LINE__,u_FILE_u)) return + update_nextalarm = .true. + + case (optNSteps) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNStep) + if (.not.present(opt_n)) call shr_sys_abort(subname//trim(option)//' requires opt_n') + if (opt_n <= 0) call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNSeconds) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNSecond) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNMinutes) + call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNMinute) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNHours) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNHour) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNDays) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNDay) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNMonths) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNMonth) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optMonthly) + call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_TimeSet( NextAlarm, yy=cyy, mm=cmm, dd=1, s=0, calendar=cal, rc=rc ) + if (chkerr(rc,__LINE__,u_FILE_u)) return + update_nextalarm = .true. + + case (optNYears) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optNYear) + if (.not.present(opt_n)) then + call shr_sys_abort(subname//trim(option)//' requires opt_n') + end if + if (opt_n <= 0) then + call shr_sys_abort(subname//trim(option)//' invalid opt_n') + end if + call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + AlarmInterval = AlarmInterval * opt_n + update_nextalarm = .true. + + case (optYearly) + call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_TimeSet( NextAlarm, yy=cyy, mm=1, dd=1, s=0, calendar=cal, rc=rc ) + if (chkerr(rc,__LINE__,u_FILE_u)) return + update_nextalarm = .true. + + case default + call shr_sys_abort(subname//'unknown option '//trim(option)) + + end select + + ! -------------------------------------------------------------------------------- + ! --- AlarmInterval and NextAlarm should be set --- + ! -------------------------------------------------------------------------------- + + ! --- advance Next Alarm so it won't ring on first timestep for + ! --- most options above. go back one alarminterval just to be careful + + if (update_nextalarm) then + NextAlarm = NextAlarm - AlarmInterval + do while (NextAlarm <= CurrTime) + NextAlarm = NextAlarm + AlarmInterval + enddo + endif + + alarm = ESMF_AlarmCreate( name=lalarmname, clock=clock, ringTime=NextAlarm, & + ringInterval=AlarmInterval, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + end subroutine alarmInit + +!=============================================================================== + + subroutine timeInit( Time, ymd, cal, tod, rc) + + ! Create the ESMF_Time object corresponding to the given input time, + ! given in YMD (Year Month Day) and TOD (Time-of-day) format. + ! Set the time by an integer as YYYYMMDD and integer seconds in the day + + ! input/output parameters: + type(ESMF_Time) , intent(inout) :: Time ! ESMF time + integer , intent(in) :: ymd ! year, month, day YYYYMMDD + type(ESMF_Calendar) , intent(in) :: cal ! ESMF calendar + integer , intent(in) :: tod ! time of day in seconds + integer , intent(out) :: rc + + ! local variables + integer :: year, mon, day ! year, month, day as integers + integer :: tdate ! temporary date + integer :: date ! coded-date (yyyymmdd) + character(len=*), parameter :: subname='(timeInit)' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + if ( (ymd < 0) .or. (tod < 0) .or. (tod > SecPerDay) )then + call shr_sys_abort( subname//'ERROR yymmdd is a negative number or time-of-day out of bounds' ) + end if + + tdate = abs(date) + year = int(tdate/10000) + if (date < 0) year = -year + mon = int( mod(tdate,10000)/ 100) + day = mod(tdate, 100) + + call ESMF_TimeSet( Time, yy=year, mm=mon, dd=day, s=tod, calendar=cal, rc=rc ) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + end subroutine timeInit + +!=============================================================================== + + logical function chkerr(rc, line, file) + + integer, intent(in) :: rc + integer, intent(in) :: line + character(len=*), intent(in) :: file + + integer :: lrc + + chkerr = .false. + lrc = rc + if (ESMF_LogFoundError(rcToCheck=lrc, msg=ESMF_LOGERR_PASSTHRU, line=line, file=file)) then + chkerr = .true. + endif + end function chkerr + +!=============================================================================== + +end module dead_methods_mod diff --git a/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 b/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 new file mode 100644 index 000000000..981113760 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 @@ -0,0 +1,907 @@ +module dead_nuopc_mod + + use ESMF , only : ESMF_Gridcomp, ESMF_State, ESMF_StateGet + use ESMF , only : ESMF_Clock, ESMF_Time, ESMF_TimeInterval, ESMF_Alarm + use ESMF , only : ESMF_GridCompGet, ESMF_ClockGet, ESMF_ClockSet, ESMF_ClockAdvance, ESMF_AlarmSet + use ESMF , only : ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_METHOD_INITIALIZE + use ESMF , only : ESMF_FAILURE, ESMF_LOGMSG_ERROR + use ESMF , only : ESMF_VMGetCurrent, ESMF_VM, ESMF_VMBroadcast, ESMF_VMGet + use ESMF , only : ESMF_VM, ESMF_VMGetCurrent, ESMF_VmGet + use ESMF , only : operator(/=), operator(==), operator(+) + 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 dead_methods_mod , only : chkerr, alarmInit + + implicit none + private + + public :: dead_init_nuopc + public :: dead_final_nuopc + public :: dead_meshinit + public :: ModelInitPhase + public :: ModelSetRunClock + public :: fld_list_add + public :: fld_list_realize + + ! !PUBLIC DATA MEMBERS: + integer, public :: dead_grid_lat = 1 ! lat from component + integer, public :: dead_grid_lon = 2 ! lon from component + integer, public :: dead_grid_area = 3 ! area from component + integer, public :: dead_grid_mask = 4 ! mask, 0 = inactive cell + integer, public :: dead_grid_frac = 5 ! fractional area coverage + integer, public :: dead_grid_index = 6 ! global index + integer, public :: dead_grid_total = 6 + + type fld_list_type + character(len=128) :: stdname + integer :: ungridded_lbound = 0 + integer :: ungridded_ubound = 0 + end type fld_list_type + public :: fld_list_type + + integer, parameter, public :: fldsMax = 100 + integer :: dbug_flag = 0 + character(*), parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine dead_read_inparms(model, inst_suffix, logunit, & + nxg, nyg, decomp_type, nproc_x, seg_len) + + ! input/output variables + character(len=*) , intent(in) :: model + character(len=*) , intent(in) :: inst_suffix ! char string associated with instance + integer , intent(in) :: logunit ! logging unit number + integer , intent(out) :: nproc_x + integer , intent(out) :: seg_len + integer , intent(out) :: nxg ! global dim i-direction + integer , intent(out) :: nyg ! global dim j-direction + integer , intent(out) :: decomp_type ! decomposition type + + ! local variables + type(ESMF_VM) :: vm + character(CL) :: fileName ! generic file name + integer :: nunit ! unit number + integer :: unitn ! Unit for namelist file + integer :: tmp(5) ! array for broadcast + integer :: localPet ! mpi id of current task in current context + integer :: rc ! return code + character(*), parameter :: F00 = "('(dead_read_inparms) ',8a)" + character(*), parameter :: F01 = "('(dead_read_inparms) ',a,a,4i8)" + character(*), parameter :: F03 = "('(dead_read_inparms) ',a,a,i8,a)" + character(*), parameter :: subName = "(dead_read_inpamrs) " + !------------------------------------------------------------------------------- + + ! read the input parms (used to configure model) + nxg = -9999 + nyg = -9999 + nproc_x = -9999 + seg_len = -9999 + decomp_type = -9999 + + call ESMF_VMGetCurrent(vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMGet(vm, localPet=localPet, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (localPet==0) then + open(newunit=unitn, file='x'//model//'_in'//trim(inst_suffix), status='old' ) + read(unitn,*) nxg + read(unitn,*) nyg + read(unitn,*) decomp_type + read(unitn,*) nproc_x + read(unitn,*) seg_len + close (unitn) + endif + + tmp(1) = nxg + tmp(2) = nyg + tmp(3) = decomp_type + tmp(4) = nproc_x + tmp(5) = seg_len + + call ESMF_VMBroadcast(vm, tmp, 6, 0, rc=rc) + + nxg = tmp(1) + nyg = tmp(2) + decomp_type = tmp(3) + nproc_x = tmp(4) + seg_len = tmp(5) + + if (localPet==0) then + write(logunit,*)' Read in X'//model//' input from file= x'//model//'_in' + write(logunit,F00) model + write(logunit,F00) model,' Model : ',model + write(logunit,F01) model,' NGX : ',nxg + write(logunit,F01) model,' NGY : ',nyg + write(logunit,F01) model,' Decomposition : ',decomp_type + write(logunit,F03) model,' Num pes in X : ',nproc_x,' (type 3 only)' + write(logunit,F03) model,' Segment Length : ',seg_len,' (type 11 only)' + write(logunit,F00) model,' inst_suffix : ',trim(inst_suffix) + write(logunit,F00) model + end if + + end subroutine dead_read_inparms + + !=============================================================================== + + subroutine dead_setNewGrid(decomp_type, nxg, nyg, logunit, lsize, gbuf, seg_len, nproc_x) + + ! This sets up some defaults. The user may want to overwrite some + ! of these fields in the main program after initialization in complete. + + use shr_const_mod , only : shr_const_pi, shr_const_rearth + + ! input/output parameters: + integer , intent(in) :: decomp_type ! + integer , intent(in) :: nxg,nyg ! global grid sizes + integer , intent(in) :: logunit ! output logunit + integer , intent(out) :: lsize ! local grid sizes + real(R8), pointer :: gbuf(:,:) ! output data + integer , intent(in),optional :: seg_len ! seg len decomp setting + integer , intent(in),optional :: nproc_x ! 2d decomp setting + + ! local + type(ESMF_VM) :: vm + integer :: rc + integer :: mype + integer :: totpe ! total number of pes + logical :: found + integer :: i,j,ig,jg + integer :: n,ng,is,ie,js,je,nx,ny + integer :: npesx,npesy,mypex,mypey,nxp,nyp + real(R8) :: hscore,bscore + real(R8) :: dx,dy,deg2rad,ys,yc,yn,area,re + integer, allocatable :: gindex(:) + character(*), parameter :: F00 = "('(dead_setNewGrid) ',8a)" + character(*), parameter :: F01 = "('(dead_setNewGrid) ',a,4i8)" + character(*), parameter :: subName = "(dead_setNewGrid) " + !------------------------------------------------------------------------------- + + call ESMF_VMGetCurrent(vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMGet(vm, localPet=mype, peCount=totpe, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if ( decomp_type == 1 .or. & + decomp_type == 2 .or. & + decomp_type == 3 .or. & + decomp_type == 4 .or. & + decomp_type == 11) then + else + ! invalid decomposition type + if (mype == 0) then + write(logunit,F01) 'ERROR: invalid decomp_type = ',decomp_type + end if + call shr_sys_abort(subName//'invalid decomp_type') + endif + + if (nxg*nyg == 0) then + lsize = 0 + allocate(gbuf(lsize,dead_grid_total)) + if (mype == 0) then + write(logunit,*) subname,' grid size is zero, lsize = ',lsize + end if + return + endif + + found = .false. + + if (decomp_type == 1) then ! 1d decomp by lat + npesx = 1 + npesy = totpe + found = .true. + elseif (decomp_type == 2) then ! 1d decomp by lon + npesx = totpe + npesy = 1 + found = .true. + elseif (decomp_type == 3) then ! 2d decomp + if (present(nproc_x)) then + if ( nproc_x > 0 ) then + npesx=nproc_x + npesy=totpe/npesx + if ( npesx*npesy /= totpe) then + write(logunit,F00) 'ERROR: uneven decomposition' + call shr_sys_abort(subName//'uneven decomp') + end if + found = .true. + endif + endif + if (.not.found) then ! narrow blocks + do nx = 1,totpe + ny = totpe/nx + if (nx*ny == totpe) then + npesx = nx + npesy = ny + found = .true. + endif + enddo + endif + elseif (decomp_type == 4) then ! 2d evenly divisible square block decomp + hscore = nxg*nyg + do nx = 1,totpe + ny = totpe/nx + if (nx*ny == totpe .and. mod(nxg,nx) == 0 .and. mod(nyg,ny) == 0) then + bscore = ((nxg*ny*1.0_r8) / (nyg*nx*1.0_r8)) - 1.0_r8 + bscore = bscore * bscore + if (bscore < hscore .or. .not.found) then + hscore = bscore + npesx = nx + npesy = ny + found = .true. + endif + endif + enddo + endif + + if (found) then + nx = nxg/npesx + mypex = mod(mype,npesx) + mypey = mype/npesx + is = (mypex ) * (nx) + 1 + ie = (mypex + 1) * (nx) + + ny = nyg/npesy + js = (mypey ) * (ny) + 1 + je = (mypey + 1) * (ny) + + nxp = nxg - (nx*npesx) ! extra lons not accounted for yet + nyp = nyg - (ny*npesy) ! extra lats not accounted for yet + + is = is + min(mypex,nxp) ! add them to first few pes and shift everything + ie = ie + min(mypex+1,nxp) + js = js + min(mypey,nyp) ! add them to first few pes and shift everything + je = je + min(mypey+1,nyp) + + lsize = (ie - is + 1) * (je - js + 1) + + allocate(gindex(lsize)) + n = 0 + do j = js,je + do i = is,ie + n = n + 1 + gindex(n) = (j-1)*nxg + i + enddo + enddo + endif + + if (.not.found) then + !------------------------------------------------------------------------- + ! type 11 general segment decomp + !------------------------------------------------------------------------- + nx = nxg*nyg / (totpe*13) + 1 ! 13 segments per pe (arbitrary) + ! nx override with seg_len + if (present(seg_len)) then + if (seg_len > 0) nx = seg_len + endif + + n = 0 + i = 0 + lsize = 0 + do while (n < nxg*nyg) + ny = min(nx,nxg*nyg-n) + do j = 1,ny + n = n + 1 + if (mype == mod(i,totpe)) then + lsize = lsize + 1 + endif + enddo + i = i + 1 + enddo + + allocate(gindex(lsize)) + + n = 0 + i = 0 + lsize = 0 + do while (n < nxg*nyg) + ny = min(nx,nxg*nyg-n) + do j = 1,ny + n = n + 1 + if (mype == mod(i,totpe)) then + lsize = lsize + 1 + gindex(lsize) = n + endif + enddo + i = i + 1 + enddo + + if (mype == 0) then + write(logunit,*) 'dead_setNewGrid decomp seg ',mype,lsize,nx + end if + + found = .true. + + endif + + if ( .not.found ) then + write(logunit,F01) 'ERROR: with decomp nxg,nyg,totpe=',nxg,nyg,totpe + call shr_sys_abort(subName//'decomp') + endif + + deg2rad = shr_const_pi / 180.0_R8 + re = shr_const_rearth + + allocate(gbuf(lsize,dead_grid_total)) + gbuf = -888.0_R8 + if (mype == 0) then + write(logunit,*) subname,' Decomp is ',decomp_type,' lsize = ',lsize + end if + + n=0 + dx = 360.0_R8/nxg * deg2rad + do n = 1,lsize + ig = mod((gindex(n)-1),nxg) + 1 + jg = (gindex(n)-1)/nxg + 1 + + ys = -90.0_R8 + (jg-1.0_R8)*180.0_R8/(nyg) + yc = -90.0_R8 + (jg-0.5_R8)*180.0_R8/(nyg) + yn = -90.0_R8 + (jg-0.0_R8)*180.0_R8/(nyg) + dy = sin(yn*deg2rad) - sin(ys*deg2rad) + area = dx*dy*re*re + + gbuf(n,dead_grid_lon ) = (ig-1.0_R8)*360.0_R8/(nxg) + gbuf(n,dead_grid_lat ) = yc + gbuf(n,dead_grid_index) = gindex(n) + gbuf(n,dead_grid_area ) = area + gbuf(n,dead_grid_mask ) = 0 + gbuf(n,dead_grid_frac ) = 1.0_R8 + enddo + + deallocate(gindex) + + end subroutine dead_setNewGrid + + !=============================================================================== + + subroutine dead_init_nuopc(model, inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + ! input/output parameters: + character(len=*) , intent(in) :: model + character(len=*) , intent(in) :: inst_suffix ! char string associated with instance + integer , intent(in) :: logunit ! logging unit number + integer , intent(out) :: lsize ! logging unit number + real(r8) , pointer :: gbuf(:,:) ! model grid + integer , pointer :: gindex(:) ! global index space + integer , intent(out) :: nxg ! global dim i-direction + integer , intent(out) :: nyg ! global dim j-direction + + !--- local variables --- + integer :: local_comm ! local communicator + integer :: nproc_x + integer :: seg_len + integer :: decomp_type + character(*), parameter :: subName = "(dead_init_nuopc) " + !------------------------------------------------------------------------------- + + ! Read input parms + call dead_read_inparms(model, inst_suffix, logunit, nxg, nyg, decomp_type, nproc_x, seg_len) + + ! Initialize grid + call dead_setNewGrid(decomp_type, nxg, nyg, logunit, lsize, gbuf, seg_len, nproc_x) + + end subroutine dead_init_nuopc + + !=============================================================================== + + subroutine dead_final_nuopc(model, logunit) + + ! finalize method for xcpl component + + ! input/output parameters: + character(len=*) , intent(in) :: model + integer , intent(in) :: logunit ! logging unit number + + ! local variables + type(ESMF_VM) :: vm + integer :: rc + integer :: localPet + character(*), parameter :: F00 = "('(dead_comp_final) ',8a)" + character(*), parameter :: F91 = "('(dead_comp_final) ',73('-'))" + character(*), parameter :: subName = "(dead_comp_final) " + !------------------------------------------------------------------------------- + + call ESMF_VMGetCurrent(vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMGet(vm, localPet=localPet, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (localPet==0) then + write(logunit,F91) + write(logunit,F00) trim(model),': end of main integration loop' + write(logunit,F91) + end if + + end subroutine dead_final_nuopc + + !=============================================================================== + + subroutine fld_list_add(num, fldlist, stdname, ungridded_lbound, ungridded_ubound) + + ! input/output variables + integer , intent(inout) :: num + type(fld_list_type) , intent(inout) :: fldlist(:) + character(len=*) , intent(in) :: stdname + integer, optional , intent(in) :: ungridded_lbound + integer, optional , intent(in) :: ungridded_ubound + + ! local variables + character(len=*), parameter :: subname='(dead_nuopc_mod:fld_list_add)' + !------------------------------------------------------------------------------- + + ! Set up a list of field information + num = num + 1 + if (num > fldsMax) then + call ESMF_LogWrite(trim(subname)//": ERROR num > fldsMax "//trim(stdname), & + ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__) + return + endif + fldlist(num)%stdname = trim(stdname) + + if (present(ungridded_lbound) .and. present(ungridded_ubound)) then + fldlist(num)%ungridded_lbound = ungridded_lbound + fldlist(num)%ungridded_ubound = ungridded_ubound + end if + + end subroutine fld_list_add + + !=============================================================================== + + subroutine fld_list_realize(state, fldList, numflds, flds_scalar_name, flds_scalar_num, mesh, tag, rc) + + use NUOPC , only : NUOPC_IsConnected, NUOPC_Realize + use ESMF , only : ESMF_MeshLoc_Element, ESMF_FieldCreate, ESMF_TYPEKIND_R8 + use ESMF , only : ESMF_MAXSTR, ESMF_Field, ESMF_State, ESMF_Mesh, ESMF_StateRemove + use ESMF , only : ESMF_LogFoundError, ESMF_LOGMSG_INFO, ESMF_SUCCESS + use ESMF , only : ESMF_LogWrite, ESMF_LOGMSG_ERROR, ESMF_LOGERR_PASSTHRU + + type(ESMF_State) , intent(inout) :: state + type(fld_list_type) , intent(in) :: fldList(:) + integer , intent(in) :: numflds + character(len=*) , intent(in) :: flds_scalar_name + integer , intent(in) :: flds_scalar_num + character(len=*) , intent(in) :: tag + type(ESMF_Mesh) , intent(in) :: mesh + integer , intent(inout) :: rc + + ! local variables + integer :: n + type(ESMF_Field) :: field + character(len=80) :: stdname + integer :: gridtoFieldMap=2 + character(len=*),parameter :: subname='(dead_nuopc_mod:fld_list_realize)' + ! ---------------------------------------------- + + rc = ESMF_SUCCESS + + do n = 1, numflds + stdname = fldList(n)%stdname + if (NUOPC_IsConnected(state, fieldName=stdname)) then + if (stdname == trim(flds_scalar_name)) then + call ESMF_LogWrite(trim(subname)//trim(tag)//" Field = "//trim(stdname)//" is connected on root pe", & + ESMF_LOGMSG_INFO) + ! Create the scalar field + call SetScalarField(field, flds_scalar_name, flds_scalar_num, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + else + call ESMF_LogWrite(trim(subname)//trim(tag)//" Field = "//trim(stdname)//" is connected using mesh", & + ESMF_LOGMSG_INFO) + ! Create the field + if (fldlist(n)%ungridded_lbound > 0 .and. fldlist(n)%ungridded_ubound > 0) then + field = ESMF_FieldCreate(mesh, ESMF_TYPEKIND_R8, name=stdname, meshloc=ESMF_MESHLOC_ELEMENT, & + ungriddedLbound=(/fldlist(n)%ungridded_lbound/), & + ungriddedUbound=(/fldlist(n)%ungridded_ubound/), & + gridToFieldMap=(/gridToFieldMap/), rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + field = ESMF_FieldCreate(mesh, ESMF_TYPEKIND_R8, name=stdname, meshloc=ESMF_MESHLOC_ELEMENT, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + end if + endif + + ! NOW call NUOPC_Realize + call NUOPC_Realize(state, field=field, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + else + if (stdname /= trim(flds_scalar_name)) then + call ESMF_LogWrite(subname // trim(tag) // " Field = "// trim(stdname) // " is not connected.", & + ESMF_LOGMSG_INFO) + call ESMF_StateRemove(state, (/stdname/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + end if + end if + end do + + contains !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + subroutine SetScalarField(field, flds_scalar_name, flds_scalar_num, rc) + ! ---------------------------------------------- + ! create a field with scalar data on the root pe + ! ---------------------------------------------- + + use ESMF, only : ESMF_Field, ESMF_DistGrid, ESMF_Grid + use ESMF, only : ESMF_DistGridCreate, ESMF_GridCreate, ESMF_LogFoundError, ESMF_LOGERR_PASSTHRU + use ESMF, only : ESMF_FieldCreate, ESMF_GridCreate, ESMF_TYPEKIND_R8 + + type(ESMF_Field) , intent(inout) :: field + character(len=*) , intent(in) :: flds_scalar_name + integer , intent(in) :: flds_scalar_num + integer , intent(inout) :: rc + + ! local variables + type(ESMF_Distgrid) :: distgrid + type(ESMF_Grid) :: grid + character(len=*), parameter :: subname='(dead_nuopc_mod:SetScalarField)' + ! ---------------------------------------------- + + rc = ESMF_SUCCESS + + ! create a DistGrid with a single index space element, which gets mapped onto DE 0. + distgrid = ESMF_DistGridCreate(minIndex=(/1/), maxIndex=(/1/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + + grid = ESMF_GridCreate(distgrid, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + + field = ESMF_FieldCreate(name=trim(flds_scalar_name), grid=grid, typekind=ESMF_TYPEKIND_R8, & + ungriddedLBound=(/1/), ungriddedUBound=(/flds_scalar_num/), gridToFieldMap=(/2/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return + + end subroutine SetScalarField + + end subroutine fld_list_realize + + !=============================================================================== + + subroutine ModelInitPhase(gcomp, importState, exportState, clock, rc) + + use NUOPC, only : NUOPC_CompFilterPhaseMap + + type(ESMF_GridComp) :: gcomp + type(ESMF_State) :: importState, exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + ! Switch to IPDv01 by filtering all other phaseMap entries + call NUOPC_CompFilterPhaseMap(gcomp, ESMF_METHOD_INITIALIZE, acceptStringList=(/"IPDv01p"/), rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + end subroutine ModelInitPhase + + !=============================================================================== + + subroutine ModelSetRunClock(gcomp, rc) + + use ESMF , only : ESMF_ClockGetAlarmList, ESMF_ALARMLIST_ALL + use NUOPC_Model , only : NUOPC_ModelGet + use NUOPC , only : NUOPC_CompAttributeGet + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: mclock, dclock + type(ESMF_Time) :: mcurrtime, dcurrtime + type(ESMF_Time) :: mstoptime + type(ESMF_TimeInterval) :: mtimestep, dtimestep + character(len=256) :: cvalue + character(len=256) :: restart_option ! Restart option units + integer :: restart_n ! Number until restart interval + integer :: restart_ymd ! Restart date (YYYYMMDD) + type(ESMF_ALARM) :: restart_alarm + character(len=128) :: name + integer :: alarmcount + character(len=*),parameter :: subname='dead_nuopc_mod:(ModelSetRunClock) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + if (dbug_flag > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO) + + ! query the Component for its clocks + call NUOPC_ModelGet(gcomp, driverClock=dclock, modelClock=mclock, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_ClockGet(dclock, currTime=dcurrtime, timeStep=dtimestep, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_ClockGet(mclock, currTime=mcurrtime, timeStep=mtimestep, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! force model clock currtime and timestep to match driver and set stoptime + !-------------------------------- + + mstoptime = mcurrtime + dtimestep + call ESMF_ClockSet(mclock, currTime=dcurrtime, timeStep=dtimestep, stopTime=mstoptime, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! set restart alarm + !-------------------------------- + + call ESMF_ClockGetAlarmList(mclock, alarmlistflag=ESMF_ALARMLIST_ALL, alarmCount=alarmCount, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (alarmCount == 0) then + + call ESMF_GridCompGet(gcomp, name=name, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_LogWrite(subname//'setting alarms for' // trim(name), ESMF_LOGMSG_INFO) + + call NUOPC_CompAttributeGet(gcomp, name="restart_option", value=restart_option, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call NUOPC_CompAttributeGet(gcomp, name="restart_n", value=cvalue, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) restart_n + + call NUOPC_CompAttributeGet(gcomp, name="restart_ymd", value=cvalue, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) restart_ymd + + call alarmInit(mclock, restart_alarm, restart_option, & + opt_n = restart_n, & + opt_ymd = restart_ymd, & + RefTime = mcurrTime, & + alarmname = 'alarm_restart', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_AlarmSet(restart_alarm, clock=mclock, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + end if + + !-------------------------------- + ! Advance model clock to trigger alarms then reset model clock back to currtime + !-------------------------------- + + call ESMF_ClockAdvance(mclock,rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_ClockSet(mclock, currTime=dcurrtime, timeStep=dtimestep, stopTime=mstoptime, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (dbug_flag > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO) + + end subroutine ModelSetRunClock + + !=============================================================================== + + subroutine dead_meshinit(gcomp, nx_global, ny_global, gindex, lon, lat, Emesh, rc) + + !----------------------------------------- + ! create an Emesh object for Fields + !----------------------------------------- + + use ESMF , only : ESMF_GridComp, ESMF_VM, ESMF_Mesh + use ESMF , only : ESMF_VMGet, ESMF_GridCompGet, ESMF_VMBroadCast, ESMF_VMAllGatherV + use ESMF , only : ESMF_SUCCESS, ESMF_LOGMSG_INFO, ESMF_LogWrite + use ESMF , only : ESMF_VMGather, ESMF_LogFoundError, ESMF_LOGERR_PASSTHRU + use ESMF , only : ESMF_MeshCreate, ESMF_COORDSYS_SPH_DEG, ESMF_REDUCE_SUM + use ESMF , only : ESMF_VMAllReduce, ESMF_MESHELEMTYPE_QUAD + + ! input/output arguments + type(ESMF_GridComp) :: gcomp + integer , intent(in) :: nx_global + integer , intent(in) :: ny_global + integer , intent(in) :: gindex(:) + real(r8), pointer , intent(in) :: lon(:) + real(r8), pointer , intent(in) :: lat(:) + type(ESMF_Mesh) , intent(inout) :: Emesh + integer , intent(inout) :: rc + + ! local variables + integer :: n,n1,n2,de + integer :: iam + integer :: lsize + integer :: numTotElems, numNodes, numConn, nodeindx + integer :: iur,iul,ill,ilr + integer :: xid, yid, xid0, yid0 + real(r8) :: lonur, lonul, lonll, lonlr + integer, pointer :: iurpts(:) + integer, pointer :: elemIds(:) + integer, pointer :: elemTypes(:) + integer, pointer :: elemConn(:) + real(r8),pointer :: elemCoords(:) + integer, pointer :: nodeIds(:) + integer, pointer :: nodeOwners(:) + real(r8),pointer :: nodeCoords(:) + real(r8),pointer :: latG(:) + real(r8),pointer :: lonG(:) + integer ,pointer :: pes_local(:) + integer ,pointer :: pes_global(:) + integer, pointer :: recvOffsets(:) + integer, pointer :: recvCounts(:) + integer :: sendData(1) + type(ESMF_VM) :: vm + integer :: petCount + character(len=*),parameter :: subname='(dead_MeshInit)' + !-------------------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_LogWrite(subname, ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + lsize = size(gindex) + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, petCount=petCount, localpet=iam, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + allocate(latG(nx_global*ny_global)) + allocate(lonG(nx_global*ny_global)) + + allocate(recvoffsets(petCount)) + allocate(recvCounts(petCount)) + + sendData(1) = lsize + call ESMF_VMGather(vm, sendData=sendData, recvData=recvCounts, count=1, rootPet=0, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMBroadCast(vm, bcstData=recvCounts, count=petCount, rootPet=0, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + recvoffsets(1) = 0 + do n = 2,petCount + recvoffsets(n) = recvoffsets(n-1) + recvCounts(n-1) + end do + + call ESMF_VMAllGatherV(vm, lat, lsize, latG, recvCounts, recvOffsets, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMAllGatherV(vm, lon, lsize, lonG, recvCounts, recvOffsets, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + deallocate(recvoffsets) + deallocate(recvCounts) + + ! assumes quadrilaterals for each gridcell (element) + ! element index matches gsmap index value + ! nodeid at lower left of each gridcell matches gsmap index value + ! assumes wrap around in x direction but no wrap in y direction + ! node ids need to be described in counter clockwise direction + ! node id associated with lower left cell is assigned to local PET + ! node ids at top of y boundary assigned to the element to the right + + numTotElems = lsize + + allocate(elemIds(numTotElems)) + allocate(elemTypes(numTotElems)) + elemTypes=(/ESMF_MESHELEMTYPE_QUAD/) + allocate(elemConn(4*numTotElems)) + allocate(elemCoords(2*numTotElems)) + + allocate(nodeIds(numTotElems*4)) + nodeIds = -99 + + elemIds(:) = gindex(:) + numNodes = 0 + numConn = 0 + + do n = 1,numTotElems + elemTypes(n) = ESMF_MESHELEMTYPE_QUAD + elemCoords(2*n-1) = lon(n) + elemCoords(2*n) = lat(n) + + do n1 = 1,4 + + numNodes = numNodes + 1 + nodeindx = numNodes + if (n1 == 1 .or. n1 == 3) xid = mod(elemIds(n)-1,nx_global) + 1 + if (n1 == 2 .or. n1 == 4) xid = mod(elemIds(n) ,nx_global) + 1 + if (n1 == 1 .or. n1 == 2) yid = (elemIds(n)-1)/nx_global + 1 + if (n1 == 3 .or. n1 == 4) yid = (elemIds(n)-1)/nx_global + 2 + nodeIds(numNodes) = (yid-1) * nx_global + xid + n2 = 0 + do while (n2 < numNodes - 1 .and. nodeindx == numNodes) + n2 = n2 + 1 + if (nodeIds(numNodes) == nodeIds(n2)) nodeindx = n2 + enddo + if (nodeindx /= numNodes) then + numNodes = numNodes - 1 + endif + + numConn = numConn + 1 + elemConn(numConn) = nodeindx + enddo + enddo + + + allocate(nodeCoords(2*numNodes)) + allocate(nodeOwners(numNodes)) + allocate(iurpts(numNodes)) + + do n = 1,numNodes + + xid0 = mod(nodeIds(n)-1, nx_global) + 1 + yid0 = (nodeIds(n)-1) / nx_global + 1 + + xid = xid0 + yid = max(min(yid0,ny_global),1) + iur = (yid-1) * nx_global + xid + iurpts(n) = iur + + xid = mod(xid0 - 2 + nx_global, nx_global) + 1 + yid = max(min(yid0,ny_global),1) + iul = (yid-1) * nx_global + xid + + xid = mod(xid0 - 2 + nx_global, nx_global) + 1 + yid = max(min(yid0-1,ny_global),1) + ill = (yid-1) * nx_global + xid + + xid = xid0 + yid = max(min(yid0-1,ny_global),1) + ilr = (yid-1) * nx_global + xid + + ! write(tmpstr,'(2a,8i6)') subname,' nodecoord = ',n,nodeIds(n),xid0,yid0,iur,iul,ill,ilr + ! call ESMF_LogWrite(trim(tmpstr), ESMF_LOGMSG_INFO) + + ! need to normalize lon values to same 360 degree setting, use lonur as reference value + lonur = lonG(iur) + lonul = lonG(iul) + lonll = lonG(ill) + lonlr = lonG(ilr) + + if (abs(lonul + 360._r8 - lonur) < abs(lonul - lonur)) lonul = lonul + 360._r8 + if (abs(lonul - 360._r8 - lonur) < abs(lonul - lonur)) lonul = lonul - 360._r8 + if (abs(lonll + 360._r8 - lonur) < abs(lonll - lonur)) lonll = lonll + 360._r8 + if (abs(lonll - 360._r8 - lonur) < abs(lonll - lonur)) lonll = lonll - 360._r8 + if (abs(lonlr + 360._r8 - lonur) < abs(lonlr - lonur)) lonlr = lonlr + 360._r8 + if (abs(lonlr - 360._r8 - lonur) < abs(lonlr - lonur)) lonlr = lonlr - 360._r8 + + nodeCoords(2*n-1) = 0.25_r8 * (lonur + lonul + lonll + lonlr) + nodeCoords(2*n) = 0.25_r8 * (latG(iur) + latG(iul) + latG(ill) + latG(ilr)) + enddo + + deallocate(lonG) + deallocate(latG) + + ! Determine the pes that own each index of iurpts (nodeOwners) + + allocate(pes_local(nx_global*ny_global)) + allocate(pes_global(nx_global*ny_global)) + pes_local(:) = 0 + do n = 1,lsize + pes_local(gindex(n)) = iam + end do + + call ESMF_VMAllReduce(vm, sendData=pes_local, recvData=pes_global, count=nx_global*ny_global, & + reduceflag=ESMF_REDUCE_SUM, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + do n = 1,numNodes + nodeOwners(n) = pes_global(iurpts(n)) + end do + deallocate(pes_local) + deallocate(pes_global) + + Emesh = ESMF_MeshCreate(parametricDim=2, & + spatialDim=2, & + coordSys=ESMF_COORDSYS_SPH_DEG, & + nodeIds=nodeIds(1:numNodes), & + nodeCoords=nodeCoords, & + nodeOwners=nodeOwners, & + elementIds=elemIds,& + elementTypes=elemTypes, & + elementConn=elemConn, & + elementCoords=elemCoords, & + rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + deallocate(iurpts) + deallocate(nodeIds, nodeCoords, nodeOwners) + deallocate(elemIds, elemTypes, elemConn, elemCoords) + + end subroutine dead_meshinit + +end module dead_nuopc_mod diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib new file mode 120000 index 000000000..9601a6fa7 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib @@ -0,0 +1 @@ +../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake new file mode 120000 index 000000000..292ce33d2 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake @@ -0,0 +1 @@ +../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml new file mode 100755 index 000000000..b7b8576ba --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +""" +build data model library +""" + +import sys, os + +_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) + +from standard_script_setup import * +from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.case import Case + +def buildnml(case, caseroot, compname): + if compname != "xwav": + raise AttributeError + build_xcpl_nml(case, caseroot, compname) + +def _main_func(): + caseroot = parse_input(sys.argv) + with Case(caseroot) as case: + buildnml(case, caseroot, "xwav") + +if __name__ == "__main__": + _main_func() diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml b/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml new file mode 100644 index 000000000..e82944fd3 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml @@ -0,0 +1,26 @@ + + + + + + + Dead wave component + + + + + char + xwav + xwav + case_comp + env_case.xml + Name of wave component + + + + ========================================= + XWAV naming conventions in compset name + ========================================= + + + diff --git a/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 new file mode 100644 index 000000000..174847a95 --- /dev/null +++ b/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 @@ -0,0 +1,518 @@ +module wav_comp_nuopc + + !---------------------------------------------------------------------------- + ! This is the NUOPC cap for XWAV + !---------------------------------------------------------------------------- + + use ESMF + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index + use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + + implicit none + private ! except + + public :: SetServices + + !-------------------------------------------------------------------------- + ! Private module data + !-------------------------------------------------------------------------- + + character(len=CL) :: 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 :: fldsToWav_num = 0 + integer :: fldsFrWav_num = 0 + type (fld_list_type) :: fldsToWav(fldsMax) + type (fld_list_type) :: fldsFrWav(fldsMax) + integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost + + real(r8), pointer :: gbuf(:,:) ! model info + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer , allocatable :: gindex(:) + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + 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 :: mastertask + integer :: dbug = 1 + character(*),parameter :: modName = "(xwav_comp_nuopc)" + character(*),parameter :: u_FILE_u = & + __FILE__ + +!=============================================================================== +contains +!=============================================================================== + + subroutine SetServices(gcomp, rc) + + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + character(len=*),parameter :: subname=trim(modName)//':(SetServices) ' + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! 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=ModelInitPhase, 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=ModelSetRunClock, 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, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + 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 + type(ESMF_VM) :: vm + character(CS) :: stdname + integer :: n + integer :: lsize ! local array size + integer :: shrlogunit ! original log unit + character(CL) :: cvalue + character(len=CL) :: logmsg + logical :: isPresent, isSet + character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, localpet=my_task, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + mastertask = (my_task == 0) + + !---------------------------------------------------------------------------- + ! determine instance information + !--------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Initialize xwav + !---------------------------------------------------------------------------- + + call dead_init_nuopc('wav', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + + allocate(gindex(lsize)) + allocate(lon(lsize)) + allocate(lat(lsize)) + + gindex(:) = gbuf(:,dead_grid_index) + lat(:) = gbuf(:,dead_grid_lat) + lon(:) = gbuf(:,dead_grid_lon) + + !-------------------------------- + ! advertise import and export fields + !-------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + flds_scalar_name = trim(cvalue) + call ESMF_LogWrite(trim(subname)//' flds_scalar_name = '//trim(flds_scalar_name), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldName') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldCount", 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_num + write(logmsg,*) flds_scalar_num + call ESMF_LogWrite(trim(subname)//' flds_scalar_num = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldCount') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNX", 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_nx + write(logmsg,*) flds_scalar_index_nx + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_nx = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNX') + endif + + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldIdxGridNY", 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_ny + write(logmsg,*) flds_scalar_index_ny + call ESMF_LogWrite(trim(subname)//' : flds_scalar_index_ny = '//trim(logmsg), ESMF_LOGMSG_INFO) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') + endif + + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrWav_num, fldsFrWav, trim(flds_scalar_name)) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_lamult' ) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_ustokes' ) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_vstokes' ) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_hstokes' ) + + call fld_list_add(fldsToWav_num, fldsToWav, trim(flds_scalar_name)) + call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_u' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_v' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_tbot' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'Si_ifrac' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_t' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_u' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_v' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_bldepth' ) + + do n = 1,fldsFrWav_num + if (mastertask) write(logunit,*)'Advertising From Xwav ',trim(fldsFrWav(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrWav(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + do n = 1,fldsToWav_num + if(mastertask) write(logunit,*)'Advertising To Xwav ',trim(fldsToWav(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToWav(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) + + 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_Mesh) :: Emesh + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! generate the mesh + !-------------------------------- + + call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! realize the actively coupled fields, now that a mesh is established + ! 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 fld_list_realize( & + state=ExportState, & + fldlist=fldsFrWav, & + numflds=fldsFrWav_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':dwavExport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call fld_list_realize( & + state=importState, & + fldList=fldsToWav, & + numflds=fldsToWav_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':dwavImport',& + mesh=Emesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call State_SetExport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call State_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + + call shr_file_setLogUnit (shrlogunit) + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine InitializeRealize + + !=============================================================================== + + subroutine ModelAdvance(gcomp, rc) + + ! input/output variables + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit + character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + if (dbug > 5) then + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + end if + call memcheck(subname, 3, mastertask) + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- + ! Pack export state + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call state_setexport(exportState, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !-------------------------------- + ! diagnostics + !-------------------------------- + + if (dbug > 1) then + call State_diagnose(exportState,subname//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if ( mastertask) then + call log_clock_advance(clock, 'XWAV', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif + endif + + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) then + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + end if + + end subroutine ModelAdvance + + !=============================================================================== + + subroutine state_setexport(exportState, rc) + + ! input/output variables + type(ESMF_State) , intent(inout) :: exportState + integer , intent(out) :: rc + + ! local variables + integer :: nf, nind, nfstart, ubound + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + nfstart = 0 ! for fields that have ubound > 0 + do nf = 2,fldsFrWav_num ! Start from index 2 in order to skip the scalar field + ubound = fldsFrWav(nf)%ungridded_ubound + if (ubound == 0) then + call field_setexport(exportState, trim(fldsFrWav(nf)%stdname), lon, lat, nf=nf, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + nfstart = nfstart + nf + ubound - 1 + do nind = 1,ubound + call field_setexport(exportState, trim(fldsFrWav(nf)%stdname), lon, lat, nf=nfstart+nind-1, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + + end subroutine state_setexport + + !=============================================================================== + + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) + + use shr_const_mod , only : pi=>shr_const_pi + + ! intput/otuput variables + type(ESMF_State) , intent(inout) :: exportState + character(len=*) , intent(in) :: fldname + real(r8) , intent(in) :: lon(:) + real(r8) , intent(in) :: lat(:) + integer , intent(in) :: nf + integer, optional , intent(in) :: ungridded_index + integer , intent(out) :: rc + + ! local variables + integer :: i, ncomp + type(ESMF_Field) :: lfield + real(r8), pointer :: data1d(:) + real(r8), pointer :: data2d(:,:) + !-------------------------------------------------- + + rc = ESMF_SUCCESS + + call ESMF_StateGet(exportState, itemName=trim(fldname), field=lfield, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ncomp = 7 + if (present(ungridded_index)) then + call ESMF_FieldGet(lfield, farrayPtr=data2d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (gridToFieldMap == 1) then + do i = 1,size(data2d, dim=1) + data2d(i,ungridded_index) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + else if (gridToFieldMap == 2) then + do i = 1,size(data2d, dim=2) + data2d(ungridded_index,i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + else + call ESMF_FieldGet(lfield, farrayPtr=data1d, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + do i = 1,size(data1d) + data1d(i) = (nf*100) * cos(pi*lat(i)/180.0_R8) * & + sin((pi*lon(i)/180.0_R8) - (ncomp-1)*(pi/3.0_R8) ) + (ncomp*10.0_R8) + end do + end if + + end subroutine field_setexport + + !=============================================================================== + + subroutine ModelFinalize(gcomp, rc) + type(ESMF_GridComp) :: gcomp + integer, intent(out) :: rc + + ! local variables + character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' + !------------------------------------------------------------------------------- + + !-------------------------------- + ! Finalize routine + !-------------------------------- + + rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + call dead_final_nuopc('wav', logunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + end subroutine ModelFinalize + +end module wav_comp_nuopc From 5bb1c491c706b33dfb194833619ae1ac28285a0e Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Thu, 6 Aug 2020 10:23:31 -0600 Subject: [PATCH 05/24] refactored X compsets to read in mesh files rather than generating meshes --- .../xatm/src/atm_comp_nuopc.F90 | 129 ++-- .../xglc/src/glc_comp_nuopc.F90 | 117 ++-- .../xice/src/ice_comp_nuopc.F90 | 83 ++- .../xlnd/src/lnd_comp_nuopc.F90 | 81 ++- .../xocn/src/ocn_comp_nuopc.F90 | 144 ++--- .../xrof/src/rof_comp_nuopc.F90 | 130 ++-- .../xshare/dead_nuopc_mod.F90 | 585 +----------------- .../xwav/src/wav_comp_nuopc.F90 | 135 ++-- 8 files changed, 301 insertions(+), 1103 deletions(-) diff --git a/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 index 4cbea61d0..7386883d6 100644 --- a/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 @@ -17,10 +17,8 @@ module atm_comp_nuopc use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance - use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index - use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type - use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock implicit none private ! except @@ -43,10 +41,7 @@ module atm_comp_nuopc type (fld_list_type) :: fldsFrAtm(fldsMax) integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost - real(r8), pointer :: gbuf(:,:) ! model info - real(r8), pointer :: lat(:) - real(r8), pointer :: lon(:) - integer , allocatable :: gindex(:) + type(ESMF_Mesh) :: mesh integer :: nxg ! global dim i-direction integer :: nyg ! global dim j-direction integer :: my_task ! my task in mpi communicator mpicom @@ -54,7 +49,7 @@ module atm_comp_nuopc character(len=5) :: inst_suffix ! char string associated with instance (ie. "_0001" or "") integer :: logunit ! logging unit number logical :: mastertask - integer :: dbug = 1 + integer :: dbug = 0 character(*),parameter :: modName = "(xatm_comp_nuopc)" character(*),parameter :: u_FILE_u = & __FILE__ @@ -109,7 +104,6 @@ subroutine SetServices(gcomp, rc) end subroutine SetServices !=============================================================================== - subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! input/output variables @@ -131,7 +125,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -141,38 +134,18 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) mastertask = (my_task==0) - !---------------------------------------------------------------------------- ! determine instance information - !---------------------------------------------------------------------------- - call get_component_instance(gcomp, inst_suffix, inst_index, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- ! set logunit and set shr logging to my log file - !---------------------------------------------------------------------------- - call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- ! Initialize xatm - !---------------------------------------------------------------------------- - - call dead_init_nuopc('atm', inst_suffix, logunit, lsize, gbuf, nxg, nyg) + call dead_read_inparms('atm', inst_suffix, logunit, nxg, nyg) - allocate(gindex(lsize)) - allocate(lon(lsize)) - allocate(lat(lsize)) - - gindex(:) = gbuf(:,dead_grid_index) - lat(:) = gbuf(:,dead_grid_lat) - lon(:) = gbuf(:,dead_grid_lon) - - !-------------------------------- ! advertise import and export fields - !-------------------------------- - call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then @@ -296,18 +269,12 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) enddo end if - !---------------------------------------------------------------------------- ! Reset shr logging to original values - !---------------------------------------------------------------------------- - call shr_file_setLogUnit (shrlogunit) - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end subroutine InitializeAdvertise !=============================================================================== - subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! input/output arguments @@ -317,37 +284,30 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Mesh) :: Emesh type(ESMF_Time) :: nextTime real(r8) :: nextsw_cday integer :: n integer :: shrlogunit ! original log unit + character(ESMF_MAXSTR) :: cvalue ! config data character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize: xatm) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - !---------------------------------------------------------------------------- ! Reset shr logging to my log file - !---------------------------------------------------------------------------- - call shr_file_getLogUnit (shrlogunit) call shr_file_setLogUnit (logUnit) - !-------------------------------- ! generate the mesh - !-------------------------------- + call NUOPC_CompAttributeGet(gcomp, name='mesh_atm', value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return - call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! realize the actively coupled fields, now that a mesh is established ! 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 fld_list_realize( & state=exportState, & fldList=fldsFrAtm, & @@ -355,7 +315,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & tag=subname//':datmExport',& - mesh=Emesh, rc=rc) + mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call fld_list_realize( & @@ -365,38 +325,26 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & tag=subname//':datmImport',& - mesh=Emesh, rc=rc) + mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! Pack export state - !-------------------------------- - call state_setexport(exportState, rc=rc) - - call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & - flds_scalar_name, flds_scalar_num, rc) + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - - call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & - flds_scalar_name, flds_scalar_num, rc) + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return ! Set time of next radiation computation - call ESMF_ClockGetNextTime(clock, nextTime) if (chkerr(rc,__LINE__,u_FILE_u)) return call ESMF_TimeGet(nextTime, dayOfYear_r8=nextsw_cday) if (chkerr(rc,__LINE__,u_FILE_u)) return - call 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 - !-------------------------------- ! diagnostics - !-------------------------------- - if (dbug > 1) then call State_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -404,12 +352,9 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call shr_file_setLogUnit (shrlogunit) - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end subroutine InitializeRealize !=============================================================================== - subroutine ModelAdvance(gcomp, rc) ! input/output variables @@ -463,14 +408,9 @@ subroutine ModelAdvance(gcomp, rc) call shr_file_setLogUnit (shrlogunit) - if (dbug > 5) then - call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end if - end subroutine ModelAdvance !=============================================================================== - subroutine state_setexport(exportState, rc) ! input/output variables @@ -478,11 +418,29 @@ subroutine state_setexport(exportState, rc) integer, intent(out) :: rc ! local variables - integer :: nf, nind + integer :: n, nf, nind + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) !-------------------------------------------------- rc = ESMF_SUCCESS + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + ! Start from index 2 in order to Skip the scalar field here do nf = 2,fldsFrAtm_num if (fldsFrAtm(nf)%ungridded_ubound == 0) then @@ -497,10 +455,12 @@ subroutine state_setexport(exportState, rc) end if end do + deallocate(lon) + deallocate(lat) + end subroutine state_setexport !=============================================================================== - subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) use shr_const_mod , only : pi=>shr_const_pi @@ -553,27 +513,18 @@ subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, end subroutine field_setexport !=============================================================================== - subroutine ModelFinalize(gcomp, rc) - type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - - ! local variables - character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' !------------------------------------------------------------------------------- - !-------------------------------- - ! Finalize routine - !-------------------------------- - rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - - call dead_final_nuopc('atm', logunit) - - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + if (mastertask) then + write(logunit,*) + write(logunit,*) 'xatm: end of main integration loop' + write(logunit,*) + end if end subroutine ModelFinalize end module atm_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 index f381503f7..8bf8b8b6e 100644 --- a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 @@ -17,10 +17,8 @@ module glc_comp_nuopc use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance - use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index - use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type - use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock implicit none private ! except @@ -42,10 +40,7 @@ module glc_comp_nuopc type (fld_list_type) :: fldsFrGlc(fldsMax) integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost - real(r8), pointer :: gbuf(:,:) ! model info - real(r8), pointer :: lat(:) - real(r8), pointer :: lon(:) - integer , allocatable :: gindex(:) + type(ESMF_Mesh) :: mesh integer :: nxg ! global dim i-direction integer :: nyg ! global dim j-direction integer :: my_task ! my task in mpi communicator mpicom @@ -54,7 +49,7 @@ module glc_comp_nuopc integer :: logunit ! logging unit number integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask - integer :: dbug = 1 + integer :: dbug = 0 character(*),parameter :: modName = "(xglc_comp_nuopc)" character(*),parameter :: u_FILE_u = & __FILE__ @@ -109,7 +104,6 @@ subroutine SetServices(gcomp, rc) end subroutine SetServices !=============================================================================== - subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! input/output variables @@ -131,7 +125,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -139,40 +132,20 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call ESMF_VMGet(vm, localpet=my_task, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - mastertask = my_task == master_task + mastertask = (my_task == master_task) - !---------------------------------------------------------------------------- ! determine instance information - !---------------------------------------------------------------------------- - call get_component_instance(gcomp, inst_suffix, inst_index, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- ! set logunit and set shr logging to my log file - !---------------------------------------------------------------------------- - call set_component_logging(gcomp, my_task==master_task, logunit, shrlogunit, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- ! Initialize xglc - !---------------------------------------------------------------------------- - - call dead_init_nuopc('glc', inst_suffix, logunit, lsize, gbuf, nxg, nyg) - - allocate(gindex(lsize)) - allocate(lon(lsize)) - allocate(lat(lsize)) - - gindex(:) = gbuf(:,dead_grid_index) - lat(:) = gbuf(:,dead_grid_lat) - lon(:) = gbuf(:,dead_grid_lon) + call dead_read_inparms('glc', inst_suffix, logunit, nxg, nyg) - !-------------------------------- ! advertise import and export fields - !-------------------------------- - call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then @@ -244,12 +217,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) enddo end if - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - - !---------------------------------------------------------------------------- ! Reset shr logging to original values - !---------------------------------------------------------------------------- - call shr_file_setLogUnit (shrlogunit) end subroutine InitializeAdvertise @@ -265,14 +233,13 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Mesh) :: Emesh - integer :: shrlogunit ! original log unit - integer :: n + integer :: n + integer :: shrlogunit ! original log unit + character(ESMF_MAXSTR) :: cvalue ! config data character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) !---------------------------------------------------------------------------- ! Reset shr logging to my log file @@ -283,11 +250,13 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) !-------------------------------- ! generate the mesh - ! grid_option specifies grid or mesh !-------------------------------- - call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + call NUOPC_CompAttributeGet(gcomp, name='mesh_glc', value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return !-------------------------------- ! realize the actively coupled fields, now that a mesh is established @@ -302,7 +271,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & tag=subname//':dglcExport',& - mesh=Emesh, rc=rc) + mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call fld_list_realize( & @@ -312,7 +281,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & tag=subname//':dglcImport',& - mesh=Emesh, rc=rc) + mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return !-------------------------------- @@ -343,8 +312,6 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call shr_file_setLogUnit (shrlogunit) - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end subroutine InitializeRealize !=============================================================================== @@ -365,7 +332,6 @@ subroutine ModelAdvance(gcomp, rc) !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) call memcheck(subname, 3, mastertask) call shr_file_getLogUnit (shrlogunit) @@ -381,27 +347,17 @@ subroutine ModelAdvance(gcomp, rc) call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! diagnostics - !-------------------------------- - if (dbug > 1) then call state_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - if (my_task == master_task) then - call log_clock_advance(clock, 'XGLC', logunit, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - endif endif call shr_file_setLogUnit (shrlogunit) - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end subroutine ModelAdvance !=============================================================================== - subroutine state_setexport(exportState, rc) ! input/output variables @@ -409,11 +365,29 @@ subroutine state_setexport(exportState, rc) integer, intent(out) :: rc ! local variables - integer :: nf, nind + integer :: n, nf, nind + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) !-------------------------------------------------- rc = ESMF_SUCCESS + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + ! Start from index 2 in order to skip the scalar field do nf = 2,fldsFrGlc_num if (fldsFrGlc(nf)%ungridded_ubound == 0) then @@ -428,6 +402,9 @@ subroutine state_setexport(exportState, rc) end if end do + deallocate(lon) + deallocate(lat) + end subroutine state_setexport !=============================================================================== @@ -494,28 +471,18 @@ subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, end subroutine field_setexport !=============================================================================== - subroutine ModelFinalize(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - - ! local variables - character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' !------------------------------------------------------------------------------- - !-------------------------------- - ! Finalize routine - !-------------------------------- - rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - - call dead_final_nuopc('glc', logunit) - - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + if (mastertask) then + write(logunit,*) + write(logunit,*) 'xglc: end of main integration loop' + write(logunit,*) + end if end subroutine ModelFinalize - !=============================================================================== - end module glc_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 index 3537e8dd1..d531da74a 100644 --- a/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 @@ -17,10 +17,8 @@ module ice_comp_nuopc use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance - use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index - use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type - use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock implicit none private ! except @@ -42,10 +40,7 @@ module ice_comp_nuopc type (fld_list_type) :: fldsFrIce(fldsMax) integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost - real(r8), pointer :: gbuf(:,:) ! model info - real(r8), pointer :: lat(:) - real(r8), pointer :: lon(:) - integer , allocatable :: gindex(:) + type(ESMF_Mesh) :: mesh integer :: nxg ! global dim i-direction integer :: nyg ! global dim j-direction integer :: my_task ! my task in mpi communicator mpicom @@ -54,7 +49,7 @@ module ice_comp_nuopc integer :: logunit ! logging unit number integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask - integer :: dbug = 1 + integer :: dbug = 0 character(*),parameter :: modName = "(xice_comp_nuopc)" character(*),parameter :: u_FILE_u = & __FILE__ @@ -108,7 +103,6 @@ subroutine SetServices(gcomp, rc) end subroutine SetServices !=============================================================================== - subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! input/output variables @@ -158,15 +152,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Initialize xice !---------------------------------------------------------------------------- - call dead_init_nuopc('ice', inst_suffix, logunit, lsize, gbuf, nxg, nyg) - - allocate(gindex(lsize)) - allocate(lon(lsize)) - allocate(lat(lsize)) - - gindex(:) = gbuf(:,dead_grid_index) - lat(:) = gbuf(:,dead_grid_lat) - lon(:) = gbuf(:,dead_grid_lon) + call dead_read_inparms('ice', inst_suffix, logunit, nxg, nyg) !-------------------------------- ! advertise import and export fields @@ -300,7 +286,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) end subroutine InitializeAdvertise !=============================================================================== - subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) type(ESMF_GridComp) :: gcomp type(ESMF_State) :: importState, exportState @@ -308,14 +293,13 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Mesh) :: Emesh integer :: shrlogunit ! original log unit integer :: n + character(ESMF_MAXSTR) :: cvalue ! config data character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) !---------------------------------------------------------------------------- ! Reset shr logging to my log file @@ -328,8 +312,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! generate the mesh !-------------------------------- - call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + call NUOPC_CompAttributeGet(gcomp, name='mesh_ice', value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return !-------------------------------- ! realize the actively coupled fields, now that a mesh is established @@ -344,7 +331,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & tag=subname//':diceExport',& - mesh=Emesh, rc=rc) + mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call fld_list_realize( & @@ -354,7 +341,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & tag=subname//':diceImport',& - mesh=Emesh, rc=rc) + mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return !-------------------------------- @@ -383,12 +370,9 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call shr_file_setLogUnit (shrlogunit) - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end subroutine InitializeRealize !=============================================================================== - subroutine ModelAdvance(gcomp, rc) ! input/output variables @@ -439,7 +423,6 @@ subroutine ModelAdvance(gcomp, rc) end subroutine ModelAdvance !=============================================================================== - subroutine state_setexport(exportState, rc) ! input/output variables @@ -447,11 +430,29 @@ subroutine state_setexport(exportState, rc) integer, intent(out) :: rc ! local variables - integer :: nf, nind + integer :: n, nf, nind + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) !-------------------------------------------------- rc = ESMF_SUCCESS + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + ! Start from index 2 in order to skip the scalar field do nf = 2,fldsFrIce_num if (fldsFrIce(nf)%ungridded_ubound == 0) then @@ -466,10 +467,12 @@ subroutine state_setexport(exportState, rc) end if end do + deallocate(lon) + deallocate(lat) + end subroutine state_setexport !=============================================================================== - subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) use shr_const_mod , only : pi=>shr_const_pi @@ -532,26 +535,18 @@ subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, end subroutine field_setexport !=============================================================================== - subroutine ModelFinalize(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - - ! local variables - character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' !------------------------------------------------------------------------------- - !-------------------------------- - ! Finalize routine - !-------------------------------- - rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - - call dead_final_nuopc('ice', logunit) - - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + if (mastertask) then + write(logunit,*) + write(logunit,*) 'xice: end of main integration loop' + write(logunit,*) + end if end subroutine ModelFinalize end module ice_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 index 4e76678b8..0d08bf68b 100644 --- a/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 @@ -17,10 +17,8 @@ module lnd_comp_nuopc use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance - use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index - use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type - use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock implicit none private ! except @@ -44,10 +42,7 @@ module lnd_comp_nuopc integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost integer :: glc_nec - real(r8), pointer :: gbuf(:,:) ! model info - real(r8), pointer :: lat(:) - real(r8), pointer :: lon(:) - integer , allocatable :: gindex(:) + type(ESMF_Mesh) :: mesh integer :: nxg ! global dim i-direction integer :: nyg ! global dim j-direction integer :: my_task ! my task in mpi communicator mpicom @@ -127,7 +122,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) integer :: lsize ! local array size integer :: shrlogunit ! original log unit character(CL) :: cvalue - character(len=CL) :: logmsg + character(CL) :: logmsg logical :: isPresent, isSet character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' !------------------------------------------------------------------------------- @@ -141,7 +136,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call ESMF_VMGet(vm, localpet=my_task, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - mastertask = my_task == master_task + mastertask = (my_task == master_task) !---------------------------------------------------------------------------- ! determine instance information @@ -161,15 +156,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Initialize xlnd !---------------------------------------------------------------------------- - call dead_init_nuopc('lnd', inst_suffix, logunit, lsize, gbuf, nxg, nyg) - - allocate(gindex(lsize)) - allocate(lon(lsize)) - allocate(lat(lsize)) - - gindex(:) = gbuf(:,dead_grid_index) - lat(:) = gbuf(:,dead_grid_lat) - lon(:) = gbuf(:,dead_grid_lon) + call dead_read_inparms('lnd', inst_suffix, logunit, nxg, nyg) !-------------------------------- ! advertise import and export fields @@ -308,7 +295,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) end subroutine InitializeAdvertise !=============================================================================== - subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! intput/output variables @@ -318,11 +304,9 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Mesh) :: Emesh integer :: shrlogunit ! original log unit - type(ESMF_VM) :: vm integer :: n - logical :: connected ! is field connected? + character(ESMF_MAXSTR) :: cvalue ! config data character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- @@ -340,8 +324,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! generate the mesh !-------------------------------- - call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + call NUOPC_CompAttributeGet(gcomp, name='mesh_lnd', value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return !-------------------------------- ! realize the actively coupled fields, now that a mesh is established @@ -356,7 +343,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & tag=subname//':dlndExport',& - mesh=Emesh, rc=rc) + mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call fld_list_realize( & @@ -366,7 +353,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & tag=subname//':dlndImport',& - mesh=Emesh, rc=rc) + mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return !-------------------------------- @@ -400,7 +387,6 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) end subroutine InitializeRealize !=============================================================================== - subroutine ModelAdvance(gcomp, rc) ! input/output variables @@ -459,11 +445,29 @@ subroutine state_setexport(exportState, rc) integer, intent(out) :: rc ! local variables - integer :: nf, nind + integer :: n, nf, nind + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) !-------------------------------------------------- rc = ESMF_SUCCESS + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + ! Start from index 2 in order to Skip the scalar field here do nf = 2,fldsFrLnd_num if (fldsFrLnd(nf)%ungridded_ubound == 0) then @@ -478,6 +482,9 @@ subroutine state_setexport(exportState, rc) end if end do + deallocate(lon) + deallocate(lat) + end subroutine state_setexport !=============================================================================== @@ -538,26 +545,18 @@ subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, end subroutine field_setexport !=============================================================================== - subroutine ModelFinalize(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - - ! local variables - character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' !------------------------------------------------------------------------------- - !-------------------------------- - ! Finalize routine - !-------------------------------- - rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - - call dead_final_nuopc('lnd', logunit) - - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + if (mastertask) then + write(logunit,*) + write(logunit,*) 'xlnd: end of main integration loop' + write(logunit,*) + end if end subroutine ModelFinalize end module lnd_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 index 2f3f037e3..5d6b04ec9 100644 --- a/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 @@ -17,10 +17,8 @@ module ocn_comp_nuopc use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance - use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index - use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type - use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock implicit none private ! except @@ -43,10 +41,7 @@ module ocn_comp_nuopc type (fld_list_type) :: fldsFrOcn(fldsMax) integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost - real(r8), pointer :: gbuf(:,:) ! model info - real(r8), pointer :: lat(:) - real(r8), pointer :: lon(:) - integer , allocatable :: gindex(:) + type(ESMF_Mesh) :: mesh integer :: nxg ! global dim i-direction integer :: nyg ! global dim j-direction integer :: my_task ! my task in mpi communicator mpicom @@ -56,7 +51,7 @@ module ocn_comp_nuopc integer :: logunit ! logging unit number integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask - integer :: dbug = 1 + integer :: dbug = 0 character(*),parameter :: modName = "(xocn_comp_nuopc)" character(*),parameter :: u_FILE_u = & __FILE__ @@ -122,7 +117,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm - character(CS) :: stdname integer :: n integer :: lsize ! local array size integer :: shrlogunit ! original log unit @@ -135,50 +129,24 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) rc = ESMF_SUCCESS call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - !---------------------------------------------------------------------------- - ! generate local mpi comm - !---------------------------------------------------------------------------- - call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMGet(vm, localpet=my_task, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + mastertask = (my_task == master_task) - mastertask = my_task == master_task - - !---------------------------------------------------------------------------- ! determine instance information - !---------------------------------------------------------------------------- - call get_component_instance(gcomp, inst_suffix, inst_index, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- ! set logunit and set shr logging to my log file - !---------------------------------------------------------------------------- - call set_component_logging(gcomp, my_task==master_task, logunit, shrlogunit, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- ! Initialize xocn - !---------------------------------------------------------------------------- - - call dead_init_nuopc('ocn', inst_suffix, logunit, lsize, gbuf, nxg, nyg) - - allocate(gindex(lsize)) - allocate(lon(lsize)) - allocate(lat(lsize)) + call dead_read_inparms('ocn', inst_suffix, logunit, nxg, nyg) - gindex(:) = gbuf(:,dead_grid_index) - lat(:) = gbuf(:,dead_grid_lat) - lon(:) = gbuf(:,dead_grid_lon) - - !-------------------------------- ! advertise import and export fields - !-------------------------------- - call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then @@ -269,18 +237,12 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) enddo end if - call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - - !---------------------------------------------------------------------------- ! Reset shr logging to original values - !---------------------------------------------------------------------------- - call shr_file_setLogUnit (shrlogunit) end subroutine InitializeAdvertise !=============================================================================== - subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! input/output variables @@ -290,35 +252,26 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Mesh) :: Emesh - integer :: shrlogunit ! original log unit - integer :: n + integer :: shrlogunit ! original log unit + character(ESMF_MAXSTR) :: cvalue ! config data character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize: xocn) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - !---------------------------------------------------------------------------- ! Reset shr logging to my log file - !---------------------------------------------------------------------------- - call shr_file_getLogUnit (shrlogunit) call shr_file_setLogUnit (logunit) - !-------------------------------- ! generate the mesh - !-------------------------------- - - call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + call NUOPC_CompAttributeGet(gcomp, name='mesh_ocn', value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! realize the actively coupled fields, now that a mesh is established ! 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 fld_list_realize( & state=ExportState, & fldlist=fldsFrOcn, & @@ -326,7 +279,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & tag=subname//':docnExport',& - mesh=Emesh, rc=rc) + mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call fld_list_realize( & @@ -336,26 +289,18 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & tag=subname//':docnImport',& - mesh=Emesh, rc=rc) + mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! Pack export state - !-------------------------------- - call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! diagnostics - !-------------------------------- - if (dbug > 1) then call state_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -363,12 +308,9 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call shr_file_setLogUnit (shrlogunit) - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end subroutine InitializeRealize !=============================================================================== - subroutine ModelAdvance(gcomp, rc) ! intput/output variables @@ -383,43 +325,29 @@ subroutine ModelAdvance(gcomp, rc) !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + call memcheck(subname, 3, mastertask) call shr_file_getLogUnit (shrlogunit) call shr_file_setLogUnit (logunit) - !-------------------------------- ! Pack export state - !-------------------------------- - call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! diagnostics - !-------------------------------- - if (dbug > 1) then call state_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - if (my_task == master_task) then - call log_clock_advance(clock, 'OCN', logunit, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - endif endif call shr_file_setLogUnit (shrlogunit) - call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end subroutine ModelAdvance !=============================================================================== - subroutine state_setexport(exportState, rc) ! input/output variables @@ -427,11 +355,29 @@ subroutine state_setexport(exportState, rc) integer, intent(out) :: rc ! local variables - integer :: nf, nind + integer :: n, nf, nind + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) !-------------------------------------------------- rc = ESMF_SUCCESS + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + ! Start from index 2 in order to Skip the scalar field here do nf = 2,fldsFrOcn_num if (fldsFrOcn(nf)%ungridded_ubound == 0) then @@ -446,6 +392,9 @@ subroutine state_setexport(exportState, rc) end if end do + deallocate(lon) + deallocate(lat) + end subroutine state_setexport !=============================================================================== @@ -509,29 +458,18 @@ subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, end subroutine field_setexport !=============================================================================== - subroutine ModelFinalize(gcomp, rc) - type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - - ! local variables - character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' !------------------------------------------------------------------------------- - !-------------------------------- - ! Finalize routine - !-------------------------------- - rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - - call dead_final_nuopc('ocn', logunit) - - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + if (mastertask) then + write(logunit,*) + write(logunit,*) 'xocn: end of main integration loop' + write(logunit,*) + end if end subroutine ModelFinalize - !=============================================================================== - end module ocn_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 index 0a50403eb..d62bc458e 100644 --- a/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 @@ -15,12 +15,10 @@ module rof_comp_nuopc use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance - use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index - use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type - use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock implicit none private ! except @@ -43,10 +41,7 @@ module rof_comp_nuopc type (fld_list_type) :: fldsFrRof(fldsMax) integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost - real(r8), pointer :: gbuf(:,:) ! model info - real(r8), pointer :: lat(:) - real(r8), pointer :: lon(:) - integer , allocatable :: gindex(:) + type(ESMF_Mesh) :: mesh integer :: nxg ! global dim i-direction integer :: nyg ! global dim j-direction integer :: my_task ! my task in mpi @@ -55,8 +50,8 @@ module rof_comp_nuopc integer :: logunit ! logging unit number integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask - integer :: dbug = 1 - character(*),parameter :: modName = "(xrof_comp_nuopc)" + integer :: dbug = 0 + character(*),parameter :: modName = "(xrof_comp_nuopc)" character(*),parameter :: u_FILE_u = & __FILE__ @@ -109,8 +104,7 @@ subroutine SetServices(gcomp, rc) end subroutine SetServices -!=============================================================================== - + !=============================================================================== subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! input/output variables @@ -132,43 +126,23 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMGet(vm, localpet=my_task, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + mastertask = (my_task == master_task) - mastertask = my_task == master_task - - !---------------------------------------------------------------------------- ! determine instance information - !---------------------------------------------------------------------------- - call get_component_instance(gcomp, inst_suffix, inst_index, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- ! set logunit and set shr logging to my log file - !---------------------------------------------------------------------------- - call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- ! Initialize xrof - !---------------------------------------------------------------------------- - - call dead_init_nuopc('rof', inst_suffix, logunit, lsize, gbuf, nxg, nyg) - - allocate(gindex(lsize)) - allocate(lon(lsize)) - allocate(lat(lsize)) - - gindex(:) = gbuf(:,dead_grid_index) - lat(:) = gbuf(:,dead_grid_lat) - lon(:) = gbuf(:,dead_grid_lon) + call dead_read_inparms('rof', inst_suffix, logunit, nxg, nyg) !-------------------------------- ! advertise import and export fields @@ -260,7 +234,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) end subroutine InitializeAdvertise !=============================================================================== - subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! input/output arguments @@ -270,35 +243,27 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Mesh) :: Emesh - integer :: n - integer :: shrlogunit ! original log unit + integer :: shrlogunit ! original log unit + character(ESMF_MAXSTR) :: cvalue ! config data character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - !---------------------------------------------------------------------------- ! Reset shr logging to my log file - !---------------------------------------------------------------------------- - call shr_file_getLogUnit (shrlogunit) call shr_file_setLogUnit (logUnit) - !-------------------------------- - ! generate the mesh - !-------------------------------- - call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + ! generate the mesh + call NUOPC_CompAttributeGet(gcomp, name='mesh_rof', value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! realize the actively coupled fields, now that a mesh is established ! 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 fld_list_realize( & state=ExportState, & fldlist=fldsFrRof, & @@ -306,7 +271,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & tag=subname//':drofExport',& - mesh=Emesh, rc=rc) + mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call fld_list_realize( & @@ -316,7 +281,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & tag=subname//':drofImport',& - mesh=Emesh, rc=rc) + mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return !-------------------------------- @@ -325,13 +290,9 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - - call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & - flds_scalar_name, flds_scalar_num, rc) + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - - call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & - flds_scalar_name, flds_scalar_num, rc) + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return !-------------------------------- @@ -345,12 +306,9 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call shr_file_setLogUnit (shrlogunit) - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end subroutine InitializeRealize !=============================================================================== - subroutine ModelAdvance(gcomp, rc) ! input/output variables @@ -374,20 +332,13 @@ subroutine ModelAdvance(gcomp, rc) call shr_file_getLogUnit (shrlogunit) call shr_file_setLogUnit (logunit) - !-------------------------------- ! Pack export state - !-------------------------------- - call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call State_SetExport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! diagnostics - !-------------------------------- - if (dbug > 1) then call State_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -406,7 +357,6 @@ subroutine ModelAdvance(gcomp, rc) end subroutine ModelAdvance !=============================================================================== - subroutine state_setexport(exportState, rc) ! input/output variables @@ -414,11 +364,29 @@ subroutine state_setexport(exportState, rc) integer, intent(out) :: rc ! local variables - integer :: nf, nind + integer :: n, nf, nind + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) !-------------------------------------------------- rc = ESMF_SUCCESS + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + ! Start from index 2 in order to skip the scalar field do nf = 2,fldsFrRof_num if (fldsFrRof(nf)%ungridded_ubound == 0) then @@ -433,10 +401,12 @@ subroutine state_setexport(exportState, rc) end if end do + deallocate(lon) + deallocate(lat) + end subroutine state_setexport !=============================================================================== - subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) use shr_const_mod , only : pi=>shr_const_pi @@ -486,26 +456,18 @@ subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, end subroutine field_setexport !=============================================================================== - subroutine ModelFinalize(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - - ! local variables - character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' !------------------------------------------------------------------------------- - !-------------------------------- - ! Finalize routine - !-------------------------------- - rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - - call dead_final_nuopc('rof', logunit) - - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + if (mastertask) then + write(logunit,*) + write(logunit,*) 'xrof: end of main integration loop' + write(logunit,*) + end if end subroutine ModelFinalize end module rof_comp_nuopc diff --git a/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 b/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 index 981113760..ee3ca6b68 100644 --- a/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 +++ b/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 @@ -15,23 +15,13 @@ module dead_nuopc_mod implicit none private - public :: dead_init_nuopc - public :: dead_final_nuopc - public :: dead_meshinit + public :: dead_read_inparms public :: ModelInitPhase public :: ModelSetRunClock public :: fld_list_add public :: fld_list_realize ! !PUBLIC DATA MEMBERS: - integer, public :: dead_grid_lat = 1 ! lat from component - integer, public :: dead_grid_lon = 2 ! lon from component - integer, public :: dead_grid_area = 3 ! area from component - integer, public :: dead_grid_mask = 4 ! mask, 0 = inactive cell - integer, public :: dead_grid_frac = 5 ! fractional area coverage - integer, public :: dead_grid_index = 6 ! global index - integer, public :: dead_grid_total = 6 - type fld_list_type character(len=128) :: stdname integer :: ungridded_lbound = 0 @@ -48,25 +38,21 @@ module dead_nuopc_mod contains !=============================================================================== - subroutine dead_read_inparms(model, inst_suffix, logunit, & - nxg, nyg, decomp_type, nproc_x, seg_len) + subroutine dead_read_inparms(model, inst_suffix, logunit, nxg, nyg) ! input/output variables character(len=*) , intent(in) :: model character(len=*) , intent(in) :: inst_suffix ! char string associated with instance integer , intent(in) :: logunit ! logging unit number - integer , intent(out) :: nproc_x - integer , intent(out) :: seg_len integer , intent(out) :: nxg ! global dim i-direction integer , intent(out) :: nyg ! global dim j-direction - integer , intent(out) :: decomp_type ! decomposition type ! local variables type(ESMF_VM) :: vm character(CL) :: fileName ! generic file name integer :: nunit ! unit number integer :: unitn ! Unit for namelist file - integer :: tmp(5) ! array for broadcast + integer :: tmp(2) ! array for broadcast integer :: localPet ! mpi id of current task in current context integer :: rc ! return code character(*), parameter :: F00 = "('(dead_read_inparms) ',8a)" @@ -76,40 +62,26 @@ subroutine dead_read_inparms(model, inst_suffix, logunit, & !------------------------------------------------------------------------------- ! read the input parms (used to configure model) - nxg = -9999 - nyg = -9999 - nproc_x = -9999 - seg_len = -9999 - decomp_type = -9999 - call ESMF_VMGetCurrent(vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call ESMF_VMGet(vm, localPet=localPet, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + nxg = -9999 + nyg = -9999 + if (localPet==0) then open(newunit=unitn, file='x'//model//'_in'//trim(inst_suffix), status='old' ) read(unitn,*) nxg read(unitn,*) nyg - read(unitn,*) decomp_type - read(unitn,*) nproc_x - read(unitn,*) seg_len close (unitn) endif tmp(1) = nxg tmp(2) = nyg - tmp(3) = decomp_type - tmp(4) = nproc_x - tmp(5) = seg_len - - call ESMF_VMBroadcast(vm, tmp, 6, 0, rc=rc) - - nxg = tmp(1) - nyg = tmp(2) - decomp_type = tmp(3) - nproc_x = tmp(4) - seg_len = tmp(5) + call ESMF_VMBroadcast(vm, tmp, 3, 0, rc=rc) + nxg = tmp(1) + nyg = tmp(2) if (localPet==0) then write(logunit,*)' Read in X'//model//' input from file= x'//model//'_in' @@ -117,9 +89,6 @@ subroutine dead_read_inparms(model, inst_suffix, logunit, & write(logunit,F00) model,' Model : ',model write(logunit,F01) model,' NGX : ',nxg write(logunit,F01) model,' NGY : ',nyg - write(logunit,F01) model,' Decomposition : ',decomp_type - write(logunit,F03) model,' Num pes in X : ',nproc_x,' (type 3 only)' - write(logunit,F03) model,' Segment Length : ',seg_len,' (type 11 only)' write(logunit,F00) model,' inst_suffix : ',trim(inst_suffix) write(logunit,F00) model end if @@ -127,298 +96,6 @@ subroutine dead_read_inparms(model, inst_suffix, logunit, & end subroutine dead_read_inparms !=============================================================================== - - subroutine dead_setNewGrid(decomp_type, nxg, nyg, logunit, lsize, gbuf, seg_len, nproc_x) - - ! This sets up some defaults. The user may want to overwrite some - ! of these fields in the main program after initialization in complete. - - use shr_const_mod , only : shr_const_pi, shr_const_rearth - - ! input/output parameters: - integer , intent(in) :: decomp_type ! - integer , intent(in) :: nxg,nyg ! global grid sizes - integer , intent(in) :: logunit ! output logunit - integer , intent(out) :: lsize ! local grid sizes - real(R8), pointer :: gbuf(:,:) ! output data - integer , intent(in),optional :: seg_len ! seg len decomp setting - integer , intent(in),optional :: nproc_x ! 2d decomp setting - - ! local - type(ESMF_VM) :: vm - integer :: rc - integer :: mype - integer :: totpe ! total number of pes - logical :: found - integer :: i,j,ig,jg - integer :: n,ng,is,ie,js,je,nx,ny - integer :: npesx,npesy,mypex,mypey,nxp,nyp - real(R8) :: hscore,bscore - real(R8) :: dx,dy,deg2rad,ys,yc,yn,area,re - integer, allocatable :: gindex(:) - character(*), parameter :: F00 = "('(dead_setNewGrid) ',8a)" - character(*), parameter :: F01 = "('(dead_setNewGrid) ',a,4i8)" - character(*), parameter :: subName = "(dead_setNewGrid) " - !------------------------------------------------------------------------------- - - call ESMF_VMGetCurrent(vm, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMGet(vm, localPet=mype, peCount=totpe, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - if ( decomp_type == 1 .or. & - decomp_type == 2 .or. & - decomp_type == 3 .or. & - decomp_type == 4 .or. & - decomp_type == 11) then - else - ! invalid decomposition type - if (mype == 0) then - write(logunit,F01) 'ERROR: invalid decomp_type = ',decomp_type - end if - call shr_sys_abort(subName//'invalid decomp_type') - endif - - if (nxg*nyg == 0) then - lsize = 0 - allocate(gbuf(lsize,dead_grid_total)) - if (mype == 0) then - write(logunit,*) subname,' grid size is zero, lsize = ',lsize - end if - return - endif - - found = .false. - - if (decomp_type == 1) then ! 1d decomp by lat - npesx = 1 - npesy = totpe - found = .true. - elseif (decomp_type == 2) then ! 1d decomp by lon - npesx = totpe - npesy = 1 - found = .true. - elseif (decomp_type == 3) then ! 2d decomp - if (present(nproc_x)) then - if ( nproc_x > 0 ) then - npesx=nproc_x - npesy=totpe/npesx - if ( npesx*npesy /= totpe) then - write(logunit,F00) 'ERROR: uneven decomposition' - call shr_sys_abort(subName//'uneven decomp') - end if - found = .true. - endif - endif - if (.not.found) then ! narrow blocks - do nx = 1,totpe - ny = totpe/nx - if (nx*ny == totpe) then - npesx = nx - npesy = ny - found = .true. - endif - enddo - endif - elseif (decomp_type == 4) then ! 2d evenly divisible square block decomp - hscore = nxg*nyg - do nx = 1,totpe - ny = totpe/nx - if (nx*ny == totpe .and. mod(nxg,nx) == 0 .and. mod(nyg,ny) == 0) then - bscore = ((nxg*ny*1.0_r8) / (nyg*nx*1.0_r8)) - 1.0_r8 - bscore = bscore * bscore - if (bscore < hscore .or. .not.found) then - hscore = bscore - npesx = nx - npesy = ny - found = .true. - endif - endif - enddo - endif - - if (found) then - nx = nxg/npesx - mypex = mod(mype,npesx) - mypey = mype/npesx - is = (mypex ) * (nx) + 1 - ie = (mypex + 1) * (nx) - - ny = nyg/npesy - js = (mypey ) * (ny) + 1 - je = (mypey + 1) * (ny) - - nxp = nxg - (nx*npesx) ! extra lons not accounted for yet - nyp = nyg - (ny*npesy) ! extra lats not accounted for yet - - is = is + min(mypex,nxp) ! add them to first few pes and shift everything - ie = ie + min(mypex+1,nxp) - js = js + min(mypey,nyp) ! add them to first few pes and shift everything - je = je + min(mypey+1,nyp) - - lsize = (ie - is + 1) * (je - js + 1) - - allocate(gindex(lsize)) - n = 0 - do j = js,je - do i = is,ie - n = n + 1 - gindex(n) = (j-1)*nxg + i - enddo - enddo - endif - - if (.not.found) then - !------------------------------------------------------------------------- - ! type 11 general segment decomp - !------------------------------------------------------------------------- - nx = nxg*nyg / (totpe*13) + 1 ! 13 segments per pe (arbitrary) - ! nx override with seg_len - if (present(seg_len)) then - if (seg_len > 0) nx = seg_len - endif - - n = 0 - i = 0 - lsize = 0 - do while (n < nxg*nyg) - ny = min(nx,nxg*nyg-n) - do j = 1,ny - n = n + 1 - if (mype == mod(i,totpe)) then - lsize = lsize + 1 - endif - enddo - i = i + 1 - enddo - - allocate(gindex(lsize)) - - n = 0 - i = 0 - lsize = 0 - do while (n < nxg*nyg) - ny = min(nx,nxg*nyg-n) - do j = 1,ny - n = n + 1 - if (mype == mod(i,totpe)) then - lsize = lsize + 1 - gindex(lsize) = n - endif - enddo - i = i + 1 - enddo - - if (mype == 0) then - write(logunit,*) 'dead_setNewGrid decomp seg ',mype,lsize,nx - end if - - found = .true. - - endif - - if ( .not.found ) then - write(logunit,F01) 'ERROR: with decomp nxg,nyg,totpe=',nxg,nyg,totpe - call shr_sys_abort(subName//'decomp') - endif - - deg2rad = shr_const_pi / 180.0_R8 - re = shr_const_rearth - - allocate(gbuf(lsize,dead_grid_total)) - gbuf = -888.0_R8 - if (mype == 0) then - write(logunit,*) subname,' Decomp is ',decomp_type,' lsize = ',lsize - end if - - n=0 - dx = 360.0_R8/nxg * deg2rad - do n = 1,lsize - ig = mod((gindex(n)-1),nxg) + 1 - jg = (gindex(n)-1)/nxg + 1 - - ys = -90.0_R8 + (jg-1.0_R8)*180.0_R8/(nyg) - yc = -90.0_R8 + (jg-0.5_R8)*180.0_R8/(nyg) - yn = -90.0_R8 + (jg-0.0_R8)*180.0_R8/(nyg) - dy = sin(yn*deg2rad) - sin(ys*deg2rad) - area = dx*dy*re*re - - gbuf(n,dead_grid_lon ) = (ig-1.0_R8)*360.0_R8/(nxg) - gbuf(n,dead_grid_lat ) = yc - gbuf(n,dead_grid_index) = gindex(n) - gbuf(n,dead_grid_area ) = area - gbuf(n,dead_grid_mask ) = 0 - gbuf(n,dead_grid_frac ) = 1.0_R8 - enddo - - deallocate(gindex) - - end subroutine dead_setNewGrid - - !=============================================================================== - - subroutine dead_init_nuopc(model, inst_suffix, logunit, lsize, gbuf, nxg, nyg) - - ! input/output parameters: - character(len=*) , intent(in) :: model - character(len=*) , intent(in) :: inst_suffix ! char string associated with instance - integer , intent(in) :: logunit ! logging unit number - integer , intent(out) :: lsize ! logging unit number - real(r8) , pointer :: gbuf(:,:) ! model grid - integer , pointer :: gindex(:) ! global index space - integer , intent(out) :: nxg ! global dim i-direction - integer , intent(out) :: nyg ! global dim j-direction - - !--- local variables --- - integer :: local_comm ! local communicator - integer :: nproc_x - integer :: seg_len - integer :: decomp_type - character(*), parameter :: subName = "(dead_init_nuopc) " - !------------------------------------------------------------------------------- - - ! Read input parms - call dead_read_inparms(model, inst_suffix, logunit, nxg, nyg, decomp_type, nproc_x, seg_len) - - ! Initialize grid - call dead_setNewGrid(decomp_type, nxg, nyg, logunit, lsize, gbuf, seg_len, nproc_x) - - end subroutine dead_init_nuopc - - !=============================================================================== - - subroutine dead_final_nuopc(model, logunit) - - ! finalize method for xcpl component - - ! input/output parameters: - character(len=*) , intent(in) :: model - integer , intent(in) :: logunit ! logging unit number - - ! local variables - type(ESMF_VM) :: vm - integer :: rc - integer :: localPet - character(*), parameter :: F00 = "('(dead_comp_final) ',8a)" - character(*), parameter :: F91 = "('(dead_comp_final) ',73('-'))" - character(*), parameter :: subName = "(dead_comp_final) " - !------------------------------------------------------------------------------- - - call ESMF_VMGetCurrent(vm, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMGet(vm, localPet=localPet, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - if (localPet==0) then - write(logunit,F91) - write(logunit,F00) trim(model),': end of main integration loop' - write(logunit,F91) - end if - - end subroutine dead_final_nuopc - - !=============================================================================== - subroutine fld_list_add(num, fldlist, stdname, ungridded_lbound, ungridded_ubound) ! input/output variables @@ -449,7 +126,6 @@ subroutine fld_list_add(num, fldlist, stdname, ungridded_lbound, ungridded_uboun end subroutine fld_list_add !=============================================================================== - subroutine fld_list_realize(state, fldList, numflds, flds_scalar_name, flds_scalar_num, mesh, tag, rc) use NUOPC , only : NUOPC_IsConnected, NUOPC_Realize @@ -555,7 +231,6 @@ end subroutine SetScalarField end subroutine fld_list_realize !=============================================================================== - subroutine ModelInitPhase(gcomp, importState, exportState, clock, rc) use NUOPC, only : NUOPC_CompFilterPhaseMap @@ -575,12 +250,11 @@ subroutine ModelInitPhase(gcomp, importState, exportState, clock, rc) end subroutine ModelInitPhase !=============================================================================== - subroutine ModelSetRunClock(gcomp, rc) - use ESMF , only : ESMF_ClockGetAlarmList, ESMF_ALARMLIST_ALL - use NUOPC_Model , only : NUOPC_ModelGet - use NUOPC , only : NUOPC_CompAttributeGet + use ESMF , only : ESMF_ClockGetAlarmList, ESMF_ALARMLIST_ALL + use NUOPC_Model , only : NUOPC_ModelGet + use NUOPC , only : NUOPC_CompAttributeGet ! input/output variables type(ESMF_GridComp) :: gcomp @@ -602,7 +276,6 @@ subroutine ModelSetRunClock(gcomp, rc) !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - if (dbug_flag > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO) ! query the Component for its clocks call NUOPC_ModelGet(gcomp, driverClock=dclock, modelClock=mclock, rc=rc) @@ -668,240 +341,6 @@ subroutine ModelSetRunClock(gcomp, rc) call ESMF_ClockSet(mclock, currTime=dcurrtime, timeStep=dtimestep, stopTime=mstoptime, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - if (dbug_flag > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO) - end subroutine ModelSetRunClock - !=============================================================================== - - subroutine dead_meshinit(gcomp, nx_global, ny_global, gindex, lon, lat, Emesh, rc) - - !----------------------------------------- - ! create an Emesh object for Fields - !----------------------------------------- - - use ESMF , only : ESMF_GridComp, ESMF_VM, ESMF_Mesh - use ESMF , only : ESMF_VMGet, ESMF_GridCompGet, ESMF_VMBroadCast, ESMF_VMAllGatherV - use ESMF , only : ESMF_SUCCESS, ESMF_LOGMSG_INFO, ESMF_LogWrite - use ESMF , only : ESMF_VMGather, ESMF_LogFoundError, ESMF_LOGERR_PASSTHRU - use ESMF , only : ESMF_MeshCreate, ESMF_COORDSYS_SPH_DEG, ESMF_REDUCE_SUM - use ESMF , only : ESMF_VMAllReduce, ESMF_MESHELEMTYPE_QUAD - - ! input/output arguments - type(ESMF_GridComp) :: gcomp - integer , intent(in) :: nx_global - integer , intent(in) :: ny_global - integer , intent(in) :: gindex(:) - real(r8), pointer , intent(in) :: lon(:) - real(r8), pointer , intent(in) :: lat(:) - type(ESMF_Mesh) , intent(inout) :: Emesh - integer , intent(inout) :: rc - - ! local variables - integer :: n,n1,n2,de - integer :: iam - integer :: lsize - integer :: numTotElems, numNodes, numConn, nodeindx - integer :: iur,iul,ill,ilr - integer :: xid, yid, xid0, yid0 - real(r8) :: lonur, lonul, lonll, lonlr - integer, pointer :: iurpts(:) - integer, pointer :: elemIds(:) - integer, pointer :: elemTypes(:) - integer, pointer :: elemConn(:) - real(r8),pointer :: elemCoords(:) - integer, pointer :: nodeIds(:) - integer, pointer :: nodeOwners(:) - real(r8),pointer :: nodeCoords(:) - real(r8),pointer :: latG(:) - real(r8),pointer :: lonG(:) - integer ,pointer :: pes_local(:) - integer ,pointer :: pes_global(:) - integer, pointer :: recvOffsets(:) - integer, pointer :: recvCounts(:) - integer :: sendData(1) - type(ESMF_VM) :: vm - integer :: petCount - character(len=*),parameter :: subname='(dead_MeshInit)' - !-------------------------------------------------------------- - - rc = ESMF_SUCCESS - - call ESMF_LogWrite(subname, ESMF_LOGMSG_INFO, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - lsize = size(gindex) - - call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - call ESMF_VMGet(vm, petCount=petCount, localpet=iam, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - allocate(latG(nx_global*ny_global)) - allocate(lonG(nx_global*ny_global)) - - allocate(recvoffsets(petCount)) - allocate(recvCounts(petCount)) - - sendData(1) = lsize - call ESMF_VMGather(vm, sendData=sendData, recvData=recvCounts, count=1, rootPet=0, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - call ESMF_VMBroadCast(vm, bcstData=recvCounts, count=petCount, rootPet=0, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - recvoffsets(1) = 0 - do n = 2,petCount - recvoffsets(n) = recvoffsets(n-1) + recvCounts(n-1) - end do - - call ESMF_VMAllGatherV(vm, lat, lsize, latG, recvCounts, recvOffsets, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - call ESMF_VMAllGatherV(vm, lon, lsize, lonG, recvCounts, recvOffsets, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - deallocate(recvoffsets) - deallocate(recvCounts) - - ! assumes quadrilaterals for each gridcell (element) - ! element index matches gsmap index value - ! nodeid at lower left of each gridcell matches gsmap index value - ! assumes wrap around in x direction but no wrap in y direction - ! node ids need to be described in counter clockwise direction - ! node id associated with lower left cell is assigned to local PET - ! node ids at top of y boundary assigned to the element to the right - - numTotElems = lsize - - allocate(elemIds(numTotElems)) - allocate(elemTypes(numTotElems)) - elemTypes=(/ESMF_MESHELEMTYPE_QUAD/) - allocate(elemConn(4*numTotElems)) - allocate(elemCoords(2*numTotElems)) - - allocate(nodeIds(numTotElems*4)) - nodeIds = -99 - - elemIds(:) = gindex(:) - numNodes = 0 - numConn = 0 - - do n = 1,numTotElems - elemTypes(n) = ESMF_MESHELEMTYPE_QUAD - elemCoords(2*n-1) = lon(n) - elemCoords(2*n) = lat(n) - - do n1 = 1,4 - - numNodes = numNodes + 1 - nodeindx = numNodes - if (n1 == 1 .or. n1 == 3) xid = mod(elemIds(n)-1,nx_global) + 1 - if (n1 == 2 .or. n1 == 4) xid = mod(elemIds(n) ,nx_global) + 1 - if (n1 == 1 .or. n1 == 2) yid = (elemIds(n)-1)/nx_global + 1 - if (n1 == 3 .or. n1 == 4) yid = (elemIds(n)-1)/nx_global + 2 - nodeIds(numNodes) = (yid-1) * nx_global + xid - n2 = 0 - do while (n2 < numNodes - 1 .and. nodeindx == numNodes) - n2 = n2 + 1 - if (nodeIds(numNodes) == nodeIds(n2)) nodeindx = n2 - enddo - if (nodeindx /= numNodes) then - numNodes = numNodes - 1 - endif - - numConn = numConn + 1 - elemConn(numConn) = nodeindx - enddo - enddo - - - allocate(nodeCoords(2*numNodes)) - allocate(nodeOwners(numNodes)) - allocate(iurpts(numNodes)) - - do n = 1,numNodes - - xid0 = mod(nodeIds(n)-1, nx_global) + 1 - yid0 = (nodeIds(n)-1) / nx_global + 1 - - xid = xid0 - yid = max(min(yid0,ny_global),1) - iur = (yid-1) * nx_global + xid - iurpts(n) = iur - - xid = mod(xid0 - 2 + nx_global, nx_global) + 1 - yid = max(min(yid0,ny_global),1) - iul = (yid-1) * nx_global + xid - - xid = mod(xid0 - 2 + nx_global, nx_global) + 1 - yid = max(min(yid0-1,ny_global),1) - ill = (yid-1) * nx_global + xid - - xid = xid0 - yid = max(min(yid0-1,ny_global),1) - ilr = (yid-1) * nx_global + xid - - ! write(tmpstr,'(2a,8i6)') subname,' nodecoord = ',n,nodeIds(n),xid0,yid0,iur,iul,ill,ilr - ! call ESMF_LogWrite(trim(tmpstr), ESMF_LOGMSG_INFO) - - ! need to normalize lon values to same 360 degree setting, use lonur as reference value - lonur = lonG(iur) - lonul = lonG(iul) - lonll = lonG(ill) - lonlr = lonG(ilr) - - if (abs(lonul + 360._r8 - lonur) < abs(lonul - lonur)) lonul = lonul + 360._r8 - if (abs(lonul - 360._r8 - lonur) < abs(lonul - lonur)) lonul = lonul - 360._r8 - if (abs(lonll + 360._r8 - lonur) < abs(lonll - lonur)) lonll = lonll + 360._r8 - if (abs(lonll - 360._r8 - lonur) < abs(lonll - lonur)) lonll = lonll - 360._r8 - if (abs(lonlr + 360._r8 - lonur) < abs(lonlr - lonur)) lonlr = lonlr + 360._r8 - if (abs(lonlr - 360._r8 - lonur) < abs(lonlr - lonur)) lonlr = lonlr - 360._r8 - - nodeCoords(2*n-1) = 0.25_r8 * (lonur + lonul + lonll + lonlr) - nodeCoords(2*n) = 0.25_r8 * (latG(iur) + latG(iul) + latG(ill) + latG(ilr)) - enddo - - deallocate(lonG) - deallocate(latG) - - ! Determine the pes that own each index of iurpts (nodeOwners) - - allocate(pes_local(nx_global*ny_global)) - allocate(pes_global(nx_global*ny_global)) - pes_local(:) = 0 - do n = 1,lsize - pes_local(gindex(n)) = iam - end do - - call ESMF_VMAllReduce(vm, sendData=pes_local, recvData=pes_global, count=nx_global*ny_global, & - reduceflag=ESMF_REDUCE_SUM, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - do n = 1,numNodes - nodeOwners(n) = pes_global(iurpts(n)) - end do - deallocate(pes_local) - deallocate(pes_global) - - Emesh = ESMF_MeshCreate(parametricDim=2, & - spatialDim=2, & - coordSys=ESMF_COORDSYS_SPH_DEG, & - nodeIds=nodeIds(1:numNodes), & - nodeCoords=nodeCoords, & - nodeOwners=nodeOwners, & - elementIds=elemIds,& - elementTypes=elemTypes, & - elementConn=elemConn, & - elementCoords=elemCoords, & - rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - deallocate(iurpts) - deallocate(nodeIds, nodeCoords, nodeOwners) - deallocate(elemIds, elemTypes, elemConn, elemCoords) - - end subroutine dead_meshinit - end module dead_nuopc_mod diff --git a/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 index 174847a95..2bb08fc29 100644 --- a/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 @@ -17,10 +17,8 @@ module wav_comp_nuopc use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance - use dead_nuopc_mod , only : dead_grid_lat, dead_grid_lon, dead_grid_index - use dead_nuopc_mod , only : dead_init_nuopc, dead_final_nuopc, dead_meshinit + use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type - use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock implicit none private ! except @@ -43,10 +41,7 @@ module wav_comp_nuopc type (fld_list_type) :: fldsFrWav(fldsMax) integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost - real(r8), pointer :: gbuf(:,:) ! model info - real(r8), pointer :: lat(:) - real(r8), pointer :: lon(:) - integer , allocatable :: gindex(:) + type(ESMF_Mesh) :: mesh integer :: nxg ! global dim i-direction integer :: nyg ! global dim j-direction integer :: my_task ! my task in mpi communicator mpicom @@ -108,9 +103,7 @@ subroutine SetServices(gcomp, rc) end subroutine SetServices - !=============================================================================== - subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! input/output variables @@ -143,38 +136,18 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) mastertask = (my_task == 0) - !---------------------------------------------------------------------------- ! determine instance information - !--------------------------------------------------------------------------- - call get_component_instance(gcomp, inst_suffix, inst_index, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- ! set logunit and set shr logging to my log file - !---------------------------------------------------------------------------- - call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- ! Initialize xwav - !---------------------------------------------------------------------------- - - call dead_init_nuopc('wav', inst_suffix, logunit, lsize, gbuf, nxg, nyg) - - allocate(gindex(lsize)) - allocate(lon(lsize)) - allocate(lat(lsize)) + call dead_read_inparms('wav', inst_suffix, logunit, nxg, nyg) - gindex(:) = gbuf(:,dead_grid_index) - lat(:) = gbuf(:,dead_grid_lat) - lon(:) = gbuf(:,dead_grid_lon) - - !-------------------------------- ! advertise import and export fields - !-------------------------------- - call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then @@ -254,16 +227,12 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- ! Reset shr logging to original values - !---------------------------------------------------------------------------- - call shr_file_setLogUnit (shrlogunit) end subroutine InitializeAdvertise !=============================================================================== - subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! input/output variables @@ -273,34 +242,26 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Mesh) :: Emesh - integer :: shrlogunit ! original log unit + integer :: shrlogunit ! original log unit + character(ESMF_MAXSTR) :: cvalue ! config data character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - !---------------------------------------------------------------------------- ! Reset shr logging to my log file - !---------------------------------------------------------------------------- - call shr_file_getLogUnit (shrlogunit) call shr_file_setLogUnit (logunit) - !-------------------------------- ! generate the mesh - !-------------------------------- - - call dead_meshinit(gcomp, nxg, nyg, gindex, lon, lat, Emesh, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + call NUOPC_CompAttributeGet(gcomp, name='mesh_wav', value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! realize the actively coupled fields, now that a mesh is established ! 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 fld_list_realize( & state=ExportState, & fldlist=fldsFrWav, & @@ -308,7 +269,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & tag=subname//':dwavExport',& - mesh=Emesh, rc=rc) + mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call fld_list_realize( & @@ -318,28 +279,18 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & tag=subname//':dwavImport',& - mesh=Emesh, rc=rc) + mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! Pack export state - !-------------------------------- - call State_SetExport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - - call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & - flds_scalar_name, flds_scalar_num, rc) + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - - call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & - flds_scalar_name, flds_scalar_num, rc) + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! diagnostics - !-------------------------------- - if (dbug > 1) then call State_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -347,12 +298,9 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call shr_file_setLogUnit (shrlogunit) - call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end subroutine InitializeRealize !=============================================================================== - subroutine ModelAdvance(gcomp, rc) ! input/output variables @@ -368,28 +316,18 @@ subroutine ModelAdvance(gcomp, rc) rc = ESMF_SUCCESS - if (dbug > 5) then - call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - end if call memcheck(subname, 3, mastertask) call shr_file_getLogUnit (shrlogunit) call shr_file_setLogUnit (logunit) - !-------------------------------- ! Pack export state - !-------------------------------- - call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! diagnostics - !-------------------------------- - if (dbug > 1) then call State_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -401,14 +339,9 @@ subroutine ModelAdvance(gcomp, rc) call shr_file_setLogUnit (shrlogunit) - if (dbug > 5) then - call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end if - end subroutine ModelAdvance !=============================================================================== - subroutine state_setexport(exportState, rc) ! input/output variables @@ -416,11 +349,30 @@ subroutine state_setexport(exportState, rc) integer , intent(out) :: rc ! local variables - integer :: nf, nind, nfstart, ubound + integer :: nfstart, ubound + integer :: n, nf, nind + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) !-------------------------------------------------- rc = ESMF_SUCCESS + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + nfstart = 0 ! for fields that have ubound > 0 do nf = 2,fldsFrWav_num ! Start from index 2 in order to skip the scalar field ubound = fldsFrWav(nf)%ungridded_ubound @@ -437,6 +389,9 @@ subroutine state_setexport(exportState, rc) end if end do + deallocate(lon) + deallocate(lat) + end subroutine state_setexport !=============================================================================== @@ -493,26 +448,18 @@ subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, end subroutine field_setexport !=============================================================================== - subroutine ModelFinalize(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - - ! local variables - character(len=*),parameter :: subname=trim(modName)//':(ModelFinalize) ' !------------------------------------------------------------------------------- - !-------------------------------- - ! Finalize routine - !-------------------------------- - rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - - call dead_final_nuopc('wav', logunit) - - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + if (mastertask) then + write(logunit,*) + write(logunit,*) 'xwav: end of main integration loop' + write(logunit,*) + end if end subroutine ModelFinalize end module wav_comp_nuopc From 181979fdce9f6940eefef9c47f1eb16d0c4b9a77 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Thu, 6 Aug 2020 13:42:37 -0600 Subject: [PATCH 06/24] updates that remove the input inparm for any dead component --- .../xatm/cime_config/buildnml | 4 +- .../xatm/src/atm_comp_nuopc.F90 | 236 ++++++------- .../xglc/cime_config/buildnml | 4 +- .../xglc/src/glc_comp_nuopc.F90 | 170 +++------- .../xice/cime_config/buildnml | 4 +- .../xice/src/ice_comp_nuopc.F90 | 310 +++++++----------- .../xlnd/cime_config/buildnml | 4 +- .../xlnd/src/lnd_comp_nuopc.F90 | 308 ++++++----------- .../xocn/cime_config/buildnml | 4 +- .../xocn/src/ocn_comp_nuopc.F90 | 184 +++++------ .../xrof/cime_config/buildnml | 4 +- .../xrof/src/rof_comp_nuopc.F90 | 193 ++++------- .../xshare/dead_nuopc_mod.F90 | 59 ---- .../xwav/cime_config/buildnml | 4 +- .../xwav/src/wav_comp_nuopc.F90 | 186 ++++------- 15 files changed, 594 insertions(+), 1080 deletions(-) diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml index 50a814c79..5b580324e 100755 --- a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml @@ -10,13 +10,13 @@ _CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",".."," sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * -from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.buildnml import parse_input from CIME.case import Case def buildnml(case, caseroot, compname): if compname != "xatm": raise AttributeError - build_xcpl_nml(case, caseroot, compname) + # Do nothing def _main_func(): caseroot = parse_input(sys.argv) diff --git a/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 index 7386883d6..b8a4d9e97 100644 --- a/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 @@ -14,10 +14,8 @@ module atm_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck - use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance - use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, memcheck, set_component_logging + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type implicit none @@ -42,11 +40,9 @@ module atm_comp_nuopc integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost type(ESMF_Mesh) :: mesh - integer :: nxg ! global dim i-direction - integer :: nyg ! global dim j-direction + real(r8), pointer :: lat(:) ! mesh lats + real(r8), pointer :: lon(:) ! mesh lons integer :: my_task ! my task in mpi communicator mpicom - integer :: inst_index ! number of current instance (ie. 1) - character(len=5) :: inst_suffix ! char string associated with instance (ie. "_0001" or "") integer :: logunit ! logging unit number logical :: mastertask integer :: dbug = 0 @@ -114,9 +110,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm - character(CS) :: stdname integer :: n - integer :: lsize ! local array size integer :: shrlogunit ! original log unit character(CL) :: cvalue character(len=CL) :: logmsg @@ -128,23 +122,14 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMGet(vm, localpet=my_task, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - mastertask = (my_task==0) - ! determine instance information - call get_component_instance(gcomp, inst_suffix, inst_index, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! set logunit and set shr logging to my log file call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! Initialize xatm - call dead_read_inparms('atm', inst_suffix, logunit, nxg, nyg) - ! advertise import and export fields call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -200,77 +185,71 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxNextSwCday') endif - if (nxg /= 0 .and. nyg /= 0) then - - call fld_list_add(fldsFrAtm_num, fldsFrAtm, trim(flds_scalar_name)) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_topo' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_z' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_u' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_v' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_tbot' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_ptem' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_shum' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_pbot' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_dens' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_pslv' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainc' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainl' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowc' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowl' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_lwdn' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swndr' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swvdr' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swndf' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swvdf' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swnet' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_dstwet', ungridded_lbound=1, ungridded_ubound=4) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_dstdry', ungridded_lbound=1, ungridded_ubound=4) - - call fld_list_add(fldsToAtm_num, fldsToAtm, trim(flds_scalar_name)) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_anidr' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_avsdf' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_anidf' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_avsdr' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_lfrac' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Si_ifrac' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_ofrac' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_tref' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_qref' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_t' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_t' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_fv' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_ram1' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_snowh' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Si_snowh' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_ssq' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_re' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_u10' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_taux' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_tauy' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_lat' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_sen' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_lwup' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_evap' ) - - do n = 1,fldsFrAtm_num - if(mastertask) write(logunit,*)'Advertising From Xatm ',trim(fldsFrAtm(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrAtm(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - end do - - do n = 1,fldsToAtm_num - if(mastertask) write(logunit,*)'Advertising To Xatm',trim(fldsToAtm(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToAtm(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo - end if + call fld_list_add(fldsFrAtm_num, fldsFrAtm, trim(flds_scalar_name)) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_topo' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_z' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_u' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_v' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_tbot' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_ptem' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_shum' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_pbot' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_dens' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_pslv' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainc' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainl' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowc' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowl' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_lwdn' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swndr' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swvdr' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swndf' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swvdf' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swnet' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_dstwet', ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_dstdry', ungridded_lbound=1, ungridded_ubound=4) + + call fld_list_add(fldsToAtm_num, fldsToAtm, trim(flds_scalar_name)) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_anidr' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_avsdf' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_anidf' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_avsdr' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_lfrac' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Si_ifrac' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_ofrac' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_tref' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_qref' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_t' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_t' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_fv' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_ram1' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_snowh' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Si_snowh' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_ssq' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_re' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_u10' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_taux' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_tauy' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_lat' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_sen' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_lwup' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_evap' ) + + do n = 1,fldsFrAtm_num + if(mastertask) write(logunit,*)'Advertising From Xatm ',trim(fldsFrAtm(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrAtm(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do - ! Reset shr logging to original values - call shr_file_setLogUnit (shrlogunit) + do n = 1,fldsToAtm_num + if(mastertask) write(logunit,*)'Advertising To Xatm',trim(fldsToAtm(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToAtm(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo end subroutine InitializeAdvertise @@ -286,22 +265,20 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_Time) :: nextTime real(r8) :: nextsw_cday - integer :: n - integer :: shrlogunit ! original log unit - character(ESMF_MAXSTR) :: cvalue ! config data + integer :: n, nxg, nyg + integer :: shrlogunit ! original log unit + character(ESMF_MAXSTR) :: cvalue ! config data + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize: xatm) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - ! Reset shr logging to my log file - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logUnit) - ! generate the mesh call NUOPC_CompAttributeGet(gcomp, name='mesh_atm', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -328,11 +305,27 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + ! determine the mes lats and lons (module variables) + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + nxg = numownedElements + nyg = 1 + ! Pack export state call state_setexport(exportState, rc=rc) - call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) + call State_SetScalar(dble(nxg), flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) + call State_SetScalar(dble(nyg), flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return ! Set time of next radiation computation @@ -350,8 +343,6 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) - end subroutine InitializeRealize !=============================================================================== @@ -371,43 +362,23 @@ subroutine ModelAdvance(gcomp, rc) rc = ESMF_SUCCESS - if (dbug > 1) then - call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - end if call memcheck(subname, 3, mastertask) - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) - - !-------------------------------- ! Pack export state - !-------------------------------- - call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call 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 - !-------------------------------- ! diagnostics - !-------------------------------- - if (dbug > 1) then call state_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - if (mastertask) then - call log_clock_advance(clock, 'XATM', logunit, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - endif endif - call shr_file_setLogUnit (shrlogunit) - end subroutine ModelAdvance !=============================================================================== @@ -418,29 +389,11 @@ subroutine state_setexport(exportState, rc) integer, intent(out) :: rc ! local variables - integer :: n, nf, nind - real(r8), pointer :: lat(:) - real(r8), pointer :: lon(:) - integer :: spatialDim - integer :: numOwnedElements - real(R8), pointer :: ownedElemCoords(:) + integer :: nf, nind !-------------------------------------------------- rc = ESMF_SUCCESS - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(lon(numownedElements)) - allocate(lat(numownedElements)) - do n = 1,numownedElements - lon(n) = ownedElemCoords(2*n-1) - lat(n) = ownedElemCoords(2*n) - end do - ! Start from index 2 in order to Skip the scalar field here do nf = 2,fldsFrAtm_num if (fldsFrAtm(nf)%ungridded_ubound == 0) then @@ -455,9 +408,6 @@ subroutine state_setexport(exportState, rc) end if end do - deallocate(lon) - deallocate(lat) - end subroutine state_setexport !=============================================================================== diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml index 64077a469..488ba2b07 100755 --- a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml @@ -10,13 +10,13 @@ _CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",".."," sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * -from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.buildnml import parse_input from CIME.case import Case def buildnml(case, caseroot, compname): if compname != "xglc": raise AttributeError - build_xcpl_nml(case, caseroot, compname) + # do nothing def _main_func(): caseroot = parse_input(sys.argv) diff --git a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 index 8bf8b8b6e..225f745fc 100644 --- a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 @@ -14,10 +14,8 @@ module glc_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck - use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance - use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, memcheck, set_component_logging + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type implicit none @@ -41,13 +39,11 @@ module glc_comp_nuopc integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost type(ESMF_Mesh) :: mesh - integer :: nxg ! global dim i-direction - integer :: nyg ! global dim j-direction - integer :: my_task ! my task in mpi communicator mpicom - 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 - integer ,parameter :: master_task=0 ! task number of master task + real(r8), pointer :: lat(:) ! mesh lats + real(r8), pointer :: lon(:) ! mesh lons + integer :: my_task ! my task in mpi communicator mpicom + integer :: logunit ! logging unit number + integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask integer :: dbug = 0 character(*),parameter :: modName = "(xglc_comp_nuopc)" @@ -114,9 +110,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm - character(CS) :: stdname integer :: n - integer :: lsize ! local array size integer :: shrlogunit ! original log unit character(CL) :: cvalue character(len=CL) :: logmsg @@ -128,23 +122,14 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMGet(vm, localpet=my_task, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - mastertask = (my_task == master_task) - ! determine instance information - call get_component_instance(gcomp, inst_suffix, inst_index, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - ! set logunit and set shr logging to my log file call set_component_logging(gcomp, my_task==master_task, logunit, shrlogunit, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - ! Initialize xglc - call dead_read_inparms('glc', inst_suffix, logunit, nxg, nyg) - ! advertise import and export fields call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -189,36 +174,30 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') endif - if (nxg /= 0 .and. nyg /= 0) then - - call fld_list_add(fldsFrGlc_num, fldsFrGlc, trim(flds_scalar_name)) - call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_icemask' ) - call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_icemask_coupled_fluxes' ) - call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_ice_covered' ) - call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_topo' ) - call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Flgg_hflx' ) - - call fld_list_add(fldsToGlc_num, fldsToGlc, trim(flds_scalar_name)) - call fld_list_add(fldsToGlc_num, fldsToGlc, 'Sl_tsrf') - call fld_list_add(fldsToGlc_num, fldsToGlc, 'Flgl_qice') - - do n = 1,fldsFrGlc_num - if (mastertask) write(logunit,*)'Advertising From Xglc ',trim(fldsFrGlc(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrglc(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo - - do n = 1,fldsToGlc_num - if (mastertask) write(logunit,*)'Advertising To Xglc ',trim(fldsToGlc(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToglc(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo - end if + call fld_list_add(fldsFrGlc_num, fldsFrGlc, trim(flds_scalar_name)) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_icemask' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_icemask_coupled_fluxes' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_ice_covered' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_topo' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Flgg_hflx' ) + + call fld_list_add(fldsToGlc_num, fldsToGlc, trim(flds_scalar_name)) + call fld_list_add(fldsToGlc_num, fldsToGlc, 'Sl_tsrf') + call fld_list_add(fldsToGlc_num, fldsToGlc, 'Flgl_qice') + + do n = 1,fldsFrGlc_num + if (mastertask) write(logunit,*)'Advertising From Xglc ',trim(fldsFrGlc(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrglc(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo - ! Reset shr logging to original values - call shr_file_setLogUnit (shrlogunit) + do n = 1,fldsToGlc_num + if (mastertask) write(logunit,*)'Advertising To Xglc ',trim(fldsToGlc(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToglc(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo end subroutine InitializeAdvertise @@ -233,37 +212,25 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - integer :: n - integer :: shrlogunit ! original log unit + integer :: n, nxg, nyg character(ESMF_MAXSTR) :: cvalue ! config data + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - !---------------------------------------------------------------------------- - ! Reset shr logging to my log file - !---------------------------------------------------------------------------- - - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) - - !-------------------------------- ! generate the mesh - !-------------------------------- - call NUOPC_CompAttributeGet(gcomp, name='mesh_glc', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! realize the actively coupled fields, now that a mesh is established ! 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 fld_list_realize( & state=ExportState, & fldList=fldsFrGlc, & @@ -284,38 +251,39 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- - ! Pack export state - ! Copy from d2x to exportState - ! Set the coupling scalars - !-------------------------------- + ! determine the mes lats and lons (module variables) + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + nxg = numownedElements + nyg = 1 + + ! Pack export state call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - - call state_setscalar(dble(nxg),flds_scalar_index_nx, exportState, & - flds_scalar_name, flds_scalar_num, rc) + call state_setscalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - - call state_setscalar(dble(nyg),flds_scalar_index_ny, exportState, & - flds_scalar_name, flds_scalar_num, rc) + call state_setscalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! diagnostics - !-------------------------------- - if (dbug > 1) then call state_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) - end subroutine InitializeRealize !=============================================================================== - subroutine ModelAdvance(gcomp, rc) ! input/output variables @@ -326,7 +294,6 @@ subroutine ModelAdvance(gcomp, rc) type(ESMF_Clock) :: clock type(ESMF_State) :: exportState integer :: n - integer :: shrlogunit ! original log unit real(r8), pointer :: dataptr(:) character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- @@ -334,16 +301,9 @@ subroutine ModelAdvance(gcomp, rc) rc = ESMF_SUCCESS call memcheck(subname, 3, mastertask) - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) - - !-------------------------------- ! Pack export state - !-------------------------------- - call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -353,8 +313,6 @@ subroutine ModelAdvance(gcomp, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) - end subroutine ModelAdvance !=============================================================================== @@ -365,29 +323,11 @@ subroutine state_setexport(exportState, rc) integer, intent(out) :: rc ! local variables - integer :: n, nf, nind - real(r8), pointer :: lat(:) - real(r8), pointer :: lon(:) - integer :: spatialDim - integer :: numOwnedElements - real(R8), pointer :: ownedElemCoords(:) + integer :: nf, nind !-------------------------------------------------- rc = ESMF_SUCCESS - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(lon(numownedElements)) - allocate(lat(numownedElements)) - do n = 1,numownedElements - lon(n) = ownedElemCoords(2*n-1) - lat(n) = ownedElemCoords(2*n) - end do - ! Start from index 2 in order to skip the scalar field do nf = 2,fldsFrGlc_num if (fldsFrGlc(nf)%ungridded_ubound == 0) then @@ -402,13 +342,9 @@ subroutine state_setexport(exportState, rc) end if end do - deallocate(lon) - deallocate(lat) - end subroutine state_setexport !=============================================================================== - subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) use shr_const_mod , only : pi=>shr_const_pi diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml index e023dc7c6..62967b52e 100755 --- a/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml @@ -10,13 +10,13 @@ _CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",".."," sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * -from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.buildnml import parse_input from CIME.case import Case def buildnml(case, caseroot, compname): if compname != "xice": raise AttributeError - build_xcpl_nml(case, caseroot, compname) + # do nothing def _main_func(): caseroot = parse_input(sys.argv) diff --git a/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 index d531da74a..f5da13a51 100644 --- a/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 @@ -5,20 +5,18 @@ module ice_comp_nuopc !---------------------------------------------------------------------------- use ESMF - 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 - use shr_sys_mod , only : shr_sys_abort - use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck - use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance - use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock - use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, memcheck, set_component_logging + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type implicit none private ! except @@ -41,13 +39,11 @@ module ice_comp_nuopc integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost type(ESMF_Mesh) :: mesh - integer :: nxg ! global dim i-direction - integer :: nyg ! global dim j-direction - integer :: my_task ! my task in mpi communicator mpicom - 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 - integer ,parameter :: master_task=0 ! task number of master task + real(r8), pointer :: lat(:) ! mesh lats + real(r8), pointer :: lon(:) ! mesh lons + integer :: my_task ! my task in mpi communicator mpicom + integer :: logunit ! logging unit number + integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask integer :: dbug = 0 character(*),parameter :: modName = "(xice_comp_nuopc)" @@ -113,51 +109,27 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm - character(CL) :: cvalue - character(CS) :: stdname integer :: n - integer :: lsize ! local array size integer :: shrlogunit ! original log unit + character(CL) :: cvalue character(len=CL) :: logmsg logical :: isPresent, isSet character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMGet(vm, localpet=my_task, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + mastertask = (my_task == master_task) - mastertask = my_task == master_task - - !---------------------------------------------------------------------------- - ! determine instance information - !---------------------------------------------------------------------------- - - call get_component_instance(gcomp, inst_suffix, inst_index, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - !---------------------------------------------------------------------------- ! set logunit and set shr logging to my log file - !---------------------------------------------------------------------------- - call set_component_logging(gcomp, my_task==master_task, logunit, shrlogunit, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- - ! Initialize xice - !---------------------------------------------------------------------------- - - call dead_read_inparms('ice', inst_suffix, logunit, nxg, nyg) - - !-------------------------------- ! advertise import and export fields - !-------------------------------- - call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then @@ -201,87 +173,75 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') endif - if (nxg /= 0 .and. nyg /= 0) then - - call fld_list_add(fldsFrIce_num, fldsFrIce, trim(flds_scalar_name)) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_imask' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_ifrac' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_t' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_tref' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_qref' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_snowh' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_u10' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_avsdr' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_anidr' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_avsdf' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_anidf' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_taux' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_tauy' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_lat' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_sen' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_lwup' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_evap' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_swnet' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_melth' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_swpen' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_meltw' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_salt' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_taux' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_tauy' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_bcpho' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_bcphi' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_flxdst' ) - - call fld_list_add(fldsToIce_num, fldsToIce, trim(flds_scalar_name)) - call fld_list_add(fldsToIce_num, fldsToIce, 'So_dhdx' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'So_dhdy' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'So_t' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'So_s' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'So_u' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'So_v' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Fioo_q' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_z' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_u' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_v' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_ptem' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_shum' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_dens' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_tbot' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swvdr' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swndr' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swvdf' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swndf' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_lwdn' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_rain' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_snow' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_dstwet', ungridded_lbound=1, ungridded_ubound=4) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_dstdry', ungridded_lbound=1, ungridded_ubound=4) - - do n = 1,fldsFrIce_num - if(mastertask) write(logunit,*)'Advertising From Xice ',trim(fldsFrIce(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrIce(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo - - do n = 1,fldsToIce_num - if(mastertask) write(logunit,*)'Advertising To Xice ',trim(fldsToIce(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToIce(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - end do - end if - - - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - - !---------------------------------------------------------------------------- - ! Reset shr logging to original values - !---------------------------------------------------------------------------- + call fld_list_add(fldsFrIce_num, fldsFrIce, trim(flds_scalar_name)) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_imask' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_ifrac' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_t' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_tref' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_qref' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_snowh' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_u10' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_avsdr' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_anidr' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_avsdf' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_anidf' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_taux' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_tauy' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_lat' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_sen' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_lwup' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_evap' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_swnet' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_melth' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_swpen' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_meltw' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_salt' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_taux' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_tauy' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_bcpho' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_bcphi' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_flxdst' ) + + call fld_list_add(fldsToIce_num, fldsToIce, trim(flds_scalar_name)) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_dhdx' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_dhdy' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_t' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_s' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_u' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_v' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Fioo_q' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_z' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_u' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_v' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_ptem' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_shum' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_dens' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_tbot' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swvdr' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swndr' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swvdf' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swndf' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_lwdn' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_rain' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_snow' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_dstwet', ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_dstdry', ungridded_lbound=1, ungridded_ubound=4) + + do n = 1,fldsFrIce_num + if(mastertask) write(logunit,*)'Advertising From Xice ',trim(fldsFrIce(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrIce(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo - call shr_file_setLogUnit (shrlogunit) + do n = 1,fldsToIce_num + if(mastertask) write(logunit,*)'Advertising To Xice ',trim(fldsToIce(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToIce(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do end subroutine InitializeAdvertise @@ -293,37 +253,25 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - integer :: shrlogunit ! original log unit - integer :: n - character(ESMF_MAXSTR) :: cvalue ! config data + integer :: n, nxg, nyg + character(ESMF_MAXSTR) :: cvalue ! config data + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - !---------------------------------------------------------------------------- - ! Reset shr logging to my log file - !---------------------------------------------------------------------------- - - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logUnit) - - !-------------------------------- ! generate the mesh - !-------------------------------- - call NUOPC_CompAttributeGet(gcomp, name='mesh_ice', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! realize the actively coupled fields, now that a mesh is established ! 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 fld_list_realize( & state=ExportState, & fldlist=fldsFrIce, & @@ -344,32 +292,36 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- - ! Pack export state - !-------------------------------- + ! determine the mesh lats and lons (module variables) + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + nxg = numownedElements + nyg = 1 + + ! Pack export state call State_SetExport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - - call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & - flds_scalar_name, flds_scalar_num, rc) + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - - call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & - flds_scalar_name, flds_scalar_num, rc) + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! diagnostics - !-------------------------------- - if (dbug > 1) then call State_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) - end subroutine InitializeRealize !=============================================================================== @@ -380,46 +332,26 @@ subroutine ModelAdvance(gcomp, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Clock) :: clock type(ESMF_State) :: exportState - integer :: shrlogunit ! original log unit character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - call memcheck(subname, 3, mastertask) - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) + call memcheck(subname, 3, mastertask) - !-------------------------------- ! Pack export state - !-------------------------------- - - call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + call NUOPC_ModelGet(gcomp, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! diagnostics - !-------------------------------- - if (dbug > 1) then call State_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - if (my_task == master_task) then - call log_clock_advance(clock, 'XICE', logunit, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - endif endif - call shr_file_setLogUnit (shrlogunit) - - call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end subroutine ModelAdvance !=============================================================================== @@ -431,8 +363,6 @@ subroutine state_setexport(exportState, rc) ! local variables integer :: n, nf, nind - real(r8), pointer :: lat(:) - real(r8), pointer :: lon(:) integer :: spatialDim integer :: numOwnedElements real(R8), pointer :: ownedElemCoords(:) @@ -440,19 +370,6 @@ subroutine state_setexport(exportState, rc) rc = ESMF_SUCCESS - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(lon(numownedElements)) - allocate(lat(numownedElements)) - do n = 1,numownedElements - lon(n) = ownedElemCoords(2*n-1) - lat(n) = ownedElemCoords(2*n) - end do - ! Start from index 2 in order to skip the scalar field do nf = 2,fldsFrIce_num if (fldsFrIce(nf)%ungridded_ubound == 0) then @@ -467,9 +384,6 @@ subroutine state_setexport(exportState, rc) end if end do - deallocate(lon) - deallocate(lat) - end subroutine state_setexport !=============================================================================== diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml index 760d75e5c..116268af0 100755 --- a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml @@ -10,13 +10,13 @@ _CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",".."," sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * -from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.buildnml import parse_input from CIME.case import Case def buildnml(case, caseroot, compname): if compname != "xlnd": raise AttributeError - build_xcpl_nml(case, caseroot, compname) + # do nothing def _main_func(): caseroot = parse_input(sys.argv) diff --git a/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 index 0d08bf68b..5076d442f 100644 --- a/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 @@ -14,10 +14,8 @@ module lnd_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck - use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance - use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, memcheck, set_component_logging + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type implicit none @@ -43,15 +41,13 @@ module lnd_comp_nuopc integer :: glc_nec type(ESMF_Mesh) :: mesh - integer :: nxg ! global dim i-direction - integer :: nyg ! global dim j-direction - integer :: my_task ! my task in mpi communicator mpicom - 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 - integer ,parameter :: master_task=0 ! task number of master task + real(r8), pointer :: lat(:) ! mesh lats + real(r8), pointer :: lon(:) ! mesh lons + integer :: my_task ! my task in mpi communicator mpicom + integer :: logunit ! logging unit number + integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask - integer :: dbug = 1 + integer :: dbug = 0 character(*),parameter :: modName = "(xlnd_comp_nuopc)" character(*),parameter :: u_FILE_u = & __FILE__ @@ -117,9 +113,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm - character(CS) :: stdname integer :: n - integer :: lsize ! local array size integer :: shrlogunit ! original log unit character(CL) :: cvalue character(CL) :: logmsg @@ -128,40 +122,18 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMGet(vm, localpet=my_task, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - mastertask = (my_task == master_task) - !---------------------------------------------------------------------------- - ! determine instance information - !---------------------------------------------------------------------------- - - call get_component_instance(gcomp, inst_suffix, inst_index, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - !---------------------------------------------------------------------------- ! set logunit and set shr logging to my log file - !---------------------------------------------------------------------------- - call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- - ! Initialize xlnd - !---------------------------------------------------------------------------- - - call dead_read_inparms('lnd', inst_suffix, logunit, nxg, nyg) - - !-------------------------------- ! advertise import and export fields - !-------------------------------- - call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then @@ -205,92 +177,82 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') end if - if (nxg /= 0 .and. nyg /= 0) then - - call NUOPC_CompAttributeGet(gcomp, name='glc_nec', value=cvalue, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) glc_nec - call ESMF_LogWrite('glc_nec = '// trim(cvalue), ESMF_LOGMSG_INFO) - - call fld_list_add(fldsFrLnd_num, fldsFrlnd, trim(flds_scalar_name)) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_lfrin' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_t' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_tref' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_qref' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_avsdr' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_anidr' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_avsdf' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_anidf' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_snowh' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_u10' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_fv' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_ram1' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofsur' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofgwl' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofsub' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofi' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_irrig' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_taux' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_tauy' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_lat' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_sen' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_lwup' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_evap' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_swnet' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_flxdst' , ungridded_lbound=1, ungridded_ubound=4) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flgl_qice_elev', ungridded_lbound=1, ungridded_ubound=glc_nec+1) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_tsrf_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_topo_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) - - call fld_list_add(fldsToLnd_num, fldsToLnd, trim(flds_scalar_name)) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_z' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_topo' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_u' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_v' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_ptem' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_pbot' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_tbot' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_shum' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Flrr_volr' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Flrr_volrmch' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_lwdn' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_rainc' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_rainl' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_snowc' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_snowl' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swndr' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swvdr' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swndf' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swvdf' ) - call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) - call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) - call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_dstwet' , ungridded_lbound=1, ungridded_ubound=4) - call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_dstdry' , ungridded_lbound=1, ungridded_ubound=4) - call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_topo_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) - call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_ice_covered_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) - call fld_list_add(fldsToLnd_num, fldsTolnd, 'Flgg_hflx_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) - - do n = 1,fldsFrLnd_num - if (mastertask) write(logunit,*)'Advertising From Xlnd ',trim(fldsFrLnd(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrLnd(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo - - do n = 1,fldsToLnd_num - if(mastertask) write(logunit,*)'Advertising To Xlnd',trim(fldsToLnd(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToLnd(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo - - end if - - !---------------------------------------------------------------------------- - ! Reset shr logging to original values - !---------------------------------------------------------------------------- + call NUOPC_CompAttributeGet(gcomp, name='glc_nec', value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) glc_nec + call ESMF_LogWrite('glc_nec = '// trim(cvalue), ESMF_LOGMSG_INFO) + + call fld_list_add(fldsFrLnd_num, fldsFrlnd, trim(flds_scalar_name)) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_lfrin' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_t' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_tref' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_qref' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_avsdr' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_anidr' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_avsdf' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_anidf' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_snowh' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_u10' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_fv' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_ram1' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofsur' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofgwl' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofsub' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofi' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_irrig' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_taux' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_tauy' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_lat' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_sen' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_lwup' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_evap' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_swnet' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_flxdst' , ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flgl_qice_elev', ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_tsrf_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_topo_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + + call fld_list_add(fldsToLnd_num, fldsToLnd, trim(flds_scalar_name)) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_z' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_topo' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_u' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_v' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_ptem' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_pbot' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_tbot' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_shum' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Flrr_volr' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Flrr_volrmch' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_lwdn' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_rainc' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_rainl' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_snowc' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_snowl' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swndr' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swvdr' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swndf' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swvdf' ) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_dstwet' , ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_dstdry' , ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_topo_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_ice_covered_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsToLnd_num, fldsTolnd, 'Flgg_hflx_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + + do n = 1,fldsFrLnd_num + if (mastertask) write(logunit,*)'Advertising From Xlnd ',trim(fldsFrLnd(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrLnd(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo - call shr_file_setLogUnit (shrlogunit) + do n = 1,fldsToLnd_num + if(mastertask) write(logunit,*)'Advertising To Xlnd',trim(fldsToLnd(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToLnd(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo end subroutine InitializeAdvertise @@ -304,38 +266,25 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - integer :: shrlogunit ! original log unit - integer :: n - character(ESMF_MAXSTR) :: cvalue ! config data + integer :: n, nxg, nyg + character(ESMF_MAXSTR) :: cvalue ! config data + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - - !---------------------------------------------------------------------------- - ! Reset shr logging to my log file - !---------------------------------------------------------------------------- - - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logUnit) - !-------------------------------- ! generate the mesh - !-------------------------------- - call NUOPC_CompAttributeGet(gcomp, name='mesh_lnd', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! realize the actively coupled fields, now that a mesh is established ! 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 fld_list_realize( & state=ExportState, & fldlist=fldsFrLnd, & @@ -356,34 +305,36 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- - ! Pack export state - !-------------------------------- + ! determine the mesh lats and lons (module variables) + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + nxg = numownedElements + nyg = 1 + ! Pack export state call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - - call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & - flds_scalar_name, flds_scalar_num, rc) + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - - call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & - flds_scalar_name, flds_scalar_num, rc) + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! diagnostics - !-------------------------------- - if (dbug > 1) then call state_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) - - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end subroutine InitializeRealize !=============================================================================== @@ -394,46 +345,26 @@ subroutine ModelAdvance(gcomp, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Clock) :: clock type(ESMF_State) :: exportState - integer :: shrlogunit ! original log unit character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - call memcheck(subname, 3, mastertask) - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) + call memcheck(subname, 3, mastertask) - !-------------------------------- ! Pack export state - !-------------------------------- - - call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + call NUOPC_ModelGet(gcomp, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! diagnostics - !-------------------------------- - if (dbug > 1) then call state_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - if (mastertask) then - call log_clock_advance(clock, 'LND', logunit, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - endif endif - call shr_file_setLogUnit (shrlogunit) - - call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end subroutine ModelAdvance !=============================================================================== @@ -445,29 +376,11 @@ subroutine state_setexport(exportState, rc) integer, intent(out) :: rc ! local variables - integer :: n, nf, nind - real(r8), pointer :: lat(:) - real(r8), pointer :: lon(:) - integer :: spatialDim - integer :: numOwnedElements - real(R8), pointer :: ownedElemCoords(:) + integer :: nf, nind !-------------------------------------------------- rc = ESMF_SUCCESS - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(lon(numownedElements)) - allocate(lat(numownedElements)) - do n = 1,numownedElements - lon(n) = ownedElemCoords(2*n-1) - lat(n) = ownedElemCoords(2*n) - end do - ! Start from index 2 in order to Skip the scalar field here do nf = 2,fldsFrLnd_num if (fldsFrLnd(nf)%ungridded_ubound == 0) then @@ -482,9 +395,6 @@ subroutine state_setexport(exportState, rc) end if end do - deallocate(lon) - deallocate(lat) - end subroutine state_setexport !=============================================================================== diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml index c6f945376..acda3b213 100755 --- a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml @@ -10,13 +10,13 @@ _CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",".."," sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * -from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.buildnml import parse_input from CIME.case import Case def buildnml(case, caseroot, compname): if compname != "xocn": raise AttributeError - build_xcpl_nml(case, caseroot, compname) + # do nothing def _main_func(): caseroot = parse_input(sys.argv) diff --git a/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 index 5d6b04ec9..edac19b09 100644 --- a/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 @@ -14,10 +14,8 @@ module ocn_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck - use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance - use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, memcheck, set_component_logging + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type implicit none @@ -42,14 +40,11 @@ module ocn_comp_nuopc integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost type(ESMF_Mesh) :: mesh - integer :: nxg ! global dim i-direction - integer :: nyg ! global dim j-direction - integer :: my_task ! my task in mpi communicator mpicom - integer :: inst_index ! number of current instance (ie. 1) - character(len=16) :: inst_name ! fullname of current instance (ie. "ocn_0001") - character(len=16) :: inst_suffix = "" ! char string associated with instance (ie. "_0001" or "") - integer :: logunit ! logging unit number - integer ,parameter :: master_task=0 ! task number of master task + real(r8), pointer :: lat(:) ! mesh lats + real(r8), pointer :: lon(:) ! mesh lons + integer :: my_task ! my task in mpi communicator mpicom + integer :: logunit ! logging unit number + integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask integer :: dbug = 0 character(*),parameter :: modName = "(xocn_comp_nuopc)" @@ -106,7 +101,6 @@ subroutine SetServices(gcomp, rc) end subroutine SetServices !=============================================================================== - subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! input/output variables @@ -118,7 +112,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm integer :: n - integer :: lsize ! local array size integer :: shrlogunit ! original log unit character(CL) :: cvalue character(len=CL) :: logmsg @@ -135,17 +128,10 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return mastertask = (my_task == master_task) - ! determine instance information - call get_component_instance(gcomp, inst_suffix, inst_index, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - ! set logunit and set shr logging to my log file call set_component_logging(gcomp, my_task==master_task, logunit, shrlogunit, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - ! Initialize xocn - call dead_read_inparms('ocn', inst_suffix, logunit, nxg, nyg) - ! advertise import and export fields call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -190,55 +176,49 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') endif - if (nxg /= 0 .and. nyg /= 0) then - - call fld_list_add(fldsFrOcn_num, fldsFrOcn, trim(flds_scalar_name)) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_omask" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_t" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_s" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_u" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_v" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_dhdx" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_dhdy" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_bldepth" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "Fioo_q" ) - - call fld_list_add(fldsToOcn_num, fldsToOcn, trim(flds_scalar_name)) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_rain" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_snow" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_lwdn" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swndr" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swvdr" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swndf" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swvdf" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_taux" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_tauy" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_sen" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_lat" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_lwup" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_evap" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Fioi_salt" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_rofl" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_rofi" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Sa_pslv" ) - - do n = 1,fldsFrOcn_num - if(mastertask) write(logunit,*)'Advertising From Xocn ',trim(fldsFrOcn(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrOcn(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo - - do n = 1,fldsToOcn_num - if(mastertask) write(logunit,*)'Advertising To Xocn',trim(fldsToOcn(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToOcn(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo - end if + call fld_list_add(fldsFrOcn_num, fldsFrOcn, trim(flds_scalar_name)) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_omask" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_t" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_s" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_u" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_v" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_dhdx" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_dhdy" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_bldepth" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "Fioo_q" ) + + call fld_list_add(fldsToOcn_num, fldsToOcn, trim(flds_scalar_name)) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_rain" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_snow" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_lwdn" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swndr" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swvdr" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swndf" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swvdf" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_taux" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_tauy" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_sen" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_lat" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_lwup" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_evap" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Fioi_salt" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_rofl" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_rofi" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Sa_pslv" ) + + do n = 1,fldsFrOcn_num + if(mastertask) write(logunit,*)'Advertising From Xocn ',trim(fldsFrOcn(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrOcn(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo - ! Reset shr logging to original values - call shr_file_setLogUnit (shrlogunit) + do n = 1,fldsToOcn_num + if(mastertask) write(logunit,*)'Advertising To Xocn',trim(fldsToOcn(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToOcn(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo end subroutine InitializeAdvertise @@ -252,17 +232,16 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - integer :: shrlogunit ! original log unit + integer :: n, nxg, nyg character(ESMF_MAXSTR) :: cvalue ! config data + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize: xocn) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - ! Reset shr logging to my log file - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) - ! generate the mesh call NUOPC_CompAttributeGet(gcomp, name='mesh_ocn', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -292,6 +271,22 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + ! determine the mesh lats and lons (module variables) + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + nxg = numownedElements + nyg = 1 + ! Pack export state call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -306,8 +301,6 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) - end subroutine InitializeRealize !=============================================================================== @@ -318,9 +311,7 @@ subroutine ModelAdvance(gcomp, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Clock) :: clock type(ESMF_State) :: exportState - integer :: shrlogunit ! original log unit character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- @@ -328,11 +319,8 @@ subroutine ModelAdvance(gcomp, rc) call memcheck(subname, 3, mastertask) - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) - ! Pack export state - call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + call NUOPC_ModelGet(gcomp, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -343,42 +331,22 @@ subroutine ModelAdvance(gcomp, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) - end subroutine ModelAdvance !=============================================================================== subroutine state_setexport(exportState, rc) ! input/output variables - type(ESMF_State) , intent(inout) :: exportState - integer, intent(out) :: rc + type(ESMF_State) , intent(inout) :: exportState + integer , intent(out) :: rc ! local variables - integer :: n, nf, nind - real(r8), pointer :: lat(:) - real(r8), pointer :: lon(:) - integer :: spatialDim - integer :: numOwnedElements - real(R8), pointer :: ownedElemCoords(:) + integer :: nf, nind !-------------------------------------------------- rc = ESMF_SUCCESS - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(lon(numownedElements)) - allocate(lat(numownedElements)) - do n = 1,numownedElements - lon(n) = ownedElemCoords(2*n-1) - lat(n) = ownedElemCoords(2*n) - end do - - ! Start from index 2 in order to Skip the scalar field here + ! Start from index 2 in order to Skip the scalar field here do nf = 2,fldsFrOcn_num if (fldsFrOcn(nf)%ungridded_ubound == 0) then call field_setexport(exportState, trim(fldsFrOcn(nf)%stdname), lon, lat, nf=nf, rc=rc) @@ -392,13 +360,9 @@ subroutine state_setexport(exportState, rc) end if end do - deallocate(lon) - deallocate(lat) - end subroutine state_setexport !=============================================================================== - subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) use shr_const_mod , only : pi=>shr_const_pi diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml index 182cf39ef..688029a29 100755 --- a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml @@ -10,13 +10,13 @@ _CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",".."," sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * -from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.buildnml import parse_input from CIME.case import Case def buildnml(case, caseroot, compname): if compname != "xrof": raise AttributeError - build_xcpl_nml(case, caseroot, compname) + # do nothing def _main_func(): caseroot = parse_input(sys.argv) diff --git a/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 index d62bc458e..231170c08 100644 --- a/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 @@ -5,20 +5,18 @@ module rof_comp_nuopc !---------------------------------------------------------------------------- use ESMF - 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 - use shr_sys_mod , only : shr_sys_abort - use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck - use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance - use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock - use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, memcheck, set_component_logging + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type implicit none private ! except @@ -42,16 +40,14 @@ module rof_comp_nuopc integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost type(ESMF_Mesh) :: mesh - integer :: nxg ! global dim i-direction - integer :: nyg ! global dim j-direction - integer :: my_task ! my task in mpi - 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 - integer ,parameter :: master_task=0 ! task number of master task + real(r8), pointer :: lat(:) ! mesh lats + real(r8), pointer :: lon(:) ! mesh lons + integer :: my_task ! my task in mpi communicator mpicom + integer :: logunit ! logging unit number + integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask integer :: dbug = 0 - character(*),parameter :: modName = "(xrof_comp_nuopc)" + character(*),parameter :: modName = "(xrof_comp_nuopc)" character(*),parameter :: u_FILE_u = & __FILE__ @@ -133,21 +129,12 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return mastertask = (my_task == master_task) - ! determine instance information - call get_component_instance(gcomp, inst_suffix, inst_index, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! set logunit and set shr logging to my log file call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! Initialize xrof - call dead_read_inparms('rof', inst_suffix, logunit, nxg, nyg) - !-------------------------------- ! advertise import and export fields - !-------------------------------- - call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then @@ -191,45 +178,34 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') endif - if (nxg /= 0 .and. nyg /= 0) then - - call fld_list_add(fldsFrRof_num, fldsFrRof, trim(flds_scalar_name)) - call fld_list_add(fldsFrRof_num, fldsFrRof, 'Forr_rofl') - call fld_list_add(fldsFrRof_num, fldsFrRof, 'Forr_rofi') - call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_flood') - call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_volr') - call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_volrmch') - - call fld_list_add(fldsToRof_num, fldsToRof, trim(flds_scalar_name)) - call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofsur') - call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofgwl') - call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofsub') - call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofdto') - call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofi') - call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_irrig') - - do n = 1,fldsFrRof_num - if(mastertask) write(logunit,*)'Advertising From Xrof ',trim(fldsFrRof(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrRof(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo - - do n = 1,fldsToRof_num - if(mastertask) write(logunit,*)'Advertising To Xrof',trim(fldsToRof(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToRof(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo - end if - - if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - - !---------------------------------------------------------------------------- - ! Reset shr logging to original values - !---------------------------------------------------------------------------- + call fld_list_add(fldsFrRof_num, fldsFrRof, trim(flds_scalar_name)) + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Forr_rofl') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Forr_rofi') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_flood') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_volr') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_volrmch') + + call fld_list_add(fldsToRof_num, fldsToRof, trim(flds_scalar_name)) + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofsur') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofgwl') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofsub') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofdto') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofi') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_irrig') + + do n = 1,fldsFrRof_num + if(mastertask) write(logunit,*)'Advertising From Xrof ',trim(fldsFrRof(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrRof(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo - call shr_file_setLogUnit (shrlogunit) + do n = 1,fldsToRof_num + if(mastertask) write(logunit,*)'Advertising To Xrof',trim(fldsToRof(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToRof(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo end subroutine InitializeAdvertise @@ -243,18 +219,16 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - integer :: shrlogunit ! original log unit + integer :: n, nxg, nyg character(ESMF_MAXSTR) :: cvalue ! config data + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - ! Reset shr logging to my log file - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logUnit) - - ! generate the mesh call NUOPC_CompAttributeGet(gcomp, name='mesh_rof', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -284,10 +258,23 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- - ! Pack export state - !-------------------------------- + ! determine the mesh lats and lons (module variables) + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + nxg = numownedElements + nyg = 1 + + ! Pack export state call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) @@ -295,17 +282,12 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! diagnostics - !-------------------------------- - if (dbug > 1) then call State_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) - end subroutine InitializeRealize !=============================================================================== @@ -316,24 +298,16 @@ subroutine ModelAdvance(gcomp, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Clock) :: clock - type(ESMF_State) :: exportState - integer :: shrlogunit ! original log unit + type(ESMF_State) :: exportState character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - if (dbug > 5) then - call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - end if call memcheck(subname, 3, mastertask) - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) - ! Pack export state - call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + call NUOPC_ModelGet(gcomp, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call State_SetExport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -342,18 +316,8 @@ subroutine ModelAdvance(gcomp, rc) if (dbug > 1) then call State_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - if (mastertask) then - call log_clock_advance(clock, 'XROF', logunit, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - endif endif - call shr_file_setLogUnit (shrlogunit) - - if (dbug > 5) then - call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - end if - end subroutine ModelAdvance !=============================================================================== @@ -364,29 +328,11 @@ subroutine state_setexport(exportState, rc) integer, intent(out) :: rc ! local variables - integer :: n, nf, nind - real(r8), pointer :: lat(:) - real(r8), pointer :: lon(:) - integer :: spatialDim - integer :: numOwnedElements - real(R8), pointer :: ownedElemCoords(:) + integer :: nf, nind !-------------------------------------------------- rc = ESMF_SUCCESS - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(lon(numownedElements)) - allocate(lat(numownedElements)) - do n = 1,numownedElements - lon(n) = ownedElemCoords(2*n-1) - lat(n) = ownedElemCoords(2*n) - end do - ! Start from index 2 in order to skip the scalar field do nf = 2,fldsFrRof_num if (fldsFrRof(nf)%ungridded_ubound == 0) then @@ -401,9 +347,6 @@ subroutine state_setexport(exportState, rc) end if end do - deallocate(lon) - deallocate(lat) - end subroutine state_setexport !=============================================================================== diff --git a/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 b/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 index ee3ca6b68..a748c67ed 100644 --- a/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 +++ b/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 @@ -15,7 +15,6 @@ module dead_nuopc_mod implicit none private - public :: dead_read_inparms public :: ModelInitPhase public :: ModelSetRunClock public :: fld_list_add @@ -38,64 +37,6 @@ module dead_nuopc_mod contains !=============================================================================== - subroutine dead_read_inparms(model, inst_suffix, logunit, nxg, nyg) - - ! input/output variables - character(len=*) , intent(in) :: model - character(len=*) , intent(in) :: inst_suffix ! char string associated with instance - integer , intent(in) :: logunit ! logging unit number - integer , intent(out) :: nxg ! global dim i-direction - integer , intent(out) :: nyg ! global dim j-direction - - ! local variables - type(ESMF_VM) :: vm - character(CL) :: fileName ! generic file name - integer :: nunit ! unit number - integer :: unitn ! Unit for namelist file - integer :: tmp(2) ! array for broadcast - integer :: localPet ! mpi id of current task in current context - integer :: rc ! return code - character(*), parameter :: F00 = "('(dead_read_inparms) ',8a)" - character(*), parameter :: F01 = "('(dead_read_inparms) ',a,a,4i8)" - character(*), parameter :: F03 = "('(dead_read_inparms) ',a,a,i8,a)" - character(*), parameter :: subName = "(dead_read_inpamrs) " - !------------------------------------------------------------------------------- - - ! read the input parms (used to configure model) - call ESMF_VMGetCurrent(vm, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMGet(vm, localPet=localPet, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - nxg = -9999 - nyg = -9999 - - if (localPet==0) then - open(newunit=unitn, file='x'//model//'_in'//trim(inst_suffix), status='old' ) - read(unitn,*) nxg - read(unitn,*) nyg - close (unitn) - endif - - tmp(1) = nxg - tmp(2) = nyg - call ESMF_VMBroadcast(vm, tmp, 3, 0, rc=rc) - nxg = tmp(1) - nyg = tmp(2) - - if (localPet==0) then - write(logunit,*)' Read in X'//model//' input from file= x'//model//'_in' - write(logunit,F00) model - write(logunit,F00) model,' Model : ',model - write(logunit,F01) model,' NGX : ',nxg - write(logunit,F01) model,' NGY : ',nyg - write(logunit,F00) model,' inst_suffix : ',trim(inst_suffix) - write(logunit,F00) model - end if - - end subroutine dead_read_inparms - - !=============================================================================== subroutine fld_list_add(num, fldlist, stdname, ungridded_lbound, ungridded_ubound) ! input/output variables diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml index b7b8576ba..7c3f264d8 100755 --- a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml @@ -10,13 +10,13 @@ _CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",".."," sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * -from CIME.buildnml import build_xcpl_nml, parse_input +from CIME.buildnml import parse_input from CIME.case import Case def buildnml(case, caseroot, compname): if compname != "xwav": raise AttributeError - build_xcpl_nml(case, caseroot, compname) + # do nothing def _main_func(): caseroot = parse_input(sys.argv) diff --git a/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 index 2bb08fc29..a06fab7b3 100644 --- a/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 @@ -5,20 +5,18 @@ module wav_comp_nuopc !---------------------------------------------------------------------------- use ESMF - 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 - use shr_sys_mod , only : shr_sys_abort - use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck - use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance - use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock - use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, memcheck, set_component_logging + use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type implicit none private ! except @@ -42,14 +40,13 @@ module wav_comp_nuopc integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost type(ESMF_Mesh) :: mesh - integer :: nxg ! global dim i-direction - integer :: nyg ! global dim j-direction - integer :: my_task ! my task in mpi communicator mpicom - 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 + real(r8), pointer :: lat(:) ! mesh lats + real(r8), pointer :: lon(:) ! mesh lons + integer :: my_task ! my task in mpi communicator mpicom + integer :: logunit ! logging unit number + integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask - integer :: dbug = 1 + integer :: dbug = 0 character(*),parameter :: modName = "(xwav_comp_nuopc)" character(*),parameter :: u_FILE_u = & __FILE__ @@ -114,9 +111,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm - character(CS) :: stdname integer :: n - integer :: lsize ! local array size integer :: shrlogunit ! original log unit character(CL) :: cvalue character(len=CL) :: logmsg @@ -125,28 +120,17 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMGet(vm, localpet=my_task, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - - mastertask = (my_task == 0) - - ! determine instance information - call get_component_instance(gcomp, inst_suffix, inst_index, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + mastertask = (my_task == master_task) ! set logunit and set shr logging to my log file call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - ! Initialize xwav - call dead_read_inparms('wav', inst_suffix, logunit, nxg, nyg) - ! advertise import and export fields call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -191,44 +175,35 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') endif - if (nxg /= 0 .and. nyg /= 0) then - - call fld_list_add(fldsFrWav_num, fldsFrWav, trim(flds_scalar_name)) - call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_lamult' ) - call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_ustokes' ) - call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_vstokes' ) - call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_hstokes' ) - - call fld_list_add(fldsToWav_num, fldsToWav, trim(flds_scalar_name)) - call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_u' ) - call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_v' ) - call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_tbot' ) - call fld_list_add(fldsToWav_num, fldsToWav, 'Si_ifrac' ) - call fld_list_add(fldsToWav_num, fldsToWav, 'So_t' ) - call fld_list_add(fldsToWav_num, fldsToWav, 'So_u' ) - call fld_list_add(fldsToWav_num, fldsToWav, 'So_v' ) - call fld_list_add(fldsToWav_num, fldsToWav, 'So_bldepth' ) - - do n = 1,fldsFrWav_num - if (mastertask) write(logunit,*)'Advertising From Xwav ',trim(fldsFrWav(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrWav(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo - - do n = 1,fldsToWav_num - if(mastertask) write(logunit,*)'Advertising To Xwav ',trim(fldsToWav(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToWav(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo - end if - - call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + call fld_list_add(fldsFrWav_num, fldsFrWav, trim(flds_scalar_name)) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_lamult' ) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_ustokes' ) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_vstokes' ) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_hstokes' ) + + call fld_list_add(fldsToWav_num, fldsToWav, trim(flds_scalar_name)) + call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_u' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_v' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_tbot' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'Si_ifrac' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_t' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_u' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_v' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_bldepth' ) + + do n = 1,fldsFrWav_num + if (mastertask) write(logunit,*)'Advertising From Xwav ',trim(fldsFrWav(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrWav(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo - ! Reset shr logging to original values - call shr_file_setLogUnit (shrlogunit) + do n = 1,fldsToWav_num + if(mastertask) write(logunit,*)'Advertising To Xwav ',trim(fldsToWav(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToWav(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo end subroutine InitializeAdvertise @@ -242,17 +217,16 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - integer :: shrlogunit ! original log unit + integer :: n, nxg, nyg character(ESMF_MAXSTR) :: cvalue ! config data + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - ! Reset shr logging to my log file - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) - ! generate the mesh call NUOPC_CompAttributeGet(gcomp, name='mesh_wav', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -282,6 +256,22 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + ! determine the mesh lats and lons (module variables) + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + nxg = numownedElements + nyg = 1 + ! Pack export state call State_SetExport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -296,8 +286,6 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) - end subroutine InitializeRealize !=============================================================================== @@ -308,9 +296,7 @@ subroutine ModelAdvance(gcomp, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Clock) :: clock - type(ESMF_State) :: exportState - integer :: shrlogunit ! original log unit + type(ESMF_State) :: exportState character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- @@ -318,11 +304,8 @@ subroutine ModelAdvance(gcomp, rc) call memcheck(subname, 3, mastertask) - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) - ! Pack export state - call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + call NUOPC_ModelGet(gcomp, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -331,14 +314,8 @@ subroutine ModelAdvance(gcomp, rc) if (dbug > 1) then call State_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - if ( mastertask) then - call log_clock_advance(clock, 'XWAV', logunit, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - endif endif - call shr_file_setLogUnit (shrlogunit) - end subroutine ModelAdvance !=============================================================================== @@ -349,30 +326,12 @@ subroutine state_setexport(exportState, rc) integer , intent(out) :: rc ! local variables - integer :: nfstart, ubound - integer :: n, nf, nind - real(r8), pointer :: lat(:) - real(r8), pointer :: lon(:) - integer :: spatialDim - integer :: numOwnedElements - real(R8), pointer :: ownedElemCoords(:) + integer :: nfstart, ubound + integer :: nf, nind !-------------------------------------------------- rc = ESMF_SUCCESS - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(lon(numownedElements)) - allocate(lat(numownedElements)) - do n = 1,numownedElements - lon(n) = ownedElemCoords(2*n-1) - lat(n) = ownedElemCoords(2*n) - end do - nfstart = 0 ! for fields that have ubound > 0 do nf = 2,fldsFrWav_num ! Start from index 2 in order to skip the scalar field ubound = fldsFrWav(nf)%ungridded_ubound @@ -389,9 +348,6 @@ subroutine state_setexport(exportState, rc) end if end do - deallocate(lon) - deallocate(lat) - end subroutine state_setexport !=============================================================================== From 95b3dd42825014a54705b9cb2bc0403a893e6277 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Thu, 6 Aug 2020 16:39:22 -0600 Subject: [PATCH 07/24] refactored X compset again to fix restart test --- .../xatm/cime_config/buildnml | 4 +- .../xatm/src/atm_comp_nuopc.F90 | 236 +++++++------ .../xglc/cime_config/buildnml | 4 +- .../xglc/src/glc_comp_nuopc.F90 | 170 +++++++--- .../xice/cime_config/buildnml | 4 +- .../xice/src/ice_comp_nuopc.F90 | 310 +++++++++++------- .../xlnd/cime_config/buildnml | 4 +- .../xlnd/src/lnd_comp_nuopc.F90 | 308 +++++++++++------ .../xocn/cime_config/buildnml | 4 +- .../xocn/src/ocn_comp_nuopc.F90 | 184 ++++++----- .../xrof/cime_config/buildnml | 4 +- .../xrof/src/rof_comp_nuopc.F90 | 193 +++++++---- .../xshare/dead_nuopc_mod.F90 | 59 ++++ .../xwav/cime_config/buildnml | 4 +- .../xwav/src/wav_comp_nuopc.F90 | 186 +++++++---- 15 files changed, 1080 insertions(+), 594 deletions(-) diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml index 5b580324e..50a814c79 100755 --- a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml @@ -10,13 +10,13 @@ _CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",".."," sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * -from CIME.buildnml import parse_input +from CIME.buildnml import build_xcpl_nml, parse_input from CIME.case import Case def buildnml(case, caseroot, compname): if compname != "xatm": raise AttributeError - # Do nothing + build_xcpl_nml(case, caseroot, compname) def _main_func(): caseroot = parse_input(sys.argv) diff --git a/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 index b8a4d9e97..7386883d6 100644 --- a/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 @@ -14,8 +14,10 @@ module atm_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, memcheck, set_component_logging - use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type implicit none @@ -40,9 +42,11 @@ module atm_comp_nuopc integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost type(ESMF_Mesh) :: mesh - real(r8), pointer :: lat(:) ! mesh lats - real(r8), pointer :: lon(:) ! mesh lons + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction integer :: my_task ! my task in mpi communicator mpicom + integer :: inst_index ! number of current instance (ie. 1) + character(len=5) :: inst_suffix ! char string associated with instance (ie. "_0001" or "") integer :: logunit ! logging unit number logical :: mastertask integer :: dbug = 0 @@ -110,7 +114,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm + character(CS) :: stdname integer :: n + integer :: lsize ! local array size integer :: shrlogunit ! original log unit character(CL) :: cvalue character(len=CL) :: logmsg @@ -122,14 +128,23 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMGet(vm, localpet=my_task, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + mastertask = (my_task==0) + ! determine instance information + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! set logunit and set shr logging to my log file call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! Initialize xatm + call dead_read_inparms('atm', inst_suffix, logunit, nxg, nyg) + ! advertise import and export fields call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -185,71 +200,77 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxNextSwCday') endif - call fld_list_add(fldsFrAtm_num, fldsFrAtm, trim(flds_scalar_name)) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_topo' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_z' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_u' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_v' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_tbot' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_ptem' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_shum' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_pbot' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_dens' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_pslv' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainc' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainl' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowc' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowl' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_lwdn' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swndr' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swvdr' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swndf' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swvdf' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swnet' ) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_dstwet', ungridded_lbound=1, ungridded_ubound=4) - call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_dstdry', ungridded_lbound=1, ungridded_ubound=4) - - call fld_list_add(fldsToAtm_num, fldsToAtm, trim(flds_scalar_name)) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_anidr' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_avsdf' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_anidf' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_avsdr' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_lfrac' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Si_ifrac' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_ofrac' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_tref' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_qref' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_t' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_t' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_fv' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_ram1' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_snowh' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Si_snowh' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_ssq' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_re' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_u10' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_taux' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_tauy' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_lat' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_sen' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_lwup' ) - call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_evap' ) - - do n = 1,fldsFrAtm_num - if(mastertask) write(logunit,*)'Advertising From Xatm ',trim(fldsFrAtm(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrAtm(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - end do + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrAtm_num, fldsFrAtm, trim(flds_scalar_name)) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_topo' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_z' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_u' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_v' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_tbot' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_ptem' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_shum' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_pbot' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_dens' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Sa_pslv' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainc' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_rainl' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowc' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_snowl' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_lwdn' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swndr' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swvdr' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swndf' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swvdf' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_swnet' ) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_dstwet', ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_dstdry', ungridded_lbound=1, ungridded_ubound=4) + + call fld_list_add(fldsToAtm_num, fldsToAtm, trim(flds_scalar_name)) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_anidr' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_avsdf' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_anidf' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_avsdr' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_lfrac' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Si_ifrac' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_ofrac' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_tref' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_qref' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_t' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_t' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_fv' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_ram1' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sl_snowh' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Si_snowh' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_ssq' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'So_re' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Sx_u10' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_taux' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_tauy' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_lat' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_sen' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_lwup' ) + call fld_list_add(fldsToAtm_num, fldsToAtm, 'Faxx_evap' ) + + do n = 1,fldsFrAtm_num + if(mastertask) write(logunit,*)'Advertising From Xatm ',trim(fldsFrAtm(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrAtm(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do - do n = 1,fldsToAtm_num - if(mastertask) write(logunit,*)'Advertising To Xatm',trim(fldsToAtm(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToAtm(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo + do n = 1,fldsToAtm_num + if(mastertask) write(logunit,*)'Advertising To Xatm',trim(fldsToAtm(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToAtm(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + ! Reset shr logging to original values + call shr_file_setLogUnit (shrlogunit) end subroutine InitializeAdvertise @@ -265,20 +286,22 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_Time) :: nextTime real(r8) :: nextsw_cday - integer :: n, nxg, nyg - integer :: shrlogunit ! original log unit - character(ESMF_MAXSTR) :: cvalue ! config data - integer :: spatialDim - integer :: numOwnedElements - real(R8), pointer :: ownedElemCoords(:) + integer :: n + integer :: shrlogunit ! original log unit + character(ESMF_MAXSTR) :: cvalue ! config data character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize: xatm) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS + ! Reset shr logging to my log file + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logUnit) + ! generate the mesh call NUOPC_CompAttributeGet(gcomp, name='mesh_atm', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -305,27 +328,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - ! determine the mes lats and lons (module variables) - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(lon(numownedElements)) - allocate(lat(numownedElements)) - do n = 1,numownedElements - lon(n) = ownedElemCoords(2*n-1) - lat(n) = ownedElemCoords(2*n) - end do - nxg = numownedElements - nyg = 1 - ! Pack export state call state_setexport(exportState, rc=rc) - call State_SetScalar(dble(nxg), flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call State_SetScalar(dble(nyg), flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return ! Set time of next radiation computation @@ -343,6 +350,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif + call shr_file_setLogUnit (shrlogunit) + end subroutine InitializeRealize !=============================================================================== @@ -362,23 +371,43 @@ subroutine ModelAdvance(gcomp, rc) rc = ESMF_SUCCESS + if (dbug > 1) then + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + end if call memcheck(subname, 3, mastertask) + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- ! Pack export state + !-------------------------------- + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + call 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 + !-------------------------------- ! diagnostics + !-------------------------------- + if (dbug > 1) then call state_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + if (mastertask) then + call log_clock_advance(clock, 'XATM', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif endif + call shr_file_setLogUnit (shrlogunit) + end subroutine ModelAdvance !=============================================================================== @@ -389,11 +418,29 @@ subroutine state_setexport(exportState, rc) integer, intent(out) :: rc ! local variables - integer :: nf, nind + integer :: n, nf, nind + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) !-------------------------------------------------- rc = ESMF_SUCCESS + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + ! Start from index 2 in order to Skip the scalar field here do nf = 2,fldsFrAtm_num if (fldsFrAtm(nf)%ungridded_ubound == 0) then @@ -408,6 +455,9 @@ subroutine state_setexport(exportState, rc) end if end do + deallocate(lon) + deallocate(lat) + end subroutine state_setexport !=============================================================================== diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml index 488ba2b07..64077a469 100755 --- a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml @@ -10,13 +10,13 @@ _CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",".."," sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * -from CIME.buildnml import parse_input +from CIME.buildnml import build_xcpl_nml, parse_input from CIME.case import Case def buildnml(case, caseroot, compname): if compname != "xglc": raise AttributeError - # do nothing + build_xcpl_nml(case, caseroot, compname) def _main_func(): caseroot = parse_input(sys.argv) diff --git a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 index 225f745fc..8bf8b8b6e 100644 --- a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 @@ -14,8 +14,10 @@ module glc_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, memcheck, set_component_logging - use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type implicit none @@ -39,11 +41,13 @@ module glc_comp_nuopc integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost type(ESMF_Mesh) :: mesh - real(r8), pointer :: lat(:) ! mesh lats - real(r8), pointer :: lon(:) ! mesh lons - integer :: my_task ! my task in mpi communicator mpicom - integer :: logunit ! logging unit number - integer ,parameter :: master_task=0 ! task number of master task + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + 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 + integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask integer :: dbug = 0 character(*),parameter :: modName = "(xglc_comp_nuopc)" @@ -110,7 +114,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm + character(CS) :: stdname integer :: n + integer :: lsize ! local array size integer :: shrlogunit ! original log unit character(CL) :: cvalue character(len=CL) :: logmsg @@ -122,14 +128,23 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMGet(vm, localpet=my_task, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + mastertask = (my_task == master_task) + ! determine instance information + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + ! set logunit and set shr logging to my log file call set_component_logging(gcomp, my_task==master_task, logunit, shrlogunit, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + ! Initialize xglc + call dead_read_inparms('glc', inst_suffix, logunit, nxg, nyg) + ! advertise import and export fields call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -174,30 +189,36 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') endif - call fld_list_add(fldsFrGlc_num, fldsFrGlc, trim(flds_scalar_name)) - call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_icemask' ) - call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_icemask_coupled_fluxes' ) - call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_ice_covered' ) - call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_topo' ) - call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Flgg_hflx' ) - - call fld_list_add(fldsToGlc_num, fldsToGlc, trim(flds_scalar_name)) - call fld_list_add(fldsToGlc_num, fldsToGlc, 'Sl_tsrf') - call fld_list_add(fldsToGlc_num, fldsToGlc, 'Flgl_qice') - - do n = 1,fldsFrGlc_num - if (mastertask) write(logunit,*)'Advertising From Xglc ',trim(fldsFrGlc(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrglc(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo + if (nxg /= 0 .and. nyg /= 0) then - do n = 1,fldsToGlc_num - if (mastertask) write(logunit,*)'Advertising To Xglc ',trim(fldsToGlc(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToglc(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo + call fld_list_add(fldsFrGlc_num, fldsFrGlc, trim(flds_scalar_name)) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_icemask' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_icemask_coupled_fluxes' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_ice_covered' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Sg_topo' ) + call fld_list_add(fldsFrGlc_num, fldsFrGlc, 'Flgg_hflx' ) + + call fld_list_add(fldsToGlc_num, fldsToGlc, trim(flds_scalar_name)) + call fld_list_add(fldsToGlc_num, fldsToGlc, 'Sl_tsrf') + call fld_list_add(fldsToGlc_num, fldsToGlc, 'Flgl_qice') + + do n = 1,fldsFrGlc_num + if (mastertask) write(logunit,*)'Advertising From Xglc ',trim(fldsFrGlc(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrglc(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + do n = 1,fldsToGlc_num + if (mastertask) write(logunit,*)'Advertising To Xglc ',trim(fldsToGlc(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToglc(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + ! Reset shr logging to original values + call shr_file_setLogUnit (shrlogunit) end subroutine InitializeAdvertise @@ -212,25 +233,37 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - integer :: n, nxg, nyg + integer :: n + integer :: shrlogunit ! original log unit character(ESMF_MAXSTR) :: cvalue ! config data - integer :: spatialDim - integer :: numOwnedElements - real(R8), pointer :: ownedElemCoords(:) character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- ! generate the mesh + !-------------------------------- + call NUOPC_CompAttributeGet(gcomp, name='mesh_glc', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + !-------------------------------- ! realize the actively coupled fields, now that a mesh is established ! 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 fld_list_realize( & state=ExportState, & fldList=fldsFrGlc, & @@ -251,39 +284,38 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - ! determine the mes lats and lons (module variables) - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(lon(numownedElements)) - allocate(lat(numownedElements)) - do n = 1,numownedElements - lon(n) = ownedElemCoords(2*n-1) - lat(n) = ownedElemCoords(2*n) - end do - nxg = numownedElements - nyg = 1 - + !-------------------------------- ! Pack export state + ! Copy from d2x to exportState + ! Set the coupling scalars + !-------------------------------- + call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call state_setscalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) + + call state_setscalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call state_setscalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) + + call state_setscalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + !-------------------------------- ! diagnostics + !-------------------------------- + if (dbug > 1) then call state_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif + call shr_file_setLogUnit (shrlogunit) + end subroutine InitializeRealize !=============================================================================== + subroutine ModelAdvance(gcomp, rc) ! input/output variables @@ -294,6 +326,7 @@ subroutine ModelAdvance(gcomp, rc) type(ESMF_Clock) :: clock type(ESMF_State) :: exportState integer :: n + integer :: shrlogunit ! original log unit real(r8), pointer :: dataptr(:) character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- @@ -301,9 +334,16 @@ subroutine ModelAdvance(gcomp, rc) rc = ESMF_SUCCESS call memcheck(subname, 3, mastertask) + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- ! Pack export state + !-------------------------------- + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -313,6 +353,8 @@ subroutine ModelAdvance(gcomp, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif + call shr_file_setLogUnit (shrlogunit) + end subroutine ModelAdvance !=============================================================================== @@ -323,11 +365,29 @@ subroutine state_setexport(exportState, rc) integer, intent(out) :: rc ! local variables - integer :: nf, nind + integer :: n, nf, nind + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) !-------------------------------------------------- rc = ESMF_SUCCESS + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + ! Start from index 2 in order to skip the scalar field do nf = 2,fldsFrGlc_num if (fldsFrGlc(nf)%ungridded_ubound == 0) then @@ -342,9 +402,13 @@ subroutine state_setexport(exportState, rc) end if end do + deallocate(lon) + deallocate(lat) + end subroutine state_setexport !=============================================================================== + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) use shr_const_mod , only : pi=>shr_const_pi diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml index 62967b52e..e023dc7c6 100755 --- a/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml @@ -10,13 +10,13 @@ _CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",".."," sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * -from CIME.buildnml import parse_input +from CIME.buildnml import build_xcpl_nml, parse_input from CIME.case import Case def buildnml(case, caseroot, compname): if compname != "xice": raise AttributeError - # do nothing + build_xcpl_nml(case, caseroot, compname) def _main_func(): caseroot = parse_input(sys.argv) diff --git a/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 index f5da13a51..d531da74a 100644 --- a/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 @@ -5,18 +5,20 @@ module ice_comp_nuopc !---------------------------------------------------------------------------- use ESMF - 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 - use shr_sys_mod , only : shr_sys_abort - use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, memcheck, set_component_logging - use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock - use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type implicit none private ! except @@ -39,11 +41,13 @@ module ice_comp_nuopc integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost type(ESMF_Mesh) :: mesh - real(r8), pointer :: lat(:) ! mesh lats - real(r8), pointer :: lon(:) ! mesh lons - integer :: my_task ! my task in mpi communicator mpicom - integer :: logunit ! logging unit number - integer ,parameter :: master_task=0 ! task number of master task + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + 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 + integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask integer :: dbug = 0 character(*),parameter :: modName = "(xice_comp_nuopc)" @@ -109,27 +113,51 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm + character(CL) :: cvalue + character(CS) :: stdname integer :: n + integer :: lsize ! local array size integer :: shrlogunit ! original log unit - character(CL) :: cvalue character(len=CL) :: logmsg logical :: isPresent, isSet character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMGet(vm, localpet=my_task, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - mastertask = (my_task == master_task) + mastertask = my_task == master_task + + !---------------------------------------------------------------------------- + ! determine instance information + !---------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + call set_component_logging(gcomp, my_task==master_task, logunit, shrlogunit, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + !---------------------------------------------------------------------------- + ! Initialize xice + !---------------------------------------------------------------------------- + + call dead_read_inparms('ice', inst_suffix, logunit, nxg, nyg) + + !-------------------------------- ! advertise import and export fields + !-------------------------------- + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then @@ -173,75 +201,87 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') endif - call fld_list_add(fldsFrIce_num, fldsFrIce, trim(flds_scalar_name)) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_imask' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_ifrac' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_t' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_tref' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_qref' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_snowh' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_u10' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_avsdr' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_anidr' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_avsdf' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_anidf' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_taux' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_tauy' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_lat' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_sen' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_lwup' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_evap' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_swnet' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_melth' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_swpen' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_meltw' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_salt' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_taux' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_tauy' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_bcpho' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_bcphi' ) - call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_flxdst' ) - - call fld_list_add(fldsToIce_num, fldsToIce, trim(flds_scalar_name)) - call fld_list_add(fldsToIce_num, fldsToIce, 'So_dhdx' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'So_dhdy' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'So_t' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'So_s' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'So_u' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'So_v' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Fioo_q' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_z' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_u' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_v' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_ptem' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_shum' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_dens' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_tbot' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swvdr' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swndr' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swvdf' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swndf' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_lwdn' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_rain' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_snow' ) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_dstwet', ungridded_lbound=1, ungridded_ubound=4) - call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_dstdry', ungridded_lbound=1, ungridded_ubound=4) - - do n = 1,fldsFrIce_num - if(mastertask) write(logunit,*)'Advertising From Xice ',trim(fldsFrIce(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrIce(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrIce_num, fldsFrIce, trim(flds_scalar_name)) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_imask' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_ifrac' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_t' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_tref' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_qref' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_snowh' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_u10' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_avsdr' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_anidr' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_avsdf' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Si_anidf' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_taux' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_tauy' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_lat' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_sen' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_lwup' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_evap' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Faii_swnet' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_melth' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_swpen' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_meltw' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_salt' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_taux' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_tauy' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_bcpho' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_bcphi' ) + call fld_list_add(fldsFrIce_num, fldsFrIce, 'Fioi_flxdst' ) + + call fld_list_add(fldsToIce_num, fldsToIce, trim(flds_scalar_name)) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_dhdx' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_dhdy' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_t' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_s' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_u' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'So_v' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Fioo_q' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_z' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_u' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_v' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_ptem' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_shum' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_dens' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Sa_tbot' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swvdr' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swndr' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swvdf' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_swndf' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_lwdn' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_rain' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_snow' ) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_dstwet', ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsToIce_num, fldsToIce, 'Faxa_dstdry', ungridded_lbound=1, ungridded_ubound=4) + + do n = 1,fldsFrIce_num + if(mastertask) write(logunit,*)'Advertising From Xice ',trim(fldsFrIce(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrIce(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo - do n = 1,fldsToIce_num - if(mastertask) write(logunit,*)'Advertising To Xice ',trim(fldsToIce(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToIce(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - end do + do n = 1,fldsToIce_num + if(mastertask) write(logunit,*)'Advertising To Xice ',trim(fldsToIce(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToIce(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) end subroutine InitializeAdvertise @@ -253,25 +293,37 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - integer :: n, nxg, nyg - character(ESMF_MAXSTR) :: cvalue ! config data - integer :: spatialDim - integer :: numOwnedElements - real(R8), pointer :: ownedElemCoords(:) + integer :: shrlogunit ! original log unit + integer :: n + character(ESMF_MAXSTR) :: cvalue ! config data character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logUnit) + + !-------------------------------- ! generate the mesh + !-------------------------------- + call NUOPC_CompAttributeGet(gcomp, name='mesh_ice', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + !-------------------------------- ! realize the actively coupled fields, now that a mesh is established ! 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 fld_list_realize( & state=ExportState, & fldlist=fldsFrIce, & @@ -292,36 +344,32 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - ! determine the mesh lats and lons (module variables) - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(lon(numownedElements)) - allocate(lat(numownedElements)) - do n = 1,numownedElements - lon(n) = ownedElemCoords(2*n-1) - lat(n) = ownedElemCoords(2*n) - end do - nxg = numownedElements - nyg = 1 - + !-------------------------------- ! Pack export state + !-------------------------------- + call State_SetExport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) + + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) + + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + !-------------------------------- ! diagnostics + !-------------------------------- + if (dbug > 1) then call State_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif + call shr_file_setLogUnit (shrlogunit) + end subroutine InitializeRealize !=============================================================================== @@ -332,26 +380,46 @@ subroutine ModelAdvance(gcomp, rc) integer, intent(out) :: rc ! local variables + type(ESMF_Clock) :: clock type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) call memcheck(subname, 3, mastertask) + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- ! Pack export state - call NUOPC_ModelGet(gcomp, exportState=exportState, rc=rc) + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + !-------------------------------- ! diagnostics + !-------------------------------- + if (dbug > 1) then call State_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + if (my_task == master_task) then + call log_clock_advance(clock, 'XICE', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif endif + call shr_file_setLogUnit (shrlogunit) + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + end subroutine ModelAdvance !=============================================================================== @@ -363,6 +431,8 @@ subroutine state_setexport(exportState, rc) ! local variables integer :: n, nf, nind + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) integer :: spatialDim integer :: numOwnedElements real(R8), pointer :: ownedElemCoords(:) @@ -370,6 +440,19 @@ subroutine state_setexport(exportState, rc) rc = ESMF_SUCCESS + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + ! Start from index 2 in order to skip the scalar field do nf = 2,fldsFrIce_num if (fldsFrIce(nf)%ungridded_ubound == 0) then @@ -384,6 +467,9 @@ subroutine state_setexport(exportState, rc) end if end do + deallocate(lon) + deallocate(lat) + end subroutine state_setexport !=============================================================================== diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml index 116268af0..760d75e5c 100755 --- a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml @@ -10,13 +10,13 @@ _CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",".."," sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * -from CIME.buildnml import parse_input +from CIME.buildnml import build_xcpl_nml, parse_input from CIME.case import Case def buildnml(case, caseroot, compname): if compname != "xlnd": raise AttributeError - # do nothing + build_xcpl_nml(case, caseroot, compname) def _main_func(): caseroot = parse_input(sys.argv) diff --git a/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 index 5076d442f..0d08bf68b 100644 --- a/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 @@ -14,8 +14,10 @@ module lnd_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, memcheck, set_component_logging - use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type implicit none @@ -41,13 +43,15 @@ module lnd_comp_nuopc integer :: glc_nec type(ESMF_Mesh) :: mesh - real(r8), pointer :: lat(:) ! mesh lats - real(r8), pointer :: lon(:) ! mesh lons - integer :: my_task ! my task in mpi communicator mpicom - integer :: logunit ! logging unit number - integer ,parameter :: master_task=0 ! task number of master task + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + 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 + integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask - integer :: dbug = 0 + integer :: dbug = 1 character(*),parameter :: modName = "(xlnd_comp_nuopc)" character(*),parameter :: u_FILE_u = & __FILE__ @@ -113,7 +117,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm + character(CS) :: stdname integer :: n + integer :: lsize ! local array size integer :: shrlogunit ! original log unit character(CL) :: cvalue character(CL) :: logmsg @@ -122,18 +128,40 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) !------------------------------------------------------------------------------- rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMGet(vm, localpet=my_task, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + mastertask = (my_task == master_task) + !---------------------------------------------------------------------------- + ! determine instance information + !---------------------------------------------------------------------------- + + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + !---------------------------------------------------------------------------- ! set logunit and set shr logging to my log file + !---------------------------------------------------------------------------- + call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + !---------------------------------------------------------------------------- + ! Initialize xlnd + !---------------------------------------------------------------------------- + + call dead_read_inparms('lnd', inst_suffix, logunit, nxg, nyg) + + !-------------------------------- ! advertise import and export fields + !-------------------------------- + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then @@ -177,82 +205,92 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') end if - call NUOPC_CompAttributeGet(gcomp, name='glc_nec', value=cvalue, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - read(cvalue,*) glc_nec - call ESMF_LogWrite('glc_nec = '// trim(cvalue), ESMF_LOGMSG_INFO) - - call fld_list_add(fldsFrLnd_num, fldsFrlnd, trim(flds_scalar_name)) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_lfrin' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_t' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_tref' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_qref' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_avsdr' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_anidr' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_avsdf' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_anidf' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_snowh' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_u10' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_fv' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_ram1' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofsur' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofgwl' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofsub' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofi' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_irrig' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_taux' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_tauy' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_lat' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_sen' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_lwup' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_evap' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_swnet' ) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_flxdst' , ungridded_lbound=1, ungridded_ubound=4) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flgl_qice_elev', ungridded_lbound=1, ungridded_ubound=glc_nec+1) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_tsrf_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) - call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_topo_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) - - call fld_list_add(fldsToLnd_num, fldsToLnd, trim(flds_scalar_name)) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_z' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_topo' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_u' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_v' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_ptem' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_pbot' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_tbot' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_shum' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Flrr_volr' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Flrr_volrmch' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_lwdn' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_rainc' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_rainl' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_snowc' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_snowl' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swndr' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swvdr' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swndf' ) - call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swvdf' ) - call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) - call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) - call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_dstwet' , ungridded_lbound=1, ungridded_ubound=4) - call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_dstdry' , ungridded_lbound=1, ungridded_ubound=4) - call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_topo_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) - call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_ice_covered_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) - call fld_list_add(fldsToLnd_num, fldsTolnd, 'Flgg_hflx_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) - - do n = 1,fldsFrLnd_num - if (mastertask) write(logunit,*)'Advertising From Xlnd ',trim(fldsFrLnd(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrLnd(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo + if (nxg /= 0 .and. nyg /= 0) then - do n = 1,fldsToLnd_num - if(mastertask) write(logunit,*)'Advertising To Xlnd',trim(fldsToLnd(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToLnd(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo + call NUOPC_CompAttributeGet(gcomp, name='glc_nec', value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + read(cvalue,*) glc_nec + call ESMF_LogWrite('glc_nec = '// trim(cvalue), ESMF_LOGMSG_INFO) + + call fld_list_add(fldsFrLnd_num, fldsFrlnd, trim(flds_scalar_name)) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_lfrin' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_t' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_tref' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_qref' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_avsdr' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_anidr' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_avsdf' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_anidf' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_snowh' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_u10' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_fv' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_ram1' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofsur' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofgwl' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofsub' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_rofi' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flrl_irrig' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_taux' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_tauy' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_lat' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_sen' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_lwup' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_evap' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_swnet' ) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Fall_flxdst' , ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Flgl_qice_elev', ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_tsrf_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsFrLnd_num, fldsFrlnd, 'Sl_topo_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + + call fld_list_add(fldsToLnd_num, fldsToLnd, trim(flds_scalar_name)) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_z' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_topo' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_u' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_v' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_ptem' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_pbot' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_tbot' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Sa_shum' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Flrr_volr' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Flrr_volrmch' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_lwdn' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_rainc' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_rainl' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_snowc' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_snowl' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swndr' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swvdr' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swndf' ) + call fld_list_add(fldsToLnd_num, fldsToLnd, 'Faxa_swvdf' ) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_bcph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_ocph' , ungridded_lbound=1, ungridded_ubound=3) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_dstwet' , ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsTolnd_num, fldsTolnd, 'Faxa_dstdry' , ungridded_lbound=1, ungridded_ubound=4) + call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_topo_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_ice_covered_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsToLnd_num, fldsTolnd, 'Flgg_hflx_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + + do n = 1,fldsFrLnd_num + if (mastertask) write(logunit,*)'Advertising From Xlnd ',trim(fldsFrLnd(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrLnd(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + do n = 1,fldsToLnd_num + if(mastertask) write(logunit,*)'Advertising To Xlnd',trim(fldsToLnd(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToLnd(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + + end if + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) end subroutine InitializeAdvertise @@ -266,25 +304,38 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - integer :: n, nxg, nyg - character(ESMF_MAXSTR) :: cvalue ! config data - integer :: spatialDim - integer :: numOwnedElements - real(R8), pointer :: ownedElemCoords(:) + integer :: shrlogunit ! original log unit + integer :: n + character(ESMF_MAXSTR) :: cvalue ! config data character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS + if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to my log file + !---------------------------------------------------------------------------- + + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logUnit) + !-------------------------------- ! generate the mesh + !-------------------------------- + call NUOPC_CompAttributeGet(gcomp, name='mesh_lnd', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + !-------------------------------- ! realize the actively coupled fields, now that a mesh is established ! 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 fld_list_realize( & state=ExportState, & fldlist=fldsFrLnd, & @@ -305,36 +356,34 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - ! determine the mesh lats and lons (module variables) - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(lon(numownedElements)) - allocate(lat(numownedElements)) - do n = 1,numownedElements - lon(n) = ownedElemCoords(2*n-1) - lat(n) = ownedElemCoords(2*n) - end do - nxg = numownedElements - nyg = 1 - + !-------------------------------- ! Pack export state + !-------------------------------- + call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) + + call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, & + flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) + + call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, & + flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + !-------------------------------- ! diagnostics + !-------------------------------- + if (dbug > 1) then call state_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + end subroutine InitializeRealize !=============================================================================== @@ -345,26 +394,46 @@ subroutine ModelAdvance(gcomp, rc) integer, intent(out) :: rc ! local variables + type(ESMF_Clock) :: clock type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) call memcheck(subname, 3, mastertask) + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + + !-------------------------------- ! Pack export state - call NUOPC_ModelGet(gcomp, exportState=exportState, rc=rc) + !-------------------------------- + + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + !-------------------------------- ! diagnostics + !-------------------------------- + if (dbug > 1) then call state_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + if (mastertask) then + call log_clock_advance(clock, 'LND', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif endif + call shr_file_setLogUnit (shrlogunit) + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + end subroutine ModelAdvance !=============================================================================== @@ -376,11 +445,29 @@ subroutine state_setexport(exportState, rc) integer, intent(out) :: rc ! local variables - integer :: nf, nind + integer :: n, nf, nind + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) !-------------------------------------------------- rc = ESMF_SUCCESS + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + ! Start from index 2 in order to Skip the scalar field here do nf = 2,fldsFrLnd_num if (fldsFrLnd(nf)%ungridded_ubound == 0) then @@ -395,6 +482,9 @@ subroutine state_setexport(exportState, rc) end if end do + deallocate(lon) + deallocate(lat) + end subroutine state_setexport !=============================================================================== diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml index acda3b213..c6f945376 100755 --- a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml @@ -10,13 +10,13 @@ _CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",".."," sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * -from CIME.buildnml import parse_input +from CIME.buildnml import build_xcpl_nml, parse_input from CIME.case import Case def buildnml(case, caseroot, compname): if compname != "xocn": raise AttributeError - # do nothing + build_xcpl_nml(case, caseroot, compname) def _main_func(): caseroot = parse_input(sys.argv) diff --git a/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 index edac19b09..5d6b04ec9 100644 --- a/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 @@ -14,8 +14,10 @@ module ocn_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, memcheck, set_component_logging - use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type implicit none @@ -40,11 +42,14 @@ module ocn_comp_nuopc integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost type(ESMF_Mesh) :: mesh - real(r8), pointer :: lat(:) ! mesh lats - real(r8), pointer :: lon(:) ! mesh lons - integer :: my_task ! my task in mpi communicator mpicom - integer :: logunit ! logging unit number - integer ,parameter :: master_task=0 ! task number of master task + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + integer :: inst_index ! number of current instance (ie. 1) + character(len=16) :: inst_name ! fullname of current instance (ie. "ocn_0001") + character(len=16) :: inst_suffix = "" ! char string associated with instance (ie. "_0001" or "") + integer :: logunit ! logging unit number + integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask integer :: dbug = 0 character(*),parameter :: modName = "(xocn_comp_nuopc)" @@ -101,6 +106,7 @@ subroutine SetServices(gcomp, rc) end subroutine SetServices !=============================================================================== + subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! input/output variables @@ -112,6 +118,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm integer :: n + integer :: lsize ! local array size integer :: shrlogunit ! original log unit character(CL) :: cvalue character(len=CL) :: logmsg @@ -128,10 +135,17 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return mastertask = (my_task == master_task) + ! determine instance information + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + ! set logunit and set shr logging to my log file call set_component_logging(gcomp, my_task==master_task, logunit, shrlogunit, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + ! Initialize xocn + call dead_read_inparms('ocn', inst_suffix, logunit, nxg, nyg) + ! advertise import and export fields call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -176,49 +190,55 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') endif - call fld_list_add(fldsFrOcn_num, fldsFrOcn, trim(flds_scalar_name)) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_omask" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_t" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_s" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_u" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_v" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_dhdx" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_dhdy" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_bldepth" ) - call fld_list_add(fldsFrOcn_num, fldsFrOcn, "Fioo_q" ) - - call fld_list_add(fldsToOcn_num, fldsToOcn, trim(flds_scalar_name)) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_rain" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_snow" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_lwdn" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swndr" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swvdr" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swndf" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swvdf" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_taux" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_tauy" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_sen" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_lat" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_lwup" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_evap" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Fioi_salt" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_rofl" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_rofi" ) - call fld_list_add(fldsToOcn_num, fldsToOcn, "Sa_pslv" ) - - do n = 1,fldsFrOcn_num - if(mastertask) write(logunit,*)'Advertising From Xocn ',trim(fldsFrOcn(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrOcn(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrOcn_num, fldsFrOcn, trim(flds_scalar_name)) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_omask" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_t" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_s" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_u" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_v" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_dhdx" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_dhdy" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "So_bldepth" ) + call fld_list_add(fldsFrOcn_num, fldsFrOcn, "Fioo_q" ) + + call fld_list_add(fldsToOcn_num, fldsToOcn, trim(flds_scalar_name)) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_rain" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_snow" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_lwdn" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swndr" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swvdr" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swndf" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Faxa_swvdf" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_taux" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_tauy" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_sen" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_lat" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_lwup" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_evap" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Fioi_salt" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_rofl" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Foxx_rofi" ) + call fld_list_add(fldsToOcn_num, fldsToOcn, "Sa_pslv" ) + + do n = 1,fldsFrOcn_num + if(mastertask) write(logunit,*)'Advertising From Xocn ',trim(fldsFrOcn(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrOcn(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo - do n = 1,fldsToOcn_num - if(mastertask) write(logunit,*)'Advertising To Xocn',trim(fldsToOcn(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToOcn(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo + do n = 1,fldsToOcn_num + if(mastertask) write(logunit,*)'Advertising To Xocn',trim(fldsToOcn(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToOcn(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + ! Reset shr logging to original values + call shr_file_setLogUnit (shrlogunit) end subroutine InitializeAdvertise @@ -232,16 +252,17 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - integer :: n, nxg, nyg + integer :: shrlogunit ! original log unit character(ESMF_MAXSTR) :: cvalue ! config data - integer :: spatialDim - integer :: numOwnedElements - real(R8), pointer :: ownedElemCoords(:) character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize: xocn) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS + ! Reset shr logging to my log file + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + ! generate the mesh call NUOPC_CompAttributeGet(gcomp, name='mesh_ocn', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -271,22 +292,6 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - ! determine the mesh lats and lons (module variables) - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(lon(numownedElements)) - allocate(lat(numownedElements)) - do n = 1,numownedElements - lon(n) = ownedElemCoords(2*n-1) - lat(n) = ownedElemCoords(2*n) - end do - nxg = numownedElements - nyg = 1 - ! Pack export state call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -301,6 +306,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif + call shr_file_setLogUnit (shrlogunit) + end subroutine InitializeRealize !=============================================================================== @@ -311,7 +318,9 @@ subroutine ModelAdvance(gcomp, rc) integer, intent(out) :: rc ! local variables + type(ESMF_Clock) :: clock type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- @@ -319,8 +328,11 @@ subroutine ModelAdvance(gcomp, rc) call memcheck(subname, 3, mastertask) + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + ! Pack export state - call NUOPC_ModelGet(gcomp, exportState=exportState, rc=rc) + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -331,22 +343,42 @@ subroutine ModelAdvance(gcomp, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif + call shr_file_setLogUnit (shrlogunit) + end subroutine ModelAdvance !=============================================================================== subroutine state_setexport(exportState, rc) ! input/output variables - type(ESMF_State) , intent(inout) :: exportState - integer , intent(out) :: rc + type(ESMF_State) , intent(inout) :: exportState + integer, intent(out) :: rc ! local variables - integer :: nf, nind + integer :: n, nf, nind + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) !-------------------------------------------------- rc = ESMF_SUCCESS - ! Start from index 2 in order to Skip the scalar field here + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + + ! Start from index 2 in order to Skip the scalar field here do nf = 2,fldsFrOcn_num if (fldsFrOcn(nf)%ungridded_ubound == 0) then call field_setexport(exportState, trim(fldsFrOcn(nf)%stdname), lon, lat, nf=nf, rc=rc) @@ -360,9 +392,13 @@ subroutine state_setexport(exportState, rc) end if end do + deallocate(lon) + deallocate(lat) + end subroutine state_setexport !=============================================================================== + subroutine field_setexport(exportState, fldname, lon, lat, nf, ungridded_index, rc) use shr_const_mod , only : pi=>shr_const_pi diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml index 688029a29..182cf39ef 100755 --- a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml @@ -10,13 +10,13 @@ _CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",".."," sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * -from CIME.buildnml import parse_input +from CIME.buildnml import build_xcpl_nml, parse_input from CIME.case import Case def buildnml(case, caseroot, compname): if compname != "xrof": raise AttributeError - # do nothing + build_xcpl_nml(case, caseroot, compname) def _main_func(): caseroot = parse_input(sys.argv) diff --git a/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 index 231170c08..d62bc458e 100644 --- a/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 @@ -5,18 +5,20 @@ module rof_comp_nuopc !---------------------------------------------------------------------------- use ESMF - 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 - use shr_sys_mod , only : shr_sys_abort - use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, memcheck, set_component_logging - use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock - use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type implicit none private ! except @@ -40,14 +42,16 @@ module rof_comp_nuopc integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost type(ESMF_Mesh) :: mesh - real(r8), pointer :: lat(:) ! mesh lats - real(r8), pointer :: lon(:) ! mesh lons - integer :: my_task ! my task in mpi communicator mpicom - integer :: logunit ! logging unit number - integer ,parameter :: master_task=0 ! task number of master task + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi + 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 + integer ,parameter :: master_task=0 ! task number of master task logical :: mastertask integer :: dbug = 0 - character(*),parameter :: modName = "(xrof_comp_nuopc)" + character(*),parameter :: modName = "(xrof_comp_nuopc)" character(*),parameter :: u_FILE_u = & __FILE__ @@ -129,12 +133,21 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return mastertask = (my_task == master_task) + ! determine instance information + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! set logunit and set shr logging to my log file call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! Initialize xrof + call dead_read_inparms('rof', inst_suffix, logunit, nxg, nyg) + !-------------------------------- ! advertise import and export fields + !-------------------------------- + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then @@ -178,34 +191,45 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') endif - call fld_list_add(fldsFrRof_num, fldsFrRof, trim(flds_scalar_name)) - call fld_list_add(fldsFrRof_num, fldsFrRof, 'Forr_rofl') - call fld_list_add(fldsFrRof_num, fldsFrRof, 'Forr_rofi') - call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_flood') - call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_volr') - call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_volrmch') - - call fld_list_add(fldsToRof_num, fldsToRof, trim(flds_scalar_name)) - call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofsur') - call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofgwl') - call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofsub') - call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofdto') - call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofi') - call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_irrig') - - do n = 1,fldsFrRof_num - if(mastertask) write(logunit,*)'Advertising From Xrof ',trim(fldsFrRof(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrRof(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrRof_num, fldsFrRof, trim(flds_scalar_name)) + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Forr_rofl') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Forr_rofi') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_flood') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_volr') + call fld_list_add(fldsFrRof_num, fldsFrRof, 'Flrr_volrmch') + + call fld_list_add(fldsToRof_num, fldsToRof, trim(flds_scalar_name)) + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofsur') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofgwl') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofsub') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofdto') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_rofi') + call fld_list_add(fldsToRof_num, fldsToRof, 'Flrl_irrig') + + do n = 1,fldsFrRof_num + if(mastertask) write(logunit,*)'Advertising From Xrof ',trim(fldsFrRof(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrRof(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo - do n = 1,fldsToRof_num - if(mastertask) write(logunit,*)'Advertising To Xrof',trim(fldsToRof(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToRof(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo + do n = 1,fldsToRof_num + if(mastertask) write(logunit,*)'Advertising To Xrof',trim(fldsToRof(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToRof(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + + !---------------------------------------------------------------------------- + ! Reset shr logging to original values + !---------------------------------------------------------------------------- + + call shr_file_setLogUnit (shrlogunit) end subroutine InitializeAdvertise @@ -219,16 +243,18 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - integer :: n, nxg, nyg + integer :: shrlogunit ! original log unit character(ESMF_MAXSTR) :: cvalue ! config data - integer :: spatialDim - integer :: numOwnedElements - real(R8), pointer :: ownedElemCoords(:) character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS + ! Reset shr logging to my log file + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logUnit) + + ! generate the mesh call NUOPC_CompAttributeGet(gcomp, name='mesh_rof', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -258,23 +284,10 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - ! determine the mesh lats and lons (module variables) - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(lon(numownedElements)) - allocate(lat(numownedElements)) - do n = 1,numownedElements - lon(n) = ownedElemCoords(2*n-1) - lat(n) = ownedElemCoords(2*n) - end do - nxg = numownedElements - nyg = 1 - + !-------------------------------- ! Pack export state + !-------------------------------- + call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call State_SetScalar(dble(nxg),flds_scalar_index_nx, exportState, flds_scalar_name, flds_scalar_num, rc) @@ -282,12 +295,17 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call State_SetScalar(dble(nyg),flds_scalar_index_ny, exportState, flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + !-------------------------------- ! diagnostics + !-------------------------------- + if (dbug > 1) then call State_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif + call shr_file_setLogUnit (shrlogunit) + end subroutine InitializeRealize !=============================================================================== @@ -298,16 +316,24 @@ subroutine ModelAdvance(gcomp, rc) integer, intent(out) :: rc ! local variables - type(ESMF_State) :: exportState + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS + if (dbug > 5) then + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + end if call memcheck(subname, 3, mastertask) + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + ! Pack export state - call NUOPC_ModelGet(gcomp, exportState=exportState, rc=rc) + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call State_SetExport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -316,8 +342,18 @@ subroutine ModelAdvance(gcomp, rc) if (dbug > 1) then call State_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + if (mastertask) then + call log_clock_advance(clock, 'XROF', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif endif + call shr_file_setLogUnit (shrlogunit) + + if (dbug > 5) then + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + end if + end subroutine ModelAdvance !=============================================================================== @@ -328,11 +364,29 @@ subroutine state_setexport(exportState, rc) integer, intent(out) :: rc ! local variables - integer :: nf, nind + integer :: n, nf, nind + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) !-------------------------------------------------- rc = ESMF_SUCCESS + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + ! Start from index 2 in order to skip the scalar field do nf = 2,fldsFrRof_num if (fldsFrRof(nf)%ungridded_ubound == 0) then @@ -347,6 +401,9 @@ subroutine state_setexport(exportState, rc) end if end do + deallocate(lon) + deallocate(lat) + end subroutine state_setexport !=============================================================================== diff --git a/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 b/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 index a748c67ed..ee3ca6b68 100644 --- a/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 +++ b/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 @@ -15,6 +15,7 @@ module dead_nuopc_mod implicit none private + public :: dead_read_inparms public :: ModelInitPhase public :: ModelSetRunClock public :: fld_list_add @@ -37,6 +38,64 @@ module dead_nuopc_mod contains !=============================================================================== + subroutine dead_read_inparms(model, inst_suffix, logunit, nxg, nyg) + + ! input/output variables + character(len=*) , intent(in) :: model + character(len=*) , intent(in) :: inst_suffix ! char string associated with instance + integer , intent(in) :: logunit ! logging unit number + integer , intent(out) :: nxg ! global dim i-direction + integer , intent(out) :: nyg ! global dim j-direction + + ! local variables + type(ESMF_VM) :: vm + character(CL) :: fileName ! generic file name + integer :: nunit ! unit number + integer :: unitn ! Unit for namelist file + integer :: tmp(2) ! array for broadcast + integer :: localPet ! mpi id of current task in current context + integer :: rc ! return code + character(*), parameter :: F00 = "('(dead_read_inparms) ',8a)" + character(*), parameter :: F01 = "('(dead_read_inparms) ',a,a,4i8)" + character(*), parameter :: F03 = "('(dead_read_inparms) ',a,a,i8,a)" + character(*), parameter :: subName = "(dead_read_inpamrs) " + !------------------------------------------------------------------------------- + + ! read the input parms (used to configure model) + call ESMF_VMGetCurrent(vm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMGet(vm, localPet=localPet, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + nxg = -9999 + nyg = -9999 + + if (localPet==0) then + open(newunit=unitn, file='x'//model//'_in'//trim(inst_suffix), status='old' ) + read(unitn,*) nxg + read(unitn,*) nyg + close (unitn) + endif + + tmp(1) = nxg + tmp(2) = nyg + call ESMF_VMBroadcast(vm, tmp, 3, 0, rc=rc) + nxg = tmp(1) + nyg = tmp(2) + + if (localPet==0) then + write(logunit,*)' Read in X'//model//' input from file= x'//model//'_in' + write(logunit,F00) model + write(logunit,F00) model,' Model : ',model + write(logunit,F01) model,' NGX : ',nxg + write(logunit,F01) model,' NGY : ',nyg + write(logunit,F00) model,' inst_suffix : ',trim(inst_suffix) + write(logunit,F00) model + end if + + end subroutine dead_read_inparms + + !=============================================================================== subroutine fld_list_add(num, fldlist, stdname, ungridded_lbound, ungridded_ubound) ! input/output variables diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml index 7c3f264d8..b7b8576ba 100755 --- a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml @@ -10,13 +10,13 @@ _CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",".."," sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * -from CIME.buildnml import parse_input +from CIME.buildnml import build_xcpl_nml, parse_input from CIME.case import Case def buildnml(case, caseroot, compname): if compname != "xwav": raise AttributeError - # do nothing + build_xcpl_nml(case, caseroot, compname) def _main_func(): caseroot = parse_input(sys.argv) diff --git a/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 index a06fab7b3..2bb08fc29 100644 --- a/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 @@ -5,18 +5,20 @@ module wav_comp_nuopc !---------------------------------------------------------------------------- use ESMF - 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 - use shr_sys_mod , only : shr_sys_abort - use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, memcheck, set_component_logging - use dead_nuopc_mod , only : ModelInitPhase, ModelSetRunClock - use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type + 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 + use shr_sys_mod , only : shr_sys_abort + use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs + use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck + use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance + use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock + use dead_nuopc_mod , only : fld_list_add, fld_list_realize, fldsMax, fld_list_type implicit none private ! except @@ -40,13 +42,14 @@ module wav_comp_nuopc integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost type(ESMF_Mesh) :: mesh - real(r8), pointer :: lat(:) ! mesh lats - real(r8), pointer :: lon(:) ! mesh lons - integer :: my_task ! my task in mpi communicator mpicom - integer :: logunit ! logging unit number - integer ,parameter :: master_task=0 ! task number of master task + integer :: nxg ! global dim i-direction + integer :: nyg ! global dim j-direction + integer :: my_task ! my task in mpi communicator mpicom + 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 :: mastertask - integer :: dbug = 0 + integer :: dbug = 1 character(*),parameter :: modName = "(xwav_comp_nuopc)" character(*),parameter :: u_FILE_u = & __FILE__ @@ -111,7 +114,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm + character(CS) :: stdname integer :: n + integer :: lsize ! local array size integer :: shrlogunit ! original log unit character(CL) :: cvalue character(len=CL) :: logmsg @@ -120,17 +125,28 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) !------------------------------------------------------------------------------- rc = ESMF_SUCCESS + call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMGet(vm, localpet=my_task, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - mastertask = (my_task == master_task) + + mastertask = (my_task == 0) + + ! determine instance information + call get_component_instance(gcomp, inst_suffix, inst_index, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return ! set logunit and set shr logging to my log file call set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + ! Initialize xwav + call dead_read_inparms('wav', inst_suffix, logunit, nxg, nyg) + ! advertise import and export fields call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -175,35 +191,44 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') endif - call fld_list_add(fldsFrWav_num, fldsFrWav, trim(flds_scalar_name)) - call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_lamult' ) - call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_ustokes' ) - call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_vstokes' ) - call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_hstokes' ) - - call fld_list_add(fldsToWav_num, fldsToWav, trim(flds_scalar_name)) - call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_u' ) - call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_v' ) - call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_tbot' ) - call fld_list_add(fldsToWav_num, fldsToWav, 'Si_ifrac' ) - call fld_list_add(fldsToWav_num, fldsToWav, 'So_t' ) - call fld_list_add(fldsToWav_num, fldsToWav, 'So_u' ) - call fld_list_add(fldsToWav_num, fldsToWav, 'So_v' ) - call fld_list_add(fldsToWav_num, fldsToWav, 'So_bldepth' ) - - do n = 1,fldsFrWav_num - if (mastertask) write(logunit,*)'Advertising From Xwav ',trim(fldsFrWav(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrWav(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo + if (nxg /= 0 .and. nyg /= 0) then + + call fld_list_add(fldsFrWav_num, fldsFrWav, trim(flds_scalar_name)) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_lamult' ) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_ustokes' ) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_vstokes' ) + call fld_list_add(fldsFrWav_num, fldsFrWav, 'Sw_hstokes' ) + + call fld_list_add(fldsToWav_num, fldsToWav, trim(flds_scalar_name)) + call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_u' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_v' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'Sa_tbot' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'Si_ifrac' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_t' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_u' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_v' ) + call fld_list_add(fldsToWav_num, fldsToWav, 'So_bldepth' ) + + do n = 1,fldsFrWav_num + if (mastertask) write(logunit,*)'Advertising From Xwav ',trim(fldsFrWav(n)%stdname) + call NUOPC_Advertise(exportState, standardName=fldsFrWav(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo - do n = 1,fldsToWav_num - if(mastertask) write(logunit,*)'Advertising To Xwav ',trim(fldsToWav(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToWav(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo + do n = 1,fldsToWav_num + if(mastertask) write(logunit,*)'Advertising To Xwav ',trim(fldsToWav(n)%stdname) + call NUOPC_Advertise(importState, standardName=fldsToWav(n)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + enddo + end if + + call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! Reset shr logging to original values + call shr_file_setLogUnit (shrlogunit) end subroutine InitializeAdvertise @@ -217,16 +242,17 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - integer :: n, nxg, nyg + integer :: shrlogunit ! original log unit character(ESMF_MAXSTR) :: cvalue ! config data - integer :: spatialDim - integer :: numOwnedElements - real(R8), pointer :: ownedElemCoords(:) character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS + ! Reset shr logging to my log file + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + ! generate the mesh call NUOPC_CompAttributeGet(gcomp, name='mesh_wav', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -256,22 +282,6 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - ! determine the mesh lats and lons (module variables) - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(lon(numownedElements)) - allocate(lat(numownedElements)) - do n = 1,numownedElements - lon(n) = ownedElemCoords(2*n-1) - lat(n) = ownedElemCoords(2*n) - end do - nxg = numownedElements - nyg = 1 - ! Pack export state call State_SetExport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -286,6 +296,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif + call shr_file_setLogUnit (shrlogunit) + end subroutine InitializeRealize !=============================================================================== @@ -296,7 +308,9 @@ subroutine ModelAdvance(gcomp, rc) integer, intent(out) :: rc ! local variables - type(ESMF_State) :: exportState + type(ESMF_Clock) :: clock + type(ESMF_State) :: exportState + integer :: shrlogunit ! original log unit character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- @@ -304,8 +318,11 @@ subroutine ModelAdvance(gcomp, rc) call memcheck(subname, 3, mastertask) + call shr_file_getLogUnit (shrlogunit) + call shr_file_setLogUnit (logunit) + ! Pack export state - call NUOPC_ModelGet(gcomp, exportState=exportState, rc=rc) + call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return call state_setexport(exportState, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -314,8 +331,14 @@ subroutine ModelAdvance(gcomp, rc) if (dbug > 1) then call State_diagnose(exportState,subname//':ES',rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + if ( mastertask) then + call log_clock_advance(clock, 'XWAV', logunit, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif endif + call shr_file_setLogUnit (shrlogunit) + end subroutine ModelAdvance !=============================================================================== @@ -326,12 +349,30 @@ subroutine state_setexport(exportState, rc) integer , intent(out) :: rc ! local variables - integer :: nfstart, ubound - integer :: nf, nind + integer :: nfstart, ubound + integer :: n, nf, nind + real(r8), pointer :: lat(:) + real(r8), pointer :: lon(:) + integer :: spatialDim + integer :: numOwnedElements + real(R8), pointer :: ownedElemCoords(:) !-------------------------------------------------- rc = ESMF_SUCCESS + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(lon(numownedElements)) + allocate(lat(numownedElements)) + do n = 1,numownedElements + lon(n) = ownedElemCoords(2*n-1) + lat(n) = ownedElemCoords(2*n) + end do + nfstart = 0 ! for fields that have ubound > 0 do nf = 2,fldsFrWav_num ! Start from index 2 in order to skip the scalar field ubound = fldsFrWav(nf)%ungridded_ubound @@ -348,6 +389,9 @@ subroutine state_setexport(exportState, rc) end if end do + deallocate(lon) + deallocate(lat) + end subroutine state_setexport !=============================================================================== From 9fdcb31bffd38b8936102ff2663a27f06dce50a5 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Sun, 29 Nov 2020 19:53:17 -0700 Subject: [PATCH 08/24] changes to dead components for ice sheet capability for glc --- .../xglc/src/glc_comp_nuopc.F90 | 191 ++++++++---------- .../xlnd/src/lnd_comp_nuopc.F90 | 2 + 2 files changed, 82 insertions(+), 111 deletions(-) diff --git a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 index 8bf8b8b6e..f8739ec83 100644 --- a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 @@ -6,7 +6,7 @@ module glc_comp_nuopc use ESMF use NUOPC , only : NUOPC_CompDerive, NUOPC_CompSetEntryPoint, NUOPC_CompSpecialize - use NUOPC , only : NUOPC_CompAttributeGet, NUOPC_Advertise + use NUOPC , only : NUOPC_CompAttributeGet, NUOPC_Advertise, NUOPC_AddNestedState 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 @@ -54,6 +54,12 @@ module glc_comp_nuopc character(*),parameter :: u_FILE_u = & __FILE__ + ! TODO: this must be generalized - but for now is just hard-wired + integer, parameter :: max_icesheets = 1 + integer :: num_icesheets = 1 + type(ESMF_State) :: NStateImp(max_icesheets) + type(ESMF_State) :: NStateExp(max_icesheets) + !=============================================================================== contains !=============================================================================== @@ -115,11 +121,12 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm character(CS) :: stdname - integer :: n + integer :: n, ns, nf integer :: lsize ! local array size integer :: shrlogunit ! original log unit character(CL) :: cvalue character(len=CL) :: logmsg + character(len=CS) :: cnum logical :: isPresent, isSet character(len=*),parameter :: subname=trim(modName)//':(InitializeAdvertise) ' !------------------------------------------------------------------------------- @@ -189,6 +196,15 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxGridNY') endif + ! Create nested state for each active ice sheet + do ns = 1,num_icesheets + write(cnum,'(i0)') ns + call NUOPC_AddNestedState(importState, CplSet="GLC"//trim(cnum), nestedState=NStateImp(ns), rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call NUOPC_AddNestedState(exportState, CplSet="GLC"//trim(cnum), nestedState=NStateExp(ns), rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + end do + if (nxg /= 0 .and. nyg /= 0) then call fld_list_add(fldsFrGlc_num, fldsFrGlc, trim(flds_scalar_name)) @@ -202,24 +218,24 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call fld_list_add(fldsToGlc_num, fldsToGlc, 'Sl_tsrf') call fld_list_add(fldsToGlc_num, fldsToGlc, 'Flgl_qice') - do n = 1,fldsFrGlc_num + ! Now advertise import and export fields fields + do ns = 1,num_icesheets + if (mastertask) write(logunit,*)'Advertising To Xglc ',trim(fldsToGlc(n)%stdname) + do nf = 1,fldsToGlc_num + call NUOPC_Advertise(NStateImp(ns), standardName=fldsToGlc(nf)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkErr(rc,__LINE__,u_FILE_u)) return + end do if (mastertask) write(logunit,*)'Advertising From Xglc ',trim(fldsFrGlc(n)%stdname) - call NUOPC_Advertise(exportState, standardName=fldsFrglc(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + do nf = 1,fldsFrGlc_num + call NUOPC_Advertise(NStateExp(ns), standardName=fldsFrGlc(nf)%stdname, & + TransferOfferGeomObject='will provide', rc=rc) + if (chkErr(rc,__LINE__,u_FILE_u)) return + end do enddo - do n = 1,fldsToGlc_num - if (mastertask) write(logunit,*)'Advertising To Xglc ',trim(fldsToGlc(n)%stdname) - call NUOPC_Advertise(importState, standardName=fldsToglc(n)%stdname, & - TransferOfferGeomObject='will provide', rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - enddo end if - ! Reset shr logging to original values - call shr_file_setLogUnit (shrlogunit) - end subroutine InitializeAdvertise !=============================================================================== @@ -233,84 +249,55 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - integer :: n - integer :: shrlogunit ! original log unit + integer :: n, ns character(ESMF_MAXSTR) :: cvalue ! config data character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS - !---------------------------------------------------------------------------- - ! Reset shr logging to my log file - !---------------------------------------------------------------------------- - - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) - - !-------------------------------- ! generate the mesh - !-------------------------------- - call NUOPC_CompAttributeGet(gcomp, name='mesh_glc', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- ! realize the actively coupled fields, now that a mesh is established ! 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 fld_list_realize( & - state=ExportState, & - fldList=fldsFrGlc, & - numflds=fldsFrGlc_num, & - flds_scalar_name=flds_scalar_name, & - flds_scalar_num=flds_scalar_num, & - tag=subname//':dglcExport',& - mesh=mesh, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - call fld_list_realize( & - state=importState, & - fldList=fldsToGlc, & - numflds=fldsToGlc_num, & - flds_scalar_name=flds_scalar_name, & - flds_scalar_num=flds_scalar_num, & - tag=subname//':dglcImport',& - mesh=mesh, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - !-------------------------------- - ! Pack export state - ! Copy from d2x to exportState - ! Set the coupling scalars - !-------------------------------- - - call state_setexport(exportState, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + do ns = 1,num_icesheets + call fld_list_realize( & + state=NStateExp(ns), & + fldList=fldsFrGlc, & + numflds=fldsFrGlc_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':dglcExport',& + mesh=mesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return - call state_setscalar(dble(nxg),flds_scalar_index_nx, exportState, & - flds_scalar_name, flds_scalar_num, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + call fld_list_realize( & + state=NStateImp(ns), & + fldList=fldsToGlc, & + numflds=fldsToGlc_num, & + flds_scalar_name=flds_scalar_name, & + flds_scalar_num=flds_scalar_num, & + tag=subname//':dglcImport',& + mesh=mesh, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do - call state_setscalar(dble(nyg),flds_scalar_index_ny, exportState, & - flds_scalar_name, flds_scalar_num, rc) + ! Pack export state and set the coupling scalars + call state_setexport(rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - !-------------------------------- - ! diagnostics - !-------------------------------- - - if (dbug > 1) then - call state_diagnose(exportState,subname//':ES',rc=rc) + do ns = 1,num_icesheets + call state_setscalar(dble(nxg),flds_scalar_index_nx, NStateExp(ns), flds_scalar_name, flds_scalar_num, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - endif - - call shr_file_setLogUnit (shrlogunit) + call state_setscalar(dble(nyg),flds_scalar_index_ny, NStateExp(ns), flds_scalar_name, flds_scalar_num, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do end subroutine InitializeRealize @@ -323,56 +310,32 @@ subroutine ModelAdvance(gcomp, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Clock) :: clock - type(ESMF_State) :: exportState - integer :: n - integer :: shrlogunit ! original log unit - real(r8), pointer :: dataptr(:) character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) ' !------------------------------------------------------------------------------- rc = ESMF_SUCCESS call memcheck(subname, 3, mastertask) - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) - - !-------------------------------- - ! Pack export state - !-------------------------------- - - call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) + call state_setexport(rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call state_setexport(exportState, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - ! diagnostics - if (dbug > 1) then - call state_diagnose(exportState,subname//':ES',rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - endif - - call shr_file_setLogUnit (shrlogunit) - end subroutine ModelAdvance - !=============================================================================== - subroutine state_setexport(exportState, rc) + !=============================================================================== + subroutine state_setexport(rc) ! input/output variables - type(ESMF_State) , intent(inout) :: exportState integer, intent(out) :: rc ! local variables - integer :: n, nf, nind + integer :: n, nf, nind, ns real(r8), pointer :: lat(:) real(r8), pointer :: lon(:) integer :: spatialDim integer :: numOwnedElements real(R8), pointer :: ownedElemCoords(:) + character(len=*),parameter :: subname=trim(modName)//':(state_setexport) ' !-------------------------------------------------- - rc = ESMF_SUCCESS call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) @@ -389,17 +352,23 @@ subroutine state_setexport(exportState, rc) end do ! Start from index 2 in order to skip the scalar field - do nf = 2,fldsFrGlc_num - if (fldsFrGlc(nf)%ungridded_ubound == 0) then - call field_setexport(exportState, trim(fldsFrGlc(nf)%stdname), lon, lat, nf=nf, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - else - do nind = 1,fldsFrGlc(nf)%ungridded_ubound - call field_setexport(exportState, trim(fldsFrGlc(nf)%stdname), lon, lat, nf=nf+nind-1, & - ungridded_index=nind, rc=rc) + do ns = 1,num_icesheets + do nf = 2,fldsFrGlc_num + if (fldsFrGlc(nf)%ungridded_ubound == 0) then + call field_setexport(NStateExp(ns), trim(fldsFrGlc(nf)%stdname), lon, lat, nf=nf, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - end do - end if + else + do nind = 1,fldsFrGlc(nf)%ungridded_ubound + call field_setexport(NStateExp(ns), trim(fldsFrGlc(nf)%stdname), lon, lat, nf=nf+nind-1, & + ungridded_index=nind, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end do + end if + end do + if (dbug > 1) then + call State_diagnose(NStateExp(ns), trim(subname)//':ES',rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + endif end do deallocate(lon) diff --git a/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 index 0d08bf68b..33c28b247 100644 --- a/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 @@ -269,6 +269,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_topo_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_ice_covered_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) call fld_list_add(fldsToLnd_num, fldsTolnd, 'Flgg_hflx_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) + call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_icemask') + call fld_list_add(fldsToLnd_num, fldsTolnd, 'Sg_icemask_coupled_fluxes') do n = 1,fldsFrLnd_num if (mastertask) write(logunit,*)'Advertising From Xlnd ',trim(fldsFrLnd(n)%stdname) From 2aaf562723f395f6728c75aacda84306dd34fb65 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 2 Dec 2020 14:04:06 -0700 Subject: [PATCH 09/24] add SetVM calls to nuopc x components --- .../xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 | 6 +++--- .../xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 | 6 +++--- .../xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 | 6 +++--- .../xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 | 8 ++++---- .../xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 | 6 +++--- .../xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 | 6 +++--- .../xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 | 8 ++++---- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 index 7386883d6..f8480b586 100644 --- a/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 @@ -11,7 +11,7 @@ module atm_comp_nuopc 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 + use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit @@ -24,7 +24,7 @@ module atm_comp_nuopc private ! except public :: SetServices - + public :: SetVM !-------------------------------------------------------------------------- ! Private module data !-------------------------------------------------------------------------- @@ -441,7 +441,7 @@ subroutine state_setexport(exportState, rc) lat(n) = ownedElemCoords(2*n) end do - ! Start from index 2 in order to Skip the scalar field here + ! Start from index 2 in order to Skip the scalar field here do nf = 2,fldsFrAtm_num if (fldsFrAtm(nf)%ungridded_ubound == 0) then call field_setexport(exportState, trim(fldsFrAtm(nf)%stdname), lon, lat, nf=nf, rc=rc) diff --git a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 index 8bf8b8b6e..a5d9341f7 100644 --- a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 @@ -11,7 +11,7 @@ module glc_comp_nuopc 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 + use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit @@ -24,7 +24,7 @@ module glc_comp_nuopc private ! except public :: SetServices - + public :: SetVM !-------------------------------------------------------------------------- ! Private module data !-------------------------------------------------------------------------- @@ -388,7 +388,7 @@ subroutine state_setexport(exportState, rc) lat(n) = ownedElemCoords(2*n) end do - ! Start from index 2 in order to skip the scalar field + ! Start from index 2 in order to skip the scalar field do nf = 2,fldsFrGlc_num if (fldsFrGlc(nf)%ungridded_ubound == 0) then call field_setexport(exportState, trim(fldsFrGlc(nf)%stdname), lon, lat, nf=nf, rc=rc) diff --git a/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 index d531da74a..7a17ae2bd 100644 --- a/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 @@ -11,7 +11,7 @@ module ice_comp_nuopc 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 + use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit @@ -24,7 +24,7 @@ module ice_comp_nuopc private ! except public :: SetServices - + public :: SetVM !-------------------------------------------------------------------------- ! Private module data !-------------------------------------------------------------------------- @@ -453,7 +453,7 @@ subroutine state_setexport(exportState, rc) lat(n) = ownedElemCoords(2*n) end do - ! Start from index 2 in order to skip the scalar field + ! Start from index 2 in order to skip the scalar field do nf = 2,fldsFrIce_num if (fldsFrIce(nf)%ungridded_ubound == 0) then call field_setexport(exportState, trim(fldsFrIce(nf)%stdname), lon, lat, nf=nf, rc=rc) diff --git a/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 index 0d08bf68b..a1055c3ed 100644 --- a/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 @@ -11,7 +11,7 @@ module lnd_comp_nuopc 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 + use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit @@ -24,7 +24,7 @@ module lnd_comp_nuopc private ! except public :: SetServices - + public :: SetVM !-------------------------------------------------------------------------- ! Private module data !-------------------------------------------------------------------------- @@ -40,7 +40,7 @@ module lnd_comp_nuopc type (fld_list_type) :: fldsToLnd(fldsMax) type (fld_list_type) :: fldsFrLnd(fldsMax) integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost - integer :: glc_nec + integer :: glc_nec type(ESMF_Mesh) :: mesh integer :: nxg ! global dim i-direction @@ -468,7 +468,7 @@ subroutine state_setexport(exportState, rc) lat(n) = ownedElemCoords(2*n) end do - ! Start from index 2 in order to Skip the scalar field here + ! Start from index 2 in order to Skip the scalar field here do nf = 2,fldsFrLnd_num if (fldsFrLnd(nf)%ungridded_ubound == 0) then call field_setexport(exportState, trim(fldsFrLnd(nf)%stdname), lon, lat, nf=nf, rc=rc) diff --git a/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 index 5d6b04ec9..b57b6feec 100644 --- a/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 @@ -11,7 +11,7 @@ module ocn_comp_nuopc 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 + use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit @@ -24,7 +24,7 @@ module ocn_comp_nuopc private ! except public :: SetServices - + public :: SetVM !-------------------------------------------------------------------------- ! Private module data !-------------------------------------------------------------------------- @@ -378,7 +378,7 @@ subroutine state_setexport(exportState, rc) lat(n) = ownedElemCoords(2*n) end do - ! Start from index 2 in order to Skip the scalar field here + ! Start from index 2 in order to Skip the scalar field here do nf = 2,fldsFrOcn_num if (fldsFrOcn(nf)%ungridded_ubound == 0) then call field_setexport(exportState, trim(fldsFrOcn(nf)%stdname), lon, lat, nf=nf, rc=rc) diff --git a/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 index d62bc458e..87e5dad9a 100644 --- a/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 @@ -11,7 +11,7 @@ module rof_comp_nuopc 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 + use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit @@ -24,7 +24,7 @@ module rof_comp_nuopc private ! except public :: SetServices - + public :: SetVM !-------------------------------------------------------------------------- ! Private module data !-------------------------------------------------------------------------- @@ -387,7 +387,7 @@ subroutine state_setexport(exportState, rc) lat(n) = ownedElemCoords(2*n) end do - ! Start from index 2 in order to skip the scalar field + ! Start from index 2 in order to skip the scalar field do nf = 2,fldsFrRof_num if (fldsFrRof(nf)%ungridded_ubound == 0) then call field_setexport(exportState, trim(fldsFrRof(nf)%stdname), lon, lat, nf=nf, rc=rc) diff --git a/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 index 2bb08fc29..938652b5b 100644 --- a/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 @@ -11,7 +11,7 @@ module wav_comp_nuopc 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 + use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit @@ -24,7 +24,7 @@ module wav_comp_nuopc private ! except public :: SetServices - + public :: SetVM !-------------------------------------------------------------------------- ! Private module data !-------------------------------------------------------------------------- @@ -359,7 +359,7 @@ subroutine state_setexport(exportState, rc) !-------------------------------------------------- rc = ESMF_SUCCESS - + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return allocate(ownedElemCoords(spatialDim*numOwnedElements)) @@ -374,7 +374,7 @@ subroutine state_setexport(exportState, rc) end do nfstart = 0 ! for fields that have ubound > 0 - do nf = 2,fldsFrWav_num ! Start from index 2 in order to skip the scalar field + do nf = 2,fldsFrWav_num ! Start from index 2 in order to skip the scalar field ubound = fldsFrWav(nf)%ungridded_ubound if (ubound == 0) then call field_setexport(exportState, trim(fldsFrWav(nf)%stdname), lon, lat, nf=nf, rc=rc) From 894502a42f96485a7137faf3e8d8530b4fe76eb3 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 10 Mar 2021 10:15:39 -0700 Subject: [PATCH 10/24] nag_port for nuopc - wip --- src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 index 500da43e6..1ad724b97 100644 --- a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 @@ -220,13 +220,13 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Now advertise import and export fields fields do ns = 1,num_icesheets - if (mastertask) write(logunit,*)'Advertising To Xglc ',trim(fldsToGlc(n)%stdname) + if (mastertask) write(logunit,*)'Advertising To Xglc ',trim(fldsToGlc(ns)%stdname) do nf = 1,fldsToGlc_num call NUOPC_Advertise(NStateImp(ns), standardName=fldsToGlc(nf)%stdname, & TransferOfferGeomObject='will provide', rc=rc) if (chkErr(rc,__LINE__,u_FILE_u)) return end do - if (mastertask) write(logunit,*)'Advertising From Xglc ',trim(fldsFrGlc(n)%stdname) + if (mastertask) write(logunit,*)'Advertising From Xglc ',trim(fldsFrGlc(ns)%stdname) do nf = 1,fldsFrGlc_num call NUOPC_Advertise(NStateExp(ns), standardName=fldsFrGlc(nf)%stdname, & TransferOfferGeomObject='will provide', rc=rc) From 6cc9235fb8f35dbc491edb48121de6c446beca28 Mon Sep 17 00:00:00 2001 From: James Foucar Date: Mon, 21 Jun 2021 09:33:43 -0600 Subject: [PATCH 11/24] Change over all remaining scripts to python3 Except the 'tools' subdirectory. Not sure that code is ready for py3 --- src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml | 2 +- src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml | 2 +- src/components/xcpl_comps_nuopc/xice/cime_config/buildnml | 2 +- src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml | 2 +- src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml | 2 +- src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml | 2 +- src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml index 50a814c79..f8308e8a7 100755 --- a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ build data model library diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml index 64077a469..2394c6c87 100755 --- a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ build data model library diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml index e023dc7c6..21dd29be0 100755 --- a/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ build data model library diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml index 760d75e5c..655cc315d 100755 --- a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ build data model library diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml index c6f945376..16abbabe5 100755 --- a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ build data model library diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml index 182cf39ef..7889ed07f 100755 --- a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ build data model library diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml index b7b8576ba..6838bc010 100755 --- a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ build data model library From 9bfe440645a83dd04f7b5609175eae02ec1a9246 Mon Sep 17 00:00:00 2001 From: Jason Boutte Date: Fri, 15 Oct 2021 02:48:13 +0000 Subject: [PATCH 12/24] Moves rest of required code/data files under CIME module --- .../data}/components/xcpl_comps_nuopc/xatm/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake | 0 .../data}/components/xcpl_comps_nuopc/xatm/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xatm/cime_config/config_component.xml | 0 .../data}/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 | 0 .../data}/components/xcpl_comps_nuopc/xglc/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake | 0 .../data}/components/xcpl_comps_nuopc/xglc/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xglc/cime_config/config_component.xml | 0 .../data}/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 | 0 .../data}/components/xcpl_comps_nuopc/xice/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake | 0 .../data}/components/xcpl_comps_nuopc/xice/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xice/cime_config/config_component.xml | 0 .../data}/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 | 0 .../data}/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake | 0 .../data}/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xlnd/cime_config/config_component.xml | 0 .../data}/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 | 0 .../data}/components/xcpl_comps_nuopc/xocn/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake | 0 .../data}/components/xcpl_comps_nuopc/xocn/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xocn/cime_config/config_component.xml | 0 .../data}/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 | 0 .../data}/components/xcpl_comps_nuopc/xrof/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake | 0 .../data}/components/xcpl_comps_nuopc/xrof/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xrof/cime_config/config_component.xml | 0 .../data}/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 | 0 .../data}/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 | 0 .../data}/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 | 0 .../data}/components/xcpl_comps_nuopc/xwav/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake | 0 .../data}/components/xcpl_comps_nuopc/xwav/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xwav/cime_config/config_component.xml | 0 .../data}/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 | 0 37 files changed, 0 insertions(+), 0 deletions(-) rename {src => CIME/data}/components/xcpl_comps_nuopc/xatm/cime_config/buildlib (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xatm/cime_config/buildnml (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xglc/cime_config/buildlib (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xglc/cime_config/buildnml (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xice/cime_config/buildlib (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xice/cime_config/buildnml (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xocn/cime_config/buildlib (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xocn/cime_config/buildnml (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xrof/cime_config/buildlib (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xrof/cime_config/buildnml (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xwav/cime_config/buildlib (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xwav/cime_config/buildnml (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml (100%) rename {src => CIME/data}/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 (100%) diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib b/CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildlib similarity index 100% rename from src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib rename to CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildlib diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake b/CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake similarity index 100% rename from src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake rename to CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml b/CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildnml similarity index 100% rename from src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml rename to CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildnml diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml b/CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml similarity index 100% rename from src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml rename to CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml diff --git a/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 b/CIME/data/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 similarity index 100% rename from src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 rename to CIME/data/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib b/CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildlib similarity index 100% rename from src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib rename to CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildlib diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake b/CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake similarity index 100% rename from src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake rename to CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml b/CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildnml similarity index 100% rename from src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml rename to CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildnml diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml b/CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml similarity index 100% rename from src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml rename to CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml diff --git a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 b/CIME/data/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 similarity index 100% rename from src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 rename to CIME/data/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib b/CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildlib similarity index 100% rename from src/components/xcpl_comps_nuopc/xice/cime_config/buildlib rename to CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildlib diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake b/CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake similarity index 100% rename from src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake rename to CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml b/CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildnml similarity index 100% rename from src/components/xcpl_comps_nuopc/xice/cime_config/buildnml rename to CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildnml diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml b/CIME/data/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml similarity index 100% rename from src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml rename to CIME/data/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml diff --git a/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 b/CIME/data/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 similarity index 100% rename from src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 rename to CIME/data/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib b/CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib similarity index 100% rename from src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib rename to CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake b/CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake similarity index 100% rename from src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake rename to CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml b/CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml similarity index 100% rename from src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml rename to CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml b/CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml similarity index 100% rename from src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml rename to CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml diff --git a/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 b/CIME/data/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 similarity index 100% rename from src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 rename to CIME/data/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib b/CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildlib similarity index 100% rename from src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib rename to CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildlib diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake b/CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake similarity index 100% rename from src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake rename to CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml b/CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildnml similarity index 100% rename from src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml rename to CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildnml diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml b/CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml similarity index 100% rename from src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml rename to CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml diff --git a/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 b/CIME/data/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 similarity index 100% rename from src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 rename to CIME/data/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib b/CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildlib similarity index 100% rename from src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib rename to CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildlib diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake b/CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake similarity index 100% rename from src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake rename to CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml b/CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildnml similarity index 100% rename from src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml rename to CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildnml diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml b/CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml similarity index 100% rename from src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml rename to CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml diff --git a/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 b/CIME/data/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 similarity index 100% rename from src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 rename to CIME/data/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 diff --git a/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 b/CIME/data/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 similarity index 100% rename from src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 rename to CIME/data/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 diff --git a/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 b/CIME/data/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 similarity index 100% rename from src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 rename to CIME/data/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib b/CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildlib similarity index 100% rename from src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib rename to CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildlib diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake b/CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake similarity index 100% rename from src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake rename to CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml b/CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildnml similarity index 100% rename from src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml rename to CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildnml diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml b/CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml similarity index 100% rename from src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml rename to CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml diff --git a/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 b/CIME/data/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 similarity index 100% rename from src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 rename to CIME/data/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 From ecd9e198f3aa406fc09b367b4a6133b0612c9078 Mon Sep 17 00:00:00 2001 From: Jason Boutte Date: Tue, 9 Nov 2021 21:45:33 +0000 Subject: [PATCH 13/24] Initial pre-commit application --- .../xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 | 2 +- .../xcpl_comps_nuopc/xshare/dead_methods_mod.F90 | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 index 1ad724b97..07d8ecf14 100644 --- a/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 +++ b/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 @@ -351,7 +351,7 @@ subroutine state_setexport(rc) lat(n) = ownedElemCoords(2*n) end do - ! Start from index 2 in order to skip the scalar field + ! Start from index 2 in order to skip the scalar field do ns = 1,num_icesheets do nf = 2,fldsFrGlc_num if (fldsFrGlc(nf)%ungridded_ubound == 0) then diff --git a/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 b/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 index d8b55abd8..7d88a7fce 100644 --- a/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 +++ b/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 @@ -11,8 +11,8 @@ module dead_methods_mod use ESMF , only : ESMF_GeomType_Flag, ESMF_FieldStatus_Flag use ESMF , only : ESMF_Mesh, ESMF_MeshGet use ESMF , only : ESMF_GEOMTYPE_MESH, ESMF_GEOMTYPE_GRID, ESMF_FIELDSTATUS_COMPLETE - use ESMF , only : ESMF_Clock, ESMF_ClockCreate, ESMF_ClockGet, ESMF_ClockSet - use ESMF , only : ESMF_ClockPrint, ESMF_ClockAdvance + use ESMF , only : ESMF_Clock, ESMF_ClockCreate, ESMF_ClockGet, ESMF_ClockSet + use ESMF , only : ESMF_ClockPrint, ESMF_ClockAdvance use ESMF , only : ESMF_Alarm, ESMF_AlarmCreate, ESMF_AlarmGet, ESMF_AlarmSet use ESMF , only : ESMF_Calendar, ESMF_CALKIND_NOLEAP, ESMF_CALKIND_GREGORIAN use ESMF , only : ESMF_Time, ESMF_TimeGet, ESMF_TimeSet @@ -34,7 +34,7 @@ module dead_methods_mod public :: state_getscalar public :: state_setscalar public :: state_diagnose - public :: alarmInit + public :: alarmInit public :: chkerr private :: timeInit @@ -61,7 +61,7 @@ module dead_methods_mod optMonthly = "monthly" , & optYearly = "yearly" , & optDate = "date" , & - optIfdays0 = "ifdays0" + optIfdays0 = "ifdays0" ! Module data integer, parameter :: SecPerDay = 86400 ! Seconds per day @@ -422,7 +422,7 @@ subroutine field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) call ESMF_MeshGet(lmesh, numOwnedNodes=nnodes, numOwnedElements=nelements, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (nnodes == 0 .and. nelements == 0) lrank = 0 - else + else call ESMF_LogWrite(trim(subname)//": ERROR geomtype not supported ", & ESMF_LOGMSG_INFO, rc=rc) rc = ESMF_FAILURE @@ -783,7 +783,7 @@ end subroutine alarmInit subroutine timeInit( Time, ymd, cal, tod, rc) - ! Create the ESMF_Time object corresponding to the given input time, + ! Create the ESMF_Time object corresponding to the given input time, ! given in YMD (Year Month Day) and TOD (Time-of-day) format. ! Set the time by an integer as YYYYMMDD and integer seconds in the day From 21a3818351446808600f9ecb93389a0789136b5d Mon Sep 17 00:00:00 2001 From: Jason Boutte Date: Wed, 10 Nov 2021 01:13:00 +0000 Subject: [PATCH 14/24] Adds black to pre-commit --- src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml | 7 ++++++- src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml | 7 ++++++- src/components/xcpl_comps_nuopc/xice/cime_config/buildnml | 7 ++++++- src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml | 7 ++++++- src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml | 7 ++++++- src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml | 7 ++++++- src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml | 7 ++++++- 7 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml index f8308e8a7..1115818ef 100755 --- a/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml @@ -6,22 +6,27 @@ build data model library import sys, os -_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +_CIMEROOT = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", ".." +) sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * from CIME.buildnml import build_xcpl_nml, parse_input from CIME.case import Case + def buildnml(case, caseroot, compname): if compname != "xatm": raise AttributeError build_xcpl_nml(case, caseroot, compname) + def _main_func(): caseroot = parse_input(sys.argv) with Case(caseroot) as case: buildnml(case, caseroot, "xatm") + if __name__ == "__main__": _main_func() diff --git a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml index 2394c6c87..93b5a7028 100755 --- a/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml @@ -6,22 +6,27 @@ build data model library import sys, os -_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +_CIMEROOT = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", ".." +) sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * from CIME.buildnml import build_xcpl_nml, parse_input from CIME.case import Case + def buildnml(case, caseroot, compname): if compname != "xglc": raise AttributeError build_xcpl_nml(case, caseroot, compname) + def _main_func(): caseroot = parse_input(sys.argv) with Case(caseroot) as case: buildnml(case, caseroot, "xglc") + if __name__ == "__main__": _main_func() diff --git a/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml index 21dd29be0..e54d7ae50 100755 --- a/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml @@ -6,22 +6,27 @@ build data model library import sys, os -_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +_CIMEROOT = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", ".." +) sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * from CIME.buildnml import build_xcpl_nml, parse_input from CIME.case import Case + def buildnml(case, caseroot, compname): if compname != "xice": raise AttributeError build_xcpl_nml(case, caseroot, compname) + def _main_func(): caseroot = parse_input(sys.argv) with Case(caseroot) as case: buildnml(case, caseroot, "xice") + if __name__ == "__main__": _main_func() diff --git a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml index 655cc315d..7d85bc7e1 100755 --- a/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml @@ -6,22 +6,27 @@ build data model library import sys, os -_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +_CIMEROOT = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", ".." +) sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * from CIME.buildnml import build_xcpl_nml, parse_input from CIME.case import Case + def buildnml(case, caseroot, compname): if compname != "xlnd": raise AttributeError build_xcpl_nml(case, caseroot, compname) + def _main_func(): caseroot = parse_input(sys.argv) with Case(caseroot) as case: buildnml(case, caseroot, "xlnd") + if __name__ == "__main__": _main_func() diff --git a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml index 16abbabe5..8e751125a 100755 --- a/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml @@ -6,22 +6,27 @@ build data model library import sys, os -_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +_CIMEROOT = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", ".." +) sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * from CIME.buildnml import build_xcpl_nml, parse_input from CIME.case import Case + def buildnml(case, caseroot, compname): if compname != "xocn": raise AttributeError build_xcpl_nml(case, caseroot, compname) + def _main_func(): caseroot = parse_input(sys.argv) with Case(caseroot) as case: buildnml(case, caseroot, "xocn") + if __name__ == "__main__": _main_func() diff --git a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml index 7889ed07f..323b7f347 100755 --- a/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml @@ -6,22 +6,27 @@ build data model library import sys, os -_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +_CIMEROOT = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", ".." +) sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * from CIME.buildnml import build_xcpl_nml, parse_input from CIME.case import Case + def buildnml(case, caseroot, compname): if compname != "xrof": raise AttributeError build_xcpl_nml(case, caseroot, compname) + def _main_func(): caseroot = parse_input(sys.argv) with Case(caseroot) as case: buildnml(case, caseroot, "xrof") + if __name__ == "__main__": _main_func() diff --git a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml index 6838bc010..100f0243b 100755 --- a/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml +++ b/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml @@ -6,22 +6,27 @@ build data model library import sys, os -_CIMEROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","..") +_CIMEROOT = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", ".." +) sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) from standard_script_setup import * from CIME.buildnml import build_xcpl_nml, parse_input from CIME.case import Case + def buildnml(case, caseroot, compname): if compname != "xwav": raise AttributeError build_xcpl_nml(case, caseroot, compname) + def _main_func(): caseroot = parse_input(sys.argv) with Case(caseroot) as case: buildnml(case, caseroot, "xwav") + if __name__ == "__main__": _main_func() From 59adbad66f453cd76ac987aef9ab4faa21bd0592 Mon Sep 17 00:00:00 2001 From: Jason Boutte Date: Wed, 19 Jan 2022 07:27:41 +0000 Subject: [PATCH 15/24] Fixes for failing unittests --- CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildnml | 2 +- CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildnml | 2 +- CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildnml | 2 +- CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml | 2 +- CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildnml | 2 +- CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildnml | 2 +- CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildnml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildnml b/CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildnml index 1115818ef..e7efcd46b 100755 --- a/CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildnml +++ b/CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildnml @@ -9,7 +9,7 @@ import sys, os _CIMEROOT = os.path.join( os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", ".." ) -sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) +sys.path.append(os.path.join(_CIMEROOT, "CIME", "Tools")) from standard_script_setup import * from CIME.buildnml import build_xcpl_nml, parse_input diff --git a/CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildnml b/CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildnml index 93b5a7028..a90f7a189 100755 --- a/CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildnml +++ b/CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildnml @@ -9,7 +9,7 @@ import sys, os _CIMEROOT = os.path.join( os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", ".." ) -sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) +sys.path.append(os.path.join(_CIMEROOT, "CIME", "Tools")) from standard_script_setup import * from CIME.buildnml import build_xcpl_nml, parse_input diff --git a/CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildnml b/CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildnml index e54d7ae50..7d141edd6 100755 --- a/CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildnml +++ b/CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildnml @@ -9,7 +9,7 @@ import sys, os _CIMEROOT = os.path.join( os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", ".." ) -sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) +sys.path.append(os.path.join(_CIMEROOT, "CIME", "Tools")) from standard_script_setup import * from CIME.buildnml import build_xcpl_nml, parse_input diff --git a/CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml b/CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml index 7d85bc7e1..72e822771 100755 --- a/CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml +++ b/CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml @@ -9,7 +9,7 @@ import sys, os _CIMEROOT = os.path.join( os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", ".." ) -sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) +sys.path.append(os.path.join(_CIMEROOT, "CIME", "Tools")) from standard_script_setup import * from CIME.buildnml import build_xcpl_nml, parse_input diff --git a/CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildnml b/CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildnml index 8e751125a..7158056b4 100755 --- a/CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildnml +++ b/CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildnml @@ -9,7 +9,7 @@ import sys, os _CIMEROOT = os.path.join( os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", ".." ) -sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) +sys.path.append(os.path.join(_CIMEROOT, "CIME", "Tools")) from standard_script_setup import * from CIME.buildnml import build_xcpl_nml, parse_input diff --git a/CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildnml b/CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildnml index 323b7f347..bf23e8913 100755 --- a/CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildnml +++ b/CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildnml @@ -9,7 +9,7 @@ import sys, os _CIMEROOT = os.path.join( os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", ".." ) -sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) +sys.path.append(os.path.join(_CIMEROOT, "CIME", "Tools")) from standard_script_setup import * from CIME.buildnml import build_xcpl_nml, parse_input diff --git a/CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildnml b/CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildnml index 100f0243b..1ea9dc3a5 100755 --- a/CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildnml +++ b/CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildnml @@ -9,7 +9,7 @@ import sys, os _CIMEROOT = os.path.join( os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "..", ".." ) -sys.path.append(os.path.join(_CIMEROOT, "scripts", "Tools")) +sys.path.append(os.path.join(_CIMEROOT, "CIME", "Tools")) from standard_script_setup import * from CIME.buildnml import build_xcpl_nml, parse_input From ab81eebdc26a198f0d7ea031bf0fc7614514f0d6 Mon Sep 17 00:00:00 2001 From: Jason Boutte Date: Thu, 27 Jan 2022 23:35:29 +0000 Subject: [PATCH 16/24] Moves CIME/data/components to CIME/data/src/components --- .../components/xcpl_comps_nuopc/xatm/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake | 0 .../components/xcpl_comps_nuopc/xatm/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xatm/cime_config/config_component.xml | 0 .../components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 | 0 .../components/xcpl_comps_nuopc/xglc/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake | 0 .../components/xcpl_comps_nuopc/xglc/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xglc/cime_config/config_component.xml | 0 .../components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 | 0 .../components/xcpl_comps_nuopc/xice/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake | 0 .../components/xcpl_comps_nuopc/xice/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xice/cime_config/config_component.xml | 0 .../components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 | 0 .../components/xcpl_comps_nuopc/xlnd/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake | 0 .../components/xcpl_comps_nuopc/xlnd/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xlnd/cime_config/config_component.xml | 0 .../components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 | 0 .../components/xcpl_comps_nuopc/xocn/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake | 0 .../components/xcpl_comps_nuopc/xocn/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xocn/cime_config/config_component.xml | 0 .../components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 | 0 .../components/xcpl_comps_nuopc/xrof/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake | 0 .../components/xcpl_comps_nuopc/xrof/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xrof/cime_config/config_component.xml | 0 .../components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 | 0 .../components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 | 0 .../components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 | 0 .../components/xcpl_comps_nuopc/xwav/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake | 0 .../components/xcpl_comps_nuopc/xwav/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xwav/cime_config/config_component.xml | 0 .../components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 | 0 37 files changed, 0 insertions(+), 0 deletions(-) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xatm/cime_config/buildlib (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xatm/cime_config/buildnml (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xglc/cime_config/buildlib (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xglc/cime_config/buildnml (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xice/cime_config/buildlib (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xice/cime_config/buildnml (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xocn/cime_config/buildlib (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xocn/cime_config/buildnml (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xrof/cime_config/buildlib (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xrof/cime_config/buildnml (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xwav/cime_config/buildlib (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xwav/cime_config/buildnml (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml (100%) rename CIME/data/{ => src}/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 (100%) diff --git a/CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildlib b/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildlib rename to CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib diff --git a/CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake b/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake rename to CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake diff --git a/CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildnml b/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/buildnml rename to CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml diff --git a/CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml b/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml rename to CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml diff --git a/CIME/data/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 b/CIME/data/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 rename to CIME/data/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 diff --git a/CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildlib b/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildlib rename to CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib diff --git a/CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake b/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake rename to CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake diff --git a/CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildnml b/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/buildnml rename to CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml diff --git a/CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml b/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml rename to CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml diff --git a/CIME/data/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 b/CIME/data/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 rename to CIME/data/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 diff --git a/CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildlib b/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildlib rename to CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib diff --git a/CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake b/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake rename to CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake diff --git a/CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildnml b/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xice/cime_config/buildnml rename to CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml diff --git a/CIME/data/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml b/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml rename to CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml diff --git a/CIME/data/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 b/CIME/data/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 rename to CIME/data/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 diff --git a/CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib b/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib rename to CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib diff --git a/CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake b/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake rename to CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake diff --git a/CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml b/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml rename to CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml diff --git a/CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml b/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml rename to CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml diff --git a/CIME/data/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 b/CIME/data/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 rename to CIME/data/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 diff --git a/CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildlib b/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildlib rename to CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib diff --git a/CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake b/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake rename to CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake diff --git a/CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildnml b/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/buildnml rename to CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml diff --git a/CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml b/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml rename to CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml diff --git a/CIME/data/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 b/CIME/data/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 rename to CIME/data/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 diff --git a/CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildlib b/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildlib rename to CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib diff --git a/CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake b/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake rename to CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake diff --git a/CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildnml b/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/buildnml rename to CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml diff --git a/CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml b/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml rename to CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml diff --git a/CIME/data/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 b/CIME/data/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 rename to CIME/data/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 diff --git a/CIME/data/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 b/CIME/data/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 rename to CIME/data/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 diff --git a/CIME/data/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 b/CIME/data/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 rename to CIME/data/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 diff --git a/CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildlib b/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildlib rename to CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib diff --git a/CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake b/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake rename to CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake diff --git a/CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildnml b/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/buildnml rename to CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml diff --git a/CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml b/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml rename to CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml diff --git a/CIME/data/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 b/CIME/data/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 similarity index 100% rename from CIME/data/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 rename to CIME/data/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 From c27ed3acdf059a07152fc90f1b689496a52a4cd1 Mon Sep 17 00:00:00 2001 From: Jason Boutte Date: Fri, 28 Jan 2022 07:48:13 +0000 Subject: [PATCH 17/24] Fixes symlinks --- .../src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib | 2 +- .../components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake | 2 +- .../src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib | 2 +- .../components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake | 2 +- .../src/components/xcpl_comps_nuopc/xice/cime_config/buildlib | 2 +- .../components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake | 2 +- .../src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib | 2 +- .../components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake | 2 +- .../src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib | 2 +- .../components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake | 2 +- .../src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib | 2 +- .../components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake | 2 +- .../src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib | 2 +- .../components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib b/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib index 9601a6fa7..7766f77f5 120000 --- a/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib +++ b/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib @@ -1 +1 @@ -../../../../build_scripts/buildlib.internal_components \ No newline at end of file +../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake b/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake index 292ce33d2..7766f77f5 120000 --- a/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake +++ b/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake @@ -1 +1 @@ -../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file +../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib b/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib index 9601a6fa7..7766f77f5 120000 --- a/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib +++ b/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib @@ -1 +1 @@ -../../../../build_scripts/buildlib.internal_components \ No newline at end of file +../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake b/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake index 292ce33d2..7766f77f5 120000 --- a/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake +++ b/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake @@ -1 +1 @@ -../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file +../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib b/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib index 9601a6fa7..7766f77f5 120000 --- a/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib +++ b/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib @@ -1 +1 @@ -../../../../build_scripts/buildlib.internal_components \ No newline at end of file +../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake b/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake index 292ce33d2..7766f77f5 120000 --- a/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake +++ b/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake @@ -1 +1 @@ -../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file +../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib b/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib index 9601a6fa7..7766f77f5 120000 --- a/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib +++ b/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib @@ -1 +1 @@ -../../../../build_scripts/buildlib.internal_components \ No newline at end of file +../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake b/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake index 292ce33d2..7766f77f5 120000 --- a/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake +++ b/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake @@ -1 +1 @@ -../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file +../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib b/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib index 9601a6fa7..7766f77f5 120000 --- a/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib +++ b/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib @@ -1 +1 @@ -../../../../build_scripts/buildlib.internal_components \ No newline at end of file +../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake b/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake index 292ce33d2..7766f77f5 120000 --- a/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake +++ b/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake @@ -1 +1 @@ -../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file +../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib b/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib index 9601a6fa7..7766f77f5 120000 --- a/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib +++ b/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib @@ -1 +1 @@ -../../../../build_scripts/buildlib.internal_components \ No newline at end of file +../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake b/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake index 292ce33d2..7766f77f5 120000 --- a/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake +++ b/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake @@ -1 +1 @@ -../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file +../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib b/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib index 9601a6fa7..7766f77f5 120000 --- a/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib +++ b/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib @@ -1 +1 @@ -../../../../build_scripts/buildlib.internal_components \ No newline at end of file +../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake b/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake index 292ce33d2..7766f77f5 120000 --- a/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake +++ b/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake @@ -1 +1 @@ -../../../../build_scripts/buildlib_cmake.internal_components \ No newline at end of file +../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file From 6aeaf7ee7aa1ed61ee74ffb27de5d6511416a4f9 Mon Sep 17 00:00:00 2001 From: Jason Boutte Date: Thu, 17 Feb 2022 18:47:20 -0800 Subject: [PATCH 18/24] Moves externals, src and cprnc under CIME/non_py --- .../src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake | 0 .../src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xatm/cime_config/config_component.xml | 0 .../src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 | 0 .../src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake | 0 .../src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xglc/cime_config/config_component.xml | 0 .../src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 | 0 .../src/components/xcpl_comps_nuopc/xice/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake | 0 .../src/components/xcpl_comps_nuopc/xice/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xice/cime_config/config_component.xml | 0 .../src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 | 0 .../src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake | 0 .../src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xlnd/cime_config/config_component.xml | 0 .../src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 | 0 .../src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake | 0 .../src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xocn/cime_config/config_component.xml | 0 .../src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 | 0 .../src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake | 0 .../src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xrof/cime_config/config_component.xml | 0 .../src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 | 0 .../src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 | 0 .../src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 | 0 .../src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib | 0 .../components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake | 0 .../src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml | 0 .../xcpl_comps_nuopc/xwav/cime_config/config_component.xml | 0 .../src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 | 0 37 files changed, 0 insertions(+), 0 deletions(-) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml (100%) rename CIME/{data => non_py}/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 (100%) diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib b/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib rename to CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake b/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake rename to CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml b/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml rename to CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml b/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml rename to CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 rename to CIME/non_py/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib b/CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib rename to CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake b/CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake rename to CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml b/CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml rename to CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml b/CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml rename to CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 rename to CIME/non_py/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib b/CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib rename to CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake b/CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake rename to CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml b/CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml rename to CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml b/CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml rename to CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 rename to CIME/non_py/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib b/CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib rename to CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake b/CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake rename to CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml b/CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml rename to CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml b/CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml rename to CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 rename to CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib b/CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib rename to CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake b/CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake rename to CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml b/CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml rename to CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml b/CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml rename to CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 rename to CIME/non_py/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib b/CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib rename to CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake b/CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake rename to CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml b/CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml rename to CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml b/CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml rename to CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 rename to CIME/non_py/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 rename to CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 rename to CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib b/CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib rename to CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake b/CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake rename to CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml b/CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml rename to CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml b/CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml rename to CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml diff --git a/CIME/data/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 similarity index 100% rename from CIME/data/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 rename to CIME/non_py/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 From af693590813fcb9d08ae7ed02103219f365388aa Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 15 Jun 2022 13:30:02 -0600 Subject: [PATCH 19/24] add code to share the component logunit --- .../xshare/dead_methods_mod.F90 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 index 7d88a7fce..883532a0c 100644 --- a/CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 +++ b/CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 @@ -127,7 +127,8 @@ end subroutine get_component_instance !=============================================================================== subroutine set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) - + use ESMF, only : ESMF_GridCompGet, ESMF_LogWrite + use NUOPC, only: NUOPC_CompAttributeAdd, NUOPC_CompAttributeSet ! input/output variables type(ESMF_GridComp) :: gcomp logical, intent(in) :: mastertask @@ -136,8 +137,9 @@ subroutine set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) integer, intent(out) :: rc ! local variables - character(len=CL) :: diro + character(len=CL) :: diro, name character(len=CL) :: logfile + character(len=*), parameter :: subname ='('//__FILE__//': set_component_logging)' !----------------------------------------------------------------------- rc = ESMF_SUCCESS @@ -157,6 +159,17 @@ subroutine set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) call shr_file_setLogUnit (logunit) + call ESMF_GridCompGet(gcomp, name=name, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + call ESMF_LogWrite(trim(subname)//": setting logunit for component: "//trim(name), ESMF_LOGMSG_INFO) + + call NUOPC_CompAttributeAdd(gcomp, attrList=(/'logunit'/), rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call NUOPC_CompAttributeSet(gcomp, name='logunit',value=logunit, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + end subroutine set_component_logging !=============================================================================== From 923b9d0bda7c8e2487b868a32c8017c5ea785509 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Tue, 6 Dec 2022 15:52:07 -0700 Subject: [PATCH 20/24] update calculation of pes --- .../components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 index f8480b586..aff6bf0ba 100644 --- a/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 +++ b/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 @@ -304,7 +304,6 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! realize the actively coupled fields, now that a mesh is established ! 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. @@ -314,7 +313,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) numflds=fldsFrAtm_num, & flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & - tag=subname//':datmExport',& + tag=subname//':xatmExport',& mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -324,7 +323,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) numflds=fldsToAtm_num, & flds_scalar_name=flds_scalar_name, & flds_scalar_num=flds_scalar_num, & - tag=subname//':datmImport',& + tag=subname//':xatmImport',& mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return From 8b1346deea83e754d003720827a08559b06a3aea Mon Sep 17 00:00:00 2001 From: James Edwards Date: Sat, 29 Apr 2023 08:33:44 -0600 Subject: [PATCH 21/24] port to python 3.10, remove depricated shr_file_ log stuff --- .../xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 | 16 ++++++++-------- .../xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 | 2 +- .../xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 | 16 ++++++++-------- .../xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 | 16 ++++++++-------- .../xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 | 16 ++++++++-------- .../xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 | 16 ++++++++-------- .../xcpl_comps_nuopc/xshare/dead_methods_mod.F90 | 4 ++-- .../xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 | 16 ++++++++-------- 8 files changed, 51 insertions(+), 51 deletions(-) diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 index aff6bf0ba..64cd5b768 100644 --- a/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 +++ b/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 @@ -14,7 +14,7 @@ module atm_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use shr_log_mod , only : shr_log_getlogunit, shr_log_setlogunit use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock @@ -270,7 +270,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) end if ! Reset shr logging to original values - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) end subroutine InitializeAdvertise @@ -295,8 +295,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) rc = ESMF_SUCCESS ! Reset shr logging to my log file - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logUnit) + call shr_log_getLogUnit (shrlogunit) + call shr_log_setLogUnit (logUnit) ! generate the mesh call NUOPC_CompAttributeGet(gcomp, name='mesh_atm', value=cvalue, rc=rc) @@ -349,7 +349,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) end subroutine InitializeRealize @@ -375,8 +375,8 @@ subroutine ModelAdvance(gcomp, rc) end if call memcheck(subname, 3, mastertask) - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) + call shr_log_getLogUnit (shrlogunit) + call shr_log_setLogUnit (logunit) !-------------------------------- ! Pack export state @@ -405,7 +405,7 @@ subroutine ModelAdvance(gcomp, rc) endif endif - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) end subroutine ModelAdvance diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 index 07d8ecf14..4b498f8d9 100644 --- a/CIME/non_py/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 +++ b/CIME/non_py/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 @@ -14,7 +14,7 @@ module glc_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use shr_log_mod , only : shr_log_getlogunit, shr_log_setlogunit use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 index 7a17ae2bd..9185b8e53 100644 --- a/CIME/non_py/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 +++ b/CIME/non_py/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 @@ -14,7 +14,7 @@ module ice_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use shr_log_mod , only : shr_log_getlogunit, shr_log_setlogunit use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock @@ -281,7 +281,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Reset shr logging to original values !---------------------------------------------------------------------------- - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) end subroutine InitializeAdvertise @@ -305,8 +305,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! Reset shr logging to my log file !---------------------------------------------------------------------------- - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logUnit) + call shr_log_getLogUnit (shrlogunit) + call shr_log_setLogUnit (logUnit) !-------------------------------- ! generate the mesh @@ -368,7 +368,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) end subroutine InitializeRealize @@ -390,8 +390,8 @@ subroutine ModelAdvance(gcomp, rc) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) call memcheck(subname, 3, mastertask) - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) + call shr_log_getLogUnit (shrlogunit) + call shr_log_setLogUnit (logunit) !-------------------------------- ! Pack export state @@ -416,7 +416,7 @@ subroutine ModelAdvance(gcomp, rc) endif endif - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 index 8a5e539ac..a43215939 100644 --- a/CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 +++ b/CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 @@ -14,7 +14,7 @@ module lnd_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use shr_log_mod , only : shr_log_getlogunit, shr_log_setlogunit use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock @@ -292,7 +292,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Reset shr logging to original values !---------------------------------------------------------------------------- - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) end subroutine InitializeAdvertise @@ -319,8 +319,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! Reset shr logging to my log file !---------------------------------------------------------------------------- - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logUnit) + call shr_log_getLogUnit (shrlogunit) + call shr_log_setLogUnit (logUnit) !-------------------------------- ! generate the mesh @@ -382,7 +382,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) @@ -406,8 +406,8 @@ subroutine ModelAdvance(gcomp, rc) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO, rc=rc) call memcheck(subname, 3, mastertask) - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) + call shr_log_getLogUnit (shrlogunit) + call shr_log_setLogUnit (logunit) !-------------------------------- ! Pack export state @@ -432,7 +432,7 @@ subroutine ModelAdvance(gcomp, rc) endif endif - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 index b57b6feec..87f8ca251 100644 --- a/CIME/non_py/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 +++ b/CIME/non_py/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 @@ -14,7 +14,7 @@ module ocn_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use shr_log_mod , only : shr_log_getlogunit, shr_log_setlogunit use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock @@ -238,7 +238,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) end if ! Reset shr logging to original values - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) end subroutine InitializeAdvertise @@ -260,8 +260,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) rc = ESMF_SUCCESS ! Reset shr logging to my log file - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) + call shr_log_getLogUnit (shrlogunit) + call shr_log_setLogUnit (logunit) ! generate the mesh call NUOPC_CompAttributeGet(gcomp, name='mesh_ocn', value=cvalue, rc=rc) @@ -306,7 +306,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) end subroutine InitializeRealize @@ -328,8 +328,8 @@ subroutine ModelAdvance(gcomp, rc) call memcheck(subname, 3, mastertask) - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) + call shr_log_getLogUnit (shrlogunit) + call shr_log_setLogUnit (logunit) ! Pack export state call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) @@ -343,7 +343,7 @@ subroutine ModelAdvance(gcomp, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) end subroutine ModelAdvance diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 index 87e5dad9a..1b5b9dd49 100644 --- a/CIME/non_py/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 +++ b/CIME/non_py/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 @@ -14,7 +14,7 @@ module rof_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use shr_log_mod , only : shr_log_getlogunit, shr_log_setlogunit use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock @@ -229,7 +229,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Reset shr logging to original values !---------------------------------------------------------------------------- - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) end subroutine InitializeAdvertise @@ -251,8 +251,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) rc = ESMF_SUCCESS ! Reset shr logging to my log file - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logUnit) + call shr_log_getLogUnit (shrlogunit) + call shr_log_setLogUnit (logUnit) ! generate the mesh @@ -304,7 +304,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) end subroutine InitializeRealize @@ -329,8 +329,8 @@ subroutine ModelAdvance(gcomp, rc) end if call memcheck(subname, 3, mastertask) - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) + call shr_log_getLogUnit (shrlogunit) + call shr_log_setLogUnit (logunit) ! Pack export state call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) @@ -348,7 +348,7 @@ subroutine ModelAdvance(gcomp, rc) endif endif - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) if (dbug > 5) then call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO, rc=rc) diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 index 883532a0c..a9ad38e24 100644 --- a/CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 +++ b/CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 @@ -22,7 +22,7 @@ module dead_methods_mod use NUOPC_Model , only : NUOPC_ModelGet use shr_kind_mod , only : r8 => shr_kind_r8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_sys_mod , only : shr_sys_abort - use shr_file_mod , only : shr_file_setlogunit, shr_file_getLogUnit + use shr_log_mod , only : shr_log_setlogunit, shr_log_getLogUnit implicit none private @@ -157,7 +157,7 @@ subroutine set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) logUnit = 6 endif - call shr_file_setLogUnit (logunit) + call shr_log_setLogUnit (logunit) call ESMF_GridCompGet(gcomp, name=name, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 b/CIME/non_py/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 index 938652b5b..aa4d982e5 100644 --- a/CIME/non_py/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 +++ b/CIME/non_py/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 @@ -14,7 +14,7 @@ module wav_comp_nuopc use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_sys_mod , only : shr_sys_abort use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit + use shr_log_mod , only : shr_log_getlogunit, shr_log_setlogunit use dead_methods_mod , only : chkerr, state_setscalar, state_diagnose, alarmInit, memcheck use dead_methods_mod , only : set_component_logging, get_component_instance, log_clock_advance use dead_nuopc_mod , only : dead_read_inparms, ModelInitPhase, ModelSetRunClock @@ -228,7 +228,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return ! Reset shr logging to original values - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) end subroutine InitializeAdvertise @@ -250,8 +250,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) rc = ESMF_SUCCESS ! Reset shr logging to my log file - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) + call shr_log_getLogUnit (shrlogunit) + call shr_log_setLogUnit (logunit) ! generate the mesh call NUOPC_CompAttributeGet(gcomp, name='mesh_wav', value=cvalue, rc=rc) @@ -296,7 +296,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return endif - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) end subroutine InitializeRealize @@ -318,8 +318,8 @@ subroutine ModelAdvance(gcomp, rc) call memcheck(subname, 3, mastertask) - call shr_file_getLogUnit (shrlogunit) - call shr_file_setLogUnit (logunit) + call shr_log_getLogUnit (shrlogunit) + call shr_log_setLogUnit (logunit) ! Pack export state call NUOPC_ModelGet(gcomp, modelClock=clock, exportState=exportState, rc=rc) @@ -337,7 +337,7 @@ subroutine ModelAdvance(gcomp, rc) endif endif - call shr_file_setLogUnit (shrlogunit) + call shr_log_setLogUnit (shrlogunit) end subroutine ModelAdvance From ff312b51a4b2c4d80758fc31688242e360849e43 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Mon, 2 Mar 2026 13:09:08 -0700 Subject: [PATCH 22/24] Move mediator test comps to a top-level directory --- .../xcpl_comps_nuopc => med_test_comps}/xatm/cime_config/buildlib | 0 .../xatm/cime_config/buildlib_cmake | 0 .../xcpl_comps_nuopc => med_test_comps}/xatm/cime_config/buildnml | 0 .../xatm/cime_config/config_component.xml | 0 .../xatm/src/atm_comp_nuopc.F90 | 0 .../xcpl_comps_nuopc => med_test_comps}/xglc/cime_config/buildlib | 0 .../xglc/cime_config/buildlib_cmake | 0 .../xcpl_comps_nuopc => med_test_comps}/xglc/cime_config/buildnml | 0 .../xglc/cime_config/config_component.xml | 0 .../xglc/src/glc_comp_nuopc.F90 | 0 .../xcpl_comps_nuopc => med_test_comps}/xice/cime_config/buildlib | 0 .../xice/cime_config/buildlib_cmake | 0 .../xcpl_comps_nuopc => med_test_comps}/xice/cime_config/buildnml | 0 .../xice/cime_config/config_component.xml | 0 .../xice/src/ice_comp_nuopc.F90 | 0 .../xcpl_comps_nuopc => med_test_comps}/xlnd/cime_config/buildlib | 0 .../xlnd/cime_config/buildlib_cmake | 0 .../xcpl_comps_nuopc => med_test_comps}/xlnd/cime_config/buildnml | 0 .../xlnd/cime_config/config_component.xml | 0 .../xlnd/src/lnd_comp_nuopc.F90 | 0 .../xcpl_comps_nuopc => med_test_comps}/xocn/cime_config/buildlib | 0 .../xocn/cime_config/buildlib_cmake | 0 .../xcpl_comps_nuopc => med_test_comps}/xocn/cime_config/buildnml | 0 .../xocn/cime_config/config_component.xml | 0 .../xocn/src/ocn_comp_nuopc.F90 | 0 .../xcpl_comps_nuopc => med_test_comps}/xrof/cime_config/buildlib | 0 .../xrof/cime_config/buildlib_cmake | 0 .../xcpl_comps_nuopc => med_test_comps}/xrof/cime_config/buildnml | 0 .../xrof/cime_config/config_component.xml | 0 .../xrof/src/rof_comp_nuopc.F90 | 0 .../xshare/dead_methods_mod.F90 | 0 .../xcpl_comps_nuopc => med_test_comps}/xshare/dead_nuopc_mod.F90 | 0 .../xcpl_comps_nuopc => med_test_comps}/xwav/cime_config/buildlib | 0 .../xwav/cime_config/buildlib_cmake | 0 .../xcpl_comps_nuopc => med_test_comps}/xwav/cime_config/buildnml | 0 .../xwav/cime_config/config_component.xml | 0 .../xwav/src/wav_comp_nuopc.F90 | 0 37 files changed, 0 insertions(+), 0 deletions(-) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xatm/cime_config/buildlib (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xatm/cime_config/buildlib_cmake (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xatm/cime_config/buildnml (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xatm/cime_config/config_component.xml (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xatm/src/atm_comp_nuopc.F90 (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xglc/cime_config/buildlib (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xglc/cime_config/buildlib_cmake (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xglc/cime_config/buildnml (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xglc/cime_config/config_component.xml (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xglc/src/glc_comp_nuopc.F90 (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xice/cime_config/buildlib (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xice/cime_config/buildlib_cmake (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xice/cime_config/buildnml (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xice/cime_config/config_component.xml (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xice/src/ice_comp_nuopc.F90 (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xlnd/cime_config/buildlib (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xlnd/cime_config/buildlib_cmake (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xlnd/cime_config/buildnml (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xlnd/cime_config/config_component.xml (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xlnd/src/lnd_comp_nuopc.F90 (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xocn/cime_config/buildlib (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xocn/cime_config/buildlib_cmake (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xocn/cime_config/buildnml (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xocn/cime_config/config_component.xml (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xocn/src/ocn_comp_nuopc.F90 (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xrof/cime_config/buildlib (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xrof/cime_config/buildlib_cmake (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xrof/cime_config/buildnml (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xrof/cime_config/config_component.xml (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xrof/src/rof_comp_nuopc.F90 (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xshare/dead_methods_mod.F90 (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xshare/dead_nuopc_mod.F90 (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xwav/cime_config/buildlib (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xwav/cime_config/buildlib_cmake (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xwav/cime_config/buildnml (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xwav/cime_config/config_component.xml (100%) rename {CIME/non_py/src/components/xcpl_comps_nuopc => med_test_comps}/xwav/src/wav_comp_nuopc.F90 (100%) diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib b/med_test_comps/xatm/cime_config/buildlib similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib rename to med_test_comps/xatm/cime_config/buildlib diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake b/med_test_comps/xatm/cime_config/buildlib_cmake similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/buildlib_cmake rename to med_test_comps/xatm/cime_config/buildlib_cmake diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml b/med_test_comps/xatm/cime_config/buildnml similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/buildnml rename to med_test_comps/xatm/cime_config/buildnml diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml b/med_test_comps/xatm/cime_config/config_component.xml similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xatm/cime_config/config_component.xml rename to med_test_comps/xatm/cime_config/config_component.xml diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 b/med_test_comps/xatm/src/atm_comp_nuopc.F90 similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xatm/src/atm_comp_nuopc.F90 rename to med_test_comps/xatm/src/atm_comp_nuopc.F90 diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib b/med_test_comps/xglc/cime_config/buildlib similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib rename to med_test_comps/xglc/cime_config/buildlib diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake b/med_test_comps/xglc/cime_config/buildlib_cmake similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/buildlib_cmake rename to med_test_comps/xglc/cime_config/buildlib_cmake diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml b/med_test_comps/xglc/cime_config/buildnml similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/buildnml rename to med_test_comps/xglc/cime_config/buildnml diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml b/med_test_comps/xglc/cime_config/config_component.xml similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xglc/cime_config/config_component.xml rename to med_test_comps/xglc/cime_config/config_component.xml diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 b/med_test_comps/xglc/src/glc_comp_nuopc.F90 similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xglc/src/glc_comp_nuopc.F90 rename to med_test_comps/xglc/src/glc_comp_nuopc.F90 diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib b/med_test_comps/xice/cime_config/buildlib similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib rename to med_test_comps/xice/cime_config/buildlib diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake b/med_test_comps/xice/cime_config/buildlib_cmake similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/buildlib_cmake rename to med_test_comps/xice/cime_config/buildlib_cmake diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml b/med_test_comps/xice/cime_config/buildnml similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/buildnml rename to med_test_comps/xice/cime_config/buildnml diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml b/med_test_comps/xice/cime_config/config_component.xml similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xice/cime_config/config_component.xml rename to med_test_comps/xice/cime_config/config_component.xml diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 b/med_test_comps/xice/src/ice_comp_nuopc.F90 similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xice/src/ice_comp_nuopc.F90 rename to med_test_comps/xice/src/ice_comp_nuopc.F90 diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib b/med_test_comps/xlnd/cime_config/buildlib similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib rename to med_test_comps/xlnd/cime_config/buildlib diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake b/med_test_comps/xlnd/cime_config/buildlib_cmake similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildlib_cmake rename to med_test_comps/xlnd/cime_config/buildlib_cmake diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml b/med_test_comps/xlnd/cime_config/buildnml similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/buildnml rename to med_test_comps/xlnd/cime_config/buildnml diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml b/med_test_comps/xlnd/cime_config/config_component.xml similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/cime_config/config_component.xml rename to med_test_comps/xlnd/cime_config/config_component.xml diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 b/med_test_comps/xlnd/src/lnd_comp_nuopc.F90 similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xlnd/src/lnd_comp_nuopc.F90 rename to med_test_comps/xlnd/src/lnd_comp_nuopc.F90 diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib b/med_test_comps/xocn/cime_config/buildlib similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib rename to med_test_comps/xocn/cime_config/buildlib diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake b/med_test_comps/xocn/cime_config/buildlib_cmake similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/buildlib_cmake rename to med_test_comps/xocn/cime_config/buildlib_cmake diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml b/med_test_comps/xocn/cime_config/buildnml similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/buildnml rename to med_test_comps/xocn/cime_config/buildnml diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml b/med_test_comps/xocn/cime_config/config_component.xml similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xocn/cime_config/config_component.xml rename to med_test_comps/xocn/cime_config/config_component.xml diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 b/med_test_comps/xocn/src/ocn_comp_nuopc.F90 similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xocn/src/ocn_comp_nuopc.F90 rename to med_test_comps/xocn/src/ocn_comp_nuopc.F90 diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib b/med_test_comps/xrof/cime_config/buildlib similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib rename to med_test_comps/xrof/cime_config/buildlib diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake b/med_test_comps/xrof/cime_config/buildlib_cmake similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/buildlib_cmake rename to med_test_comps/xrof/cime_config/buildlib_cmake diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml b/med_test_comps/xrof/cime_config/buildnml similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/buildnml rename to med_test_comps/xrof/cime_config/buildnml diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml b/med_test_comps/xrof/cime_config/config_component.xml similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xrof/cime_config/config_component.xml rename to med_test_comps/xrof/cime_config/config_component.xml diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 b/med_test_comps/xrof/src/rof_comp_nuopc.F90 similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xrof/src/rof_comp_nuopc.F90 rename to med_test_comps/xrof/src/rof_comp_nuopc.F90 diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 b/med_test_comps/xshare/dead_methods_mod.F90 similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_methods_mod.F90 rename to med_test_comps/xshare/dead_methods_mod.F90 diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 b/med_test_comps/xshare/dead_nuopc_mod.F90 similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xshare/dead_nuopc_mod.F90 rename to med_test_comps/xshare/dead_nuopc_mod.F90 diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib b/med_test_comps/xwav/cime_config/buildlib similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib rename to med_test_comps/xwav/cime_config/buildlib diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake b/med_test_comps/xwav/cime_config/buildlib_cmake similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/buildlib_cmake rename to med_test_comps/xwav/cime_config/buildlib_cmake diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml b/med_test_comps/xwav/cime_config/buildnml similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/buildnml rename to med_test_comps/xwav/cime_config/buildnml diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml b/med_test_comps/xwav/cime_config/config_component.xml similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xwav/cime_config/config_component.xml rename to med_test_comps/xwav/cime_config/config_component.xml diff --git a/CIME/non_py/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 b/med_test_comps/xwav/src/wav_comp_nuopc.F90 similarity index 100% rename from CIME/non_py/src/components/xcpl_comps_nuopc/xwav/src/wav_comp_nuopc.F90 rename to med_test_comps/xwav/src/wav_comp_nuopc.F90 From 482b13db246de7cf34f06397ce7d852863428cb2 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Mon, 2 Mar 2026 13:16:20 -0700 Subject: [PATCH 23/24] Remove buildlib_cmake symlinks These don't appear to be used in a CESM build (they aren't present in any components other than these xcpl_comps) --- med_test_comps/xatm/cime_config/buildlib_cmake | 1 - med_test_comps/xglc/cime_config/buildlib_cmake | 1 - med_test_comps/xice/cime_config/buildlib_cmake | 1 - med_test_comps/xlnd/cime_config/buildlib_cmake | 1 - med_test_comps/xocn/cime_config/buildlib_cmake | 1 - med_test_comps/xrof/cime_config/buildlib_cmake | 1 - med_test_comps/xwav/cime_config/buildlib_cmake | 1 - 7 files changed, 7 deletions(-) delete mode 120000 med_test_comps/xatm/cime_config/buildlib_cmake delete mode 120000 med_test_comps/xglc/cime_config/buildlib_cmake delete mode 120000 med_test_comps/xice/cime_config/buildlib_cmake delete mode 120000 med_test_comps/xlnd/cime_config/buildlib_cmake delete mode 120000 med_test_comps/xocn/cime_config/buildlib_cmake delete mode 120000 med_test_comps/xrof/cime_config/buildlib_cmake delete mode 120000 med_test_comps/xwav/cime_config/buildlib_cmake diff --git a/med_test_comps/xatm/cime_config/buildlib_cmake b/med_test_comps/xatm/cime_config/buildlib_cmake deleted file mode 120000 index 7766f77f5..000000000 --- a/med_test_comps/xatm/cime_config/buildlib_cmake +++ /dev/null @@ -1 +0,0 @@ -../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/med_test_comps/xglc/cime_config/buildlib_cmake b/med_test_comps/xglc/cime_config/buildlib_cmake deleted file mode 120000 index 7766f77f5..000000000 --- a/med_test_comps/xglc/cime_config/buildlib_cmake +++ /dev/null @@ -1 +0,0 @@ -../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/med_test_comps/xice/cime_config/buildlib_cmake b/med_test_comps/xice/cime_config/buildlib_cmake deleted file mode 120000 index 7766f77f5..000000000 --- a/med_test_comps/xice/cime_config/buildlib_cmake +++ /dev/null @@ -1 +0,0 @@ -../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/med_test_comps/xlnd/cime_config/buildlib_cmake b/med_test_comps/xlnd/cime_config/buildlib_cmake deleted file mode 120000 index 7766f77f5..000000000 --- a/med_test_comps/xlnd/cime_config/buildlib_cmake +++ /dev/null @@ -1 +0,0 @@ -../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/med_test_comps/xocn/cime_config/buildlib_cmake b/med_test_comps/xocn/cime_config/buildlib_cmake deleted file mode 120000 index 7766f77f5..000000000 --- a/med_test_comps/xocn/cime_config/buildlib_cmake +++ /dev/null @@ -1 +0,0 @@ -../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/med_test_comps/xrof/cime_config/buildlib_cmake b/med_test_comps/xrof/cime_config/buildlib_cmake deleted file mode 120000 index 7766f77f5..000000000 --- a/med_test_comps/xrof/cime_config/buildlib_cmake +++ /dev/null @@ -1 +0,0 @@ -../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file diff --git a/med_test_comps/xwav/cime_config/buildlib_cmake b/med_test_comps/xwav/cime_config/buildlib_cmake deleted file mode 120000 index 7766f77f5..000000000 --- a/med_test_comps/xwav/cime_config/buildlib_cmake +++ /dev/null @@ -1 +0,0 @@ -../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file From cdfb66ed721541f564ee48d2a638304217d3be16 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Mon, 2 Mar 2026 13:30:05 -0700 Subject: [PATCH 24/24] Add buildlib from CIME for xcomps This is copied exactly from CIME/build_scripts/buildlib.internal_components from ESMCI/cime@5444eae316 --- med_test_comps/xatm/cime_config/buildlib | 2 +- med_test_comps/xglc/cime_config/buildlib | 2 +- med_test_comps/xice/cime_config/buildlib | 2 +- med_test_comps/xlnd/cime_config/buildlib | 2 +- med_test_comps/xocn/cime_config/buildlib | 2 +- med_test_comps/xrof/cime_config/buildlib | 2 +- med_test_comps/xshare/cime_config/buildlib | 39 ++++++++++++++++++++++ med_test_comps/xwav/cime_config/buildlib | 2 +- 8 files changed, 46 insertions(+), 7 deletions(-) create mode 100755 med_test_comps/xshare/cime_config/buildlib diff --git a/med_test_comps/xatm/cime_config/buildlib b/med_test_comps/xatm/cime_config/buildlib index 7766f77f5..ba1b3b80a 120000 --- a/med_test_comps/xatm/cime_config/buildlib +++ b/med_test_comps/xatm/cime_config/buildlib @@ -1 +1 @@ -../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file +../../xshare/cime_config/buildlib \ No newline at end of file diff --git a/med_test_comps/xglc/cime_config/buildlib b/med_test_comps/xglc/cime_config/buildlib index 7766f77f5..ba1b3b80a 120000 --- a/med_test_comps/xglc/cime_config/buildlib +++ b/med_test_comps/xglc/cime_config/buildlib @@ -1 +1 @@ -../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file +../../xshare/cime_config/buildlib \ No newline at end of file diff --git a/med_test_comps/xice/cime_config/buildlib b/med_test_comps/xice/cime_config/buildlib index 7766f77f5..ba1b3b80a 120000 --- a/med_test_comps/xice/cime_config/buildlib +++ b/med_test_comps/xice/cime_config/buildlib @@ -1 +1 @@ -../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file +../../xshare/cime_config/buildlib \ No newline at end of file diff --git a/med_test_comps/xlnd/cime_config/buildlib b/med_test_comps/xlnd/cime_config/buildlib index 7766f77f5..ba1b3b80a 120000 --- a/med_test_comps/xlnd/cime_config/buildlib +++ b/med_test_comps/xlnd/cime_config/buildlib @@ -1 +1 @@ -../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file +../../xshare/cime_config/buildlib \ No newline at end of file diff --git a/med_test_comps/xocn/cime_config/buildlib b/med_test_comps/xocn/cime_config/buildlib index 7766f77f5..ba1b3b80a 120000 --- a/med_test_comps/xocn/cime_config/buildlib +++ b/med_test_comps/xocn/cime_config/buildlib @@ -1 +1 @@ -../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file +../../xshare/cime_config/buildlib \ No newline at end of file diff --git a/med_test_comps/xrof/cime_config/buildlib b/med_test_comps/xrof/cime_config/buildlib index 7766f77f5..ba1b3b80a 120000 --- a/med_test_comps/xrof/cime_config/buildlib +++ b/med_test_comps/xrof/cime_config/buildlib @@ -1 +1 @@ -../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file +../../xshare/cime_config/buildlib \ No newline at end of file diff --git a/med_test_comps/xshare/cime_config/buildlib b/med_test_comps/xshare/cime_config/buildlib new file mode 100755 index 000000000..f7f597d77 --- /dev/null +++ b/med_test_comps/xshare/cime_config/buildlib @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +""" +build cime component model library. This buildlib script is used by all cime internal +components. +""" + +import sys, os + +_CIMEROOT = os.environ.get("CIMEROOT") +if _CIMEROOT == None: + raise ValueError("ERROR: CIMEROOT not defined in buildlib.internal_components.") +sys.path.append(os.path.join(_CIMEROOT, "CIME", "Tools")) + +from standard_script_setup import * +from CIME.buildlib import build_cime_component_lib, parse_input +from CIME.case import Case + + +def buildlib(bldroot, libroot, case, compname=None): + if compname is None: + thisdir = os.path.dirname(os.path.abspath(__file__)) + path, dir1 = os.path.split(thisdir) + _, dir2 = os.path.split(path) + if dir1 == "cime_config": + compname = dir2 + else: + compname = dir1.split(".")[1] + build_cime_component_lib(case, compname, libroot, bldroot) + + +def _main_func(args): + caseroot, libroot, bldroot = parse_input(args) + with Case(caseroot) as case: + buildlib(bldroot, libroot, case) + + +if __name__ == "__main__": + _main_func(sys.argv) diff --git a/med_test_comps/xwav/cime_config/buildlib b/med_test_comps/xwav/cime_config/buildlib index 7766f77f5..ba1b3b80a 120000 --- a/med_test_comps/xwav/cime_config/buildlib +++ b/med_test_comps/xwav/cime_config/buildlib @@ -1 +1 @@ -../../../../../../build_scripts/buildlib.internal_components \ No newline at end of file +../../xshare/cime_config/buildlib \ No newline at end of file