diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29bb..000000000 diff --git a/Makefile b/Makefile index df9c11391..60e46b200 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,14 @@ ifndef CXX $(error CXX not defined) endif +ifndef PIO_LIBDIR +$(error PIO_LIBDIR should point to PIO library directory.) +endif + +ifndef PIO_INC +$(error PIO_INC should point to PIO include directory.) +endif + ifndef INTERNAL_PIO_INIT INTERNAL_PIO_INIT := 1 endif @@ -41,7 +49,7 @@ else @echo "ESMF_DEP_FRONT = MED" >> cmeps.mk.install @echo "ESMF_DEP_INCPATH = $(INSTALLDIR)/include" >> cmeps.mk.install @echo "ESMF_DEP_CMPL_OBJS = " >> cmeps.mk.install - @echo "ESMF_DEP_LINK_OBJS = $(INSTALLDIR)/libcmeps.a $(INSTALLDIR)/libcmeps_util.a $(PIO_ROOT)/lib/libpiof.a $(PIO_ROOT)/lib/libpioc.a $(PNETCDF_LD_OPTS)" >> cmeps.mk.install + @echo "ESMF_DEP_LINK_OBJS = $(INSTALLDIR)/libcmeps.a $(INSTALLDIR)/libcmeps_util.a $(PIO_LIBDIR)/libpiof.a $(PIO_LIBDIR)/libpioc.a $(PNETCDF_LD_OPTS)" >> cmeps.mk.install mkdir -p $(INSTALLDIR) mkdir -p $(INSTALLDIR)/include cp -f $(LIBRARY_UTIL) $(INSTALLDIR) @@ -53,11 +61,11 @@ endif $(LIBRARY_MEDIATOR): $(LIBRARY_UTIL) .FORCE cd mediator ;\ - exec $(MAKE) PIO_INCLUDE_DIR=$(PIO_INCLUDE_DIR) INTERNAL_PIO_INIT=$(INTERNAL_PIO_INIT) + exec $(MAKE) PIO_INC=$(PIO_INC) INTERNAL_PIO_INIT=$(INTERNAL_PIO_INIT) $(LIBRARY_UTIL): .FORCE cd util ;\ - exec $(MAKE) + exec $(MAKE) PIO_INC=$(PIO_INC) .FORCE: @@ -66,3 +74,4 @@ clean: exec $(MAKE) clean cd util; \ exec $(MAKE) clean + diff --git a/cime_config/buildnml b/cime_config/buildnml index ea6827d05..efd54b074 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -572,8 +572,8 @@ def buildnml(case, caseroot, component): coupling_mode = case.get_value('COUPLING_MODE') if coupling_mode == 'cesm': filename = os.path.join(fd_dir,"fd_cesm.yaml") - elif coupling_mode == 'hafs': - filename = os.path.join(fd_dir,"fd_hafs.yaml") + elif 'nems' in coupling_mode or coupling_mode == 'hafs': + filename = os.path.join(fd_dir,"fd_nems.yaml") else: expect(False, "coupling mode currently only supports cesm") shutil.copy(filename, os.path.join(rundir, "fd.yaml")) diff --git a/doc/source/field_naming_convention.rst b/doc/source/field_naming_convention.rst index a3064f844..66eae269d 100644 --- a/doc/source/field_naming_convention.rst +++ b/doc/source/field_naming_convention.rst @@ -17,7 +17,6 @@ field dictionaries are supported:: fd_cesm.yaml fd_nems.yaml - fd_hafs.yaml The CMEPS field name convention in these YAML files is independent of the model components. The convention differentiates between variables that are state fields versus flux fields. diff --git a/mediator/Makefile b/mediator/Makefile index 74b158ffd..126d040bd 100644 --- a/mediator/Makefile +++ b/mediator/Makefile @@ -7,8 +7,8 @@ ESMF_VERSION_MAJOR ?= 0 ESMF_VERSION_MINOR ?= 0 CPPDEFS += -DESMF_VERSION_MAJOR=$(ESMF_VERSION_MAJOR) -DESMF_VERSION_MINOR=$(ESMF_VERSION_MINOR) -ifndef PIO_INCLUDE_DIR -$(error PIO_INCLUDE_DIR not set) +ifndef PIO_INC +$(error PIO_INC should point to PIO include directory.) endif ifeq ($(INTERNAL_PIO_INIT),1) @@ -25,7 +25,7 @@ $(LIBRARY): $(OBJ) $(AR) $(ARFLAGS) $@ $? %.o: %.F90 - $(ESMF_F90COMPILER) -c $(ESMF_F90COMPILEOPTS) $(ESMF_F90COMPILEPATHS) $(CPPDEFS) -I$(PIO_ROOT)/include -I../util $*.F90 + $(ESMF_F90COMPILER) -c $(ESMF_F90COMPILEOPTS) $(ESMF_F90COMPILEPATHS) $(CPPDEFS) -I${PIO_INC} -I../util $*.F90 clean: $(RM) -f $(LIBRARY) *.i90 *.o *.mod diff --git a/mediator/esmFlds.F90 b/mediator/esmFlds.F90 index e41d4289f..5e0430b57 100644 --- a/mediator/esmFlds.F90 +++ b/mediator/esmFlds.F90 @@ -52,7 +52,8 @@ module esmflds integer , public, parameter :: map_rof2ocn_liq = 11 ! custom smoothing map to map liq from rof->ocn (cesm only) integer , public, parameter :: map_glc2ocn_liq = 12 ! custom smoothing map to map liq from glc->ocn (cesm only) integer , public, parameter :: map_glc2ocn_ice = 13 ! custom smoothing map to map ice from glc->ocn (cesm only) - integer , public, parameter :: nmappers = 13 + integer , public, parameter :: mapfillv_bilnr = 14 ! fill value followed by bilinear + integer , public, parameter :: nmappers = 14 character(len=*) , public, parameter :: mapnames(nmappers) = & (/'bilnr ',& @@ -67,7 +68,8 @@ module esmflds 'rof2ocn_ice',& 'rof2ocn_liq',& 'glc2ocn_ice',& - 'glc2ocn_liq'/) + 'glc2ocn_liq',& + 'fillv_bilnr'/) !----------------------------------------------- ! Set coupling mode @@ -75,6 +77,19 @@ module esmflds character(len=CS), public :: coupling_mode ! valid values are [cesm,nems_orig,nems_frac,nems_orig_data,hafs] + !----------------------------------------------- + ! Name of model components + !----------------------------------------------- + + character(len=CS), public :: med_name = '' + character(len=CS), public :: atm_name = '' + character(len=CS), public :: lnd_name = '' + character(len=CS), public :: ocn_name = '' + character(len=CS), public :: ice_name = '' + character(len=CS), public :: rof_name = '' + character(len=CS), public :: wav_name = '' + character(len=CS), public :: glc_name = '' + !----------------------------------------------- ! PUblic methods !----------------------------------------------- diff --git a/mediator/esmFldsExchange_hafs_mod.F90 b/mediator/esmFldsExchange_hafs_mod.F90 index 38f294fcf..37e8cb3e3 100644 --- a/mediator/esmFldsExchange_hafs_mod.F90 +++ b/mediator/esmFldsExchange_hafs_mod.F90 @@ -30,6 +30,17 @@ module esmFldsExchange_hafs_mod character(*), parameter :: u_FILE_u = & __FILE__ + type systemType + sequence + private + integer :: system + end type + + type(systemType), parameter :: & + SYS_ERR = systemType(-1), & ! Error code + SYS_CDP = systemType(0), & ! Community Data Models for Earth Prediction Sys + SYS_UFS = systemType(1) ! Unified Forecast System + type gcomp_attr character(len=CX) :: atm2ice_fmap='unset' character(len=CX) :: atm2ice_smap='unset' @@ -41,8 +52,19 @@ module esmFldsExchange_hafs_mod character(len=CX) :: ice2atm_smap='unset' character(len=CX) :: ocn2atm_fmap='unset' character(len=CX) :: ocn2atm_smap='unset' + character(len=CS) :: mapnorm ='one' + type(systemType) :: hafs_sysType=SYS_CDP end type + interface operator (==) + module procedure systemType_eq + end interface + + interface assignment (=) + module procedure systemType_tostring + module procedure systemType_frstring + end interface + !=============================================================================== contains !=============================================================================== @@ -55,18 +77,30 @@ subroutine esmFldsExchange_hafs(gcomp, phase, rc) integer , intent(inout) :: rc ! local variables: + character(len=*) , parameter :: subname='(esmFldsExchange_hafs)' !-------------------------------------- + call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO) rc = ESMF_SUCCESS if (phase == 'advertise') then call esmFldsExchange_hafs_advt(gcomp, phase, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - else + elseif (phase == 'fieldcheck') then + call esmFldsExchange_hafs_fchk(gcomp, phase, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + elseif (phase == 'initialize') then call esmFldsExchange_hafs_init(gcomp, phase, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + else + call ESMF_LogSetError(ESMF_FAILURE, & + msg=trim(subname)//": Phase is set to "//trim(phase), & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return ! bail out endif + call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO) + end subroutine esmFldsExchange_hafs !----------------------------------------------------------------------------- @@ -86,23 +120,45 @@ subroutine esmFldsExchange_hafs_advt(gcomp, phase, rc) !character(len=5) :: iso(2) character(len=CL) :: cvalue character(len=CS) :: name, fldname + character(len=CS) :: fldname1, fldname2 + type(gcomp_attr) :: hafs_attr character(len=CS), allocatable :: flds(:) + character(len=CS), allocatable :: S_flds(:) + character(len=CS), allocatable :: F_flds(:,:) character(len=CS), allocatable :: suffix(:) character(len=*) , parameter :: subname='(esmFldsExchange_hafs_advt)' !-------------------------------------- + call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO) rc = ESMF_SUCCESS !===================================================================== ! scalar information !===================================================================== - call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", value=cvalue, & - rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - do n = 1,ncomps - call addfld(fldListFr(n)%flds, trim(cvalue)) - call addfld(fldListTo(n)%flds, trim(cvalue)) - end do + + call NUOPC_CompAttributeGet(gcomp, name='ScalarFieldName', & + isPresent=isPresent, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (isPresent) then + call NUOPC_CompAttributeGet(gcomp, name="ScalarFieldName", & + value=cvalue, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + do n = 1,ncomps + call addfld(fldListFr(n)%flds, trim(cvalue)) + call addfld(fldListTo(n)%flds, trim(cvalue)) + end do + end if + + !===================================================================== + ! attribute settings + !===================================================================== + call esmFldsExchange_hafs_attr(gcomp, hafs_attr, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + ! --------------------------------------------------------------------- + ! CDEPS Coupling + ! --------------------------------------------------------------------- + if (hafs_attr%hafs_sysType == SYS_CDP) then !===================================================================== ! FIELDS TO MEDIATOR component (for fractions and atm/ocn flux calculation) @@ -130,6 +186,12 @@ subroutine esmFldsExchange_hafs_advt(gcomp, phase, rc) call addfld(fldListTo(compatm)%flds, 'Si_ifrac') call addfld(fldListTo(compatm)%flds, 'So_ofrac') + !---------------------------------------------------------- + ! to atm: surface temperatures from ocn + !---------------------------------------------------------- + call addfld(fldListFr(compocn)%flds, 'So_t') + call addfld(fldListTo(compatm)%flds, 'So_t') + !===================================================================== ! FIELDS TO OCEAN (compocn) !===================================================================== @@ -293,10 +355,110 @@ subroutine esmFldsExchange_hafs_advt(gcomp, phase, rc) end do deallocate(flds) + ! --------------------------------------------------------------------- + ! UFS Coupling + ! --------------------------------------------------------------------- + elseif (hafs_attr%hafs_sysType == SYS_UFS) then + !---------------------------------------------------------- + ! to med: masks from components + !---------------------------------------------------------- + call addfld(fldListFr(compocn)%flds, 'So_omask') + !---------------------------------------------------------- + ! to med: frac from components + !---------------------------------------------------------- + call addfld(fldListTo(compatm)%flds, 'So_ofrac') + ! --------------------------------------------------------------------- + ! from atm to ocn + ! --------------------------------------------------------------------- + ! state fields + allocate(S_flds(6)) + S_flds = (/'Sa_u ', & ! inst_zonal_wind_height10m + 'Sa_v ', & ! inst_merid_wind_height10m + 'Sa_tbot', & ! inst_temp_height2m + 'Sa_shum', & ! inst_spec_humid_height2m + 'Sa_pslv', & ! inst_pres_height_surface + 'Sa_tskn' /) ! inst_temp_height_surface + do n = 1,size(S_flds) + fldname = trim(S_flds(n)) + call addfld(fldListFr(compatm)%flds, trim(fldname)) + call addfld(fldListTo(compocn)%flds, trim(fldname)) + end do + deallocate(S_flds) + ! flux fields + allocate(F_flds(5,2)) + F_flds(1,:) = (/'Faxa_taux ','Faxa_taux '/) ! mean_zonal_moment_flx_atm + F_flds(2,:) = (/'Faxa_tauy ','Faxa_tauy '/) ! mean_merid_moment_flx_atm + F_flds(3,:) = (/'Faxa_rain ','Faxa_rain '/) ! mean_prec_rate + F_flds(4,:) = (/'Faxa_swnet','Faxa_swnet'/) ! mean_net_sw_flx + F_flds(5,:) = (/'Faxa_lwnet','Faxa_lwnet'/) ! mean_net_lw_flx + do n = 1,size(F_flds,1) + fldname1 = trim(F_flds(n,1)) + fldname2 = trim(F_flds(n,2)) + call addfld(fldListFr(compatm)%flds, trim(fldname1)) + call addfld(fldListTo(compocn)%flds, trim(fldname2)) + end do + deallocate(F_flds) + ! --------------------------------------------------------------------- + ! from ocn to atm + ! --------------------------------------------------------------------- + ! state fields + allocate(S_flds(1)) + S_flds = (/'So_t'/) ! sea_surface_temperature + do n = 1,size(S_flds) + fldname = trim(S_flds(n)) + call addfld(fldListFr(compocn)%flds, trim(fldname)) + call addfld(fldListTo(compatm)%flds, trim(fldname)) + end do + deallocate(S_flds) + endif ! hafs_sysType + + call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO) + end subroutine esmFldsExchange_hafs_advt !----------------------------------------------------------------------------- + subroutine esmFldsExchange_hafs_fchk(gcomp, phase, rc) + + use med_methods_mod , only : fldchk => med_methods_FB_FldChk + use med_internalstate_mod , only : InternalState + + ! input/output parameters: + type(ESMF_GridComp) :: gcomp + character(len=*) , intent(in) :: phase + integer , intent(inout) :: rc + + ! local variables: + type(InternalState) :: is_local + character(len=*) , parameter :: subname='(esmFldsExchange_hafs_fchk)' + !-------------------------------------- + + call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO) + rc = ESMF_SUCCESS + + !--------------------------------------- + ! Get the internal state + !--------------------------------------- + nullify(is_local%wrap) + call ESMF_GridCompGetInternalState(gcomp, is_local, rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + + if (fldchk(is_local%wrap%FBImp(compocn,compocn),'So_omask',rc=rc)) then + call ESMF_LogWrite(trim(subname)//": Field connected "//"So_omask", & + ESMF_LOGMSG_INFO) + else + call ESMF_LogSetError(ESMF_FAILURE, & + msg=trim(subname)//": Field is not connected "//"So_omask", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return ! bail out + endif + + call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO) + + end subroutine esmFldsExchange_hafs_fchk + + !----------------------------------------------------------------------------- + subroutine esmFldsExchange_hafs_init(gcomp, phase, rc) use med_methods_mod , only : fldchk => med_methods_FB_FldChk @@ -306,6 +468,7 @@ subroutine esmFldsExchange_hafs_init(gcomp, phase, rc) use esmFlds , only : addmrg => med_fldList_AddMrg use esmflds , only : mapbilnr, mapconsf, mapconsd, mappatch use esmflds , only : mapfcopy, mapnstod, mapnstod_consd + use esmflds , only : mapfillv_bilnr use esmflds , only : mapnstod_consf ! input/output parameters: @@ -317,16 +480,19 @@ subroutine esmFldsExchange_hafs_init(gcomp, phase, rc) type(InternalState) :: is_local integer :: num, i, n integer :: n1, n2, n3, n4 - logical :: isPresent !character(len=5) :: iso(2) character(len=CL) :: cvalue character(len=CS) :: name, fldname + character(len=CS) :: fldname1, fldname2 type(gcomp_attr) :: hafs_attr character(len=CS), allocatable :: flds(:) + character(len=CS), allocatable :: S_flds(:) + character(len=CS), allocatable :: F_flds(:,:) character(len=CS), allocatable :: suffix(:) character(len=*) , parameter :: subname='(esmFldsExchange_hafs_init)' !-------------------------------------- + call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO) rc = ESMF_SUCCESS !--------------------------------------- @@ -354,9 +520,17 @@ subroutine esmFldsExchange_hafs_init(gcomp, phase, rc) ! for these computations. !-------------------------------------- + !===================================================================== + ! attribute settings + !===================================================================== call esmFldsExchange_hafs_attr(gcomp, hafs_attr, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + ! --------------------------------------------------------------------- + ! CDEPS Coupling + ! --------------------------------------------------------------------- + if (hafs_attr%hafs_sysType == SYS_CDP) then + !===================================================================== ! FIELDS TO MEDIATOR component (for fractions and atm/ocn flux calculation) !===================================================================== @@ -424,6 +598,24 @@ subroutine esmFldsExchange_hafs_init(gcomp, phase, rc) ! FIELDS TO ATMOSPHERE !===================================================================== + !---------------------------------------------------------- + ! to atm: sea surface temperature + !---------------------------------------------------------- + allocate(flds(1)) + flds = (/'So_t'/) ! sea_surface_temperature + do n = 1,size(flds) + fldname = trim(flds(n)) + if (fldchk(is_local%wrap%FBExp(compatm),trim(fldname),rc=rc) .and. & + fldchk(is_local%wrap%FBImp(compocn,compocn),trim(fldname),rc=rc) & + ) then + call addmap(fldListFr(compocn)%flds, trim(fldname), compatm, & + mapfillv_bilnr, hafs_attr%mapnorm, hafs_attr%ocn2atm_smap) + call addmrg(fldListTo(compatm)%flds, trim(fldname), & + mrg_from=compocn, mrg_fld=trim(fldname), mrg_type='copy') + end if + end do + deallocate(flds) + !===================================================================== ! FIELDS TO OCEAN (compocn) !===================================================================== @@ -646,6 +838,75 @@ subroutine esmFldsExchange_hafs_init(gcomp, phase, rc) end do deallocate(flds) + ! --------------------------------------------------------------------- + ! UFS Coupling + ! --------------------------------------------------------------------- + elseif (hafs_attr%hafs_sysType == SYS_UFS) then + ! --------------------------------------------------------------------- + ! from atm to ocn + ! --------------------------------------------------------------------- + ! state fields + allocate(S_flds(6)) + S_flds = (/'Sa_u ', & ! inst_zonal_wind_height10m + 'Sa_v ', & ! inst_merid_wind_height10m + 'Sa_tbot', & ! inst_temp_height2m + 'Sa_shum', & ! inst_spec_humid_height2m + 'Sa_pslv', & ! inst_pres_height_surface + 'Sa_tskn' /) ! inst_temp_height_surface + do n = 1,size(S_flds) + fldname = trim(S_flds(n)) + if (fldchk(is_local%wrap%FBExp(compocn),trim(fldname),rc=rc) .and. & + fldchk(is_local%wrap%FBImp(compatm,compatm),trim(fldname),rc=rc) & + ) then + call addmap(fldListFr(compatm)%flds, trim(fldname), compocn, & + mapfillv_bilnr, hafs_attr%mapnorm, hafs_attr%atm2ocn_smap) + call addmrg(fldListTo(compocn)%flds, trim(fldname), & + mrg_from=compatm, mrg_fld=trim(fldname), mrg_type='copy') + end if + end do + deallocate(S_flds) + ! flux fields + allocate(F_flds(5,2)) + F_flds(1,:) = (/'Faxa_taux ','Faxa_taux '/) ! mean_zonal_moment_flx_atm + F_flds(2,:) = (/'Faxa_tauy ','Faxa_tauy '/) ! mean_merid_moment_flx_atm + F_flds(3,:) = (/'Faxa_rain ','Faxa_rain '/) ! mean_prec_rate + F_flds(4,:) = (/'Faxa_swnet','Faxa_swnet'/) ! mean_net_sw_flx + F_flds(5,:) = (/'Faxa_lwnet','Faxa_lwnet'/) ! mean_net_lw_flx + do n = 1,size(F_flds,1) + fldname1 = trim(F_flds(n,1)) + fldname2 = trim(F_flds(n,2)) + if (fldchk(is_local%wrap%FBExp(compocn),trim(fldname2),rc=rc) .and. & + fldchk(is_local%wrap%FBImp(compatm,compatm),trim(fldname1),rc=rc) & + ) then + call addmap(fldListFr(compatm)%flds, trim(fldname1), compocn, & + mapfillv_bilnr, hafs_attr%mapnorm, hafs_attr%atm2ocn_smap) + call addmrg(fldListTo(compocn)%flds, trim(fldname2), & + mrg_from=compatm, mrg_fld=trim(fldname1), mrg_type='copy') + end if + end do + deallocate(F_flds) + ! --------------------------------------------------------------------- + ! from ocn to atm + ! --------------------------------------------------------------------- + ! state fields + allocate(S_flds(1)) + S_flds = (/'So_t'/) ! sea_surface_temperature + do n = 1,size(S_flds) + fldname = trim(S_flds(n)) + if (fldchk(is_local%wrap%FBExp(compatm),trim(fldname),rc=rc) .and. & + fldchk(is_local%wrap%FBImp(compocn,compocn),trim(fldname),rc=rc) & + ) then + call addmap(fldListFr(compocn)%flds, trim(fldname), compatm, & + mapfillv_bilnr, hafs_attr%mapnorm, hafs_attr%ocn2atm_smap) + call addmrg(fldListTo(compatm)%flds, trim(fldname), & + mrg_from=compocn, mrg_fld=trim(fldname), mrg_type='copy') + end if + end do + deallocate(S_flds) + endif ! hafs_sysType + + call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO) + end subroutine esmFldsExchange_hafs_init !----------------------------------------------------------------------------- @@ -658,102 +919,232 @@ subroutine esmFldsExchange_hafs_attr(gcomp, hafs_attr, rc) integer , intent(inout) :: rc ! local variables: + character(32) :: cname + integer :: verbosity, diagnostic + character(len=CL) :: cvalue logical :: isPresent character(len=*) , parameter :: subname='(esmFldsExchange_hafs_attr)' !-------------------------------------- + call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO) rc = ESMF_SUCCESS + ! Query component for name, verbosity, and diagnostic values +#if ESMF_VERSION_MAJOR >= 8 + call NUOPC_CompGet(gcomp, name=cname, verbosity=verbosity, & + diagnostic=diagnostic, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return +#else + call ESMF_GridCompGet(gcomp, name=cname, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_AttributeGet(gcomp, name="Verbosity", value=cvalue, & + defaultValue="0", convention="NUOPC", purpose="Instance", rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + verbosity = ESMF_UtilString2Int(cvalue, & + specialStringList=(/"off ","low ","high","max "/), & + specialValueList=(/0,9985,32513,131071/), rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_AttributeGet(gcomp, name="Diagnostic", value=cvalue, & + defaultValue="0", convention="NUOPC", purpose="Instance", rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + diagnostic = ESMF_UtilString2Int(cvalue, & + specialStringList=(/"off ","max "/), & + specialValueList=(/0,131071/), rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return +#endif + + !---------------------------------------------------------- + ! Initialize system type + !---------------------------------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name='system_type', & + isPresent=isPresent, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (isPresent) then + call NUOPC_CompAttributeGet(gcomp, name='system_type', & + value=cvalue, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + hafs_attr%hafs_sysType = cvalue + end if + + !---------------------------------------------------------- + ! Normalization type + !---------------------------------------------------------- + + call NUOPC_CompAttributeGet(gcomp, name='normalization', & + isPresent=isPresent, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (isPresent) then + call NUOPC_CompAttributeGet(gcomp, name='normalization', & + value=hafs_attr%mapnorm, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end if + !---------------------------------------------------------- ! Initialize mapping file names !---------------------------------------------------------- ! to atm - call NUOPC_CompAttributeGet(gcomp, name='ice2atm_fmapname', & - value=hafs_attr%ice2atm_fmap, isPresent=isPresent, rc=rc) + isPresent=isPresent, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (isPresent) then - call ESMF_LogWrite('ice2atm_fmapname = '//trim(hafs_attr%ice2atm_fmap), & - ESMF_LOGMSG_INFO) + call NUOPC_CompAttributeGet(gcomp, name='ice2atm_fmapname', & + value=hafs_attr%ice2atm_fmap, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return end if - call NUOPC_CompAttributeGet(gcomp, name='ice2atm_smapname', & - value=hafs_attr%ice2atm_smap, isPresent=isPresent, rc=rc) + isPresent=isPresent, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (isPresent) then - call ESMF_LogWrite('ice2atm_smapname = '//trim(hafs_attr%ice2atm_smap), & - ESMF_LOGMSG_INFO) + call NUOPC_CompAttributeGet(gcomp, name='ice2atm_smapname', & + value=hafs_attr%ice2atm_smap, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return end if - call NUOPC_CompAttributeGet(gcomp, name='ocn2atm_smapname', & - value=hafs_attr%ocn2atm_smap, isPresent=isPresent, rc=rc) + isPresent=isPresent, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (isPresent) then - call ESMF_LogWrite('ocn2atm_smapname = '//trim(hafs_attr%ocn2atm_smap), & - ESMF_LOGMSG_INFO) + call NUOPC_CompAttributeGet(gcomp, name='ocn2atm_smapname', & + value=hafs_attr%ocn2atm_smap, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return end if - call NUOPC_CompAttributeGet(gcomp, name='ocn2atm_fmapname', & - value=hafs_attr%ocn2atm_fmap, isPresent=isPresent, rc=rc) + isPresent=isPresent, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (isPresent) then - call ESMF_LogWrite('ocn2atm_fmapname = '//trim(hafs_attr%ocn2atm_fmap), & - ESMF_LOGMSG_INFO) + call NUOPC_CompAttributeGet(gcomp, name='ocn2atm_fmapname', & + value=hafs_attr%ocn2atm_fmap, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return end if ! to ice - call NUOPC_CompAttributeGet(gcomp, name='atm2ice_fmapname', & - value=hafs_attr%atm2ice_fmap, isPresent=isPresent, rc=rc) + isPresent=isPresent, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (isPresent) then - call ESMF_LogWrite('atm2ice_fmapname = '//trim(hafs_attr%atm2ice_fmap), & - ESMF_LOGMSG_INFO) + call NUOPC_CompAttributeGet(gcomp, name='atm2ice_fmapname', & + value=hafs_attr%atm2ice_fmap, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return end if - call NUOPC_CompAttributeGet(gcomp, name='atm2ice_smapname', & - value=hafs_attr%atm2ice_smap, isPresent=isPresent, rc=rc) + isPresent=isPresent, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (isPresent) then - call ESMF_LogWrite('atm2ice_smapname = '//trim(hafs_attr%atm2ice_smap), & - ESMF_LOGMSG_INFO) + call NUOPC_CompAttributeGet(gcomp, name='atm2ice_smapname', & + value=hafs_attr%atm2ice_smap, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return end if - call NUOPC_CompAttributeGet(gcomp, name='atm2ice_vmapname', & - value=hafs_attr%atm2ice_vmap, isPresent=isPresent, rc=rc) + isPresent=isPresent, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (isPresent) then - call ESMF_LogWrite('atm2ice_vmapname = '//trim(hafs_attr%atm2ice_vmap), & - ESMF_LOGMSG_INFO) + call NUOPC_CompAttributeGet(gcomp, name='atm2ice_vmapname', & + value=hafs_attr%atm2ice_vmap, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return end if ! to ocn - call NUOPC_CompAttributeGet(gcomp, name='atm2ocn_fmapname', & - value=hafs_attr%atm2ocn_fmap, isPresent=isPresent, rc=rc) + isPresent=isPresent, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (isPresent) then - call ESMF_LogWrite('atm2ocn_fmapname = '//trim(hafs_attr%atm2ocn_fmap), & - ESMF_LOGMSG_INFO) + call NUOPC_CompAttributeGet(gcomp, name='atm2ocn_fmapname', & + value=hafs_attr%atm2ocn_fmap, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return end if - call NUOPC_CompAttributeGet(gcomp, name='atm2ocn_smapname', & - value=hafs_attr%atm2ocn_smap, isPresent=isPresent, rc=rc) + isPresent=isPresent, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (isPresent) then - call ESMF_LogWrite('atm2ocn_smapname = '//trim(hafs_attr%atm2ocn_smap), & - ESMF_LOGMSG_INFO) + call NUOPC_CompAttributeGet(gcomp, name='atm2ocn_smapname', & + value=hafs_attr%atm2ocn_smap, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return end if - call NUOPC_CompAttributeGet(gcomp, name='atm2ocn_vmapname', & - value=hafs_attr%atm2ocn_vmap, isPresent=isPresent, rc=rc) + isPresent=isPresent, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return if (isPresent) then - call ESMF_LogWrite('atm2ocn_vmapname = '//trim(hafs_attr%atm2ocn_vmap), & - ESMF_LOGMSG_INFO) + call NUOPC_CompAttributeGet(gcomp, name='atm2ocn_vmapname', & + value=hafs_attr%atm2ocn_vmap, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return end if + ! Log Attribute Settings + if (btest(verbosity,16)) then + write(cvalue,"(I0)") verbosity + call ESMF_LogWrite(trim(subname)//': Verbosity = '// & + trim(cvalue), ESMF_LOGMSG_INFO) + write(cvalue,"(I0)") diagnostic + call ESMF_LogWrite(trim(subname)//': Diagnostic = '// & + trim(cvalue), ESMF_LOGMSG_INFO) + cvalue = hafs_attr%hafs_sysType + call ESMF_LogWrite(trim(subname)//': system_type = '// & + trim(cvalue), ESMF_LOGMSG_INFO) + call ESMF_LogWrite(trim(subname)//': normalization = '// & + trim(hafs_attr%mapnorm), ESMF_LOGMSG_INFO) + call ESMF_LogWrite(trim(subname)//': ice2atm_fmapname = '// & + trim(hafs_attr%ice2atm_fmap), ESMF_LOGMSG_INFO) + call ESMF_LogWrite(trim(subname)//': ice2atm_smapname = '// & + trim(hafs_attr%ice2atm_smap), ESMF_LOGMSG_INFO) + call ESMF_LogWrite(trim(subname)//': ocn2atm_smapname = '// & + trim(hafs_attr%ocn2atm_smap), ESMF_LOGMSG_INFO) + call ESMF_LogWrite(trim(subname)//': ocn2atm_fmapname = '// & + trim(hafs_attr%ocn2atm_fmap), ESMF_LOGMSG_INFO) + call ESMF_LogWrite(trim(subname)//': atm2ice_fmapname = '// & + trim(hafs_attr%atm2ice_fmap), ESMF_LOGMSG_INFO) + call ESMF_LogWrite(trim(subname)//': atm2ice_smapname = '// & + trim(hafs_attr%atm2ice_smap), ESMF_LOGMSG_INFO) + call ESMF_LogWrite(trim(subname)//': atm2ice_vmapname = '// & + trim(hafs_attr%atm2ice_vmap), ESMF_LOGMSG_INFO) + call ESMF_LogWrite(trim(subname)//': atm2ocn_fmapname = '// & + trim(hafs_attr%atm2ocn_fmap), ESMF_LOGMSG_INFO) + call ESMF_LogWrite(trim(subname)//': atm2ocn_smapname = '// & + trim(hafs_attr%atm2ocn_smap), ESMF_LOGMSG_INFO) + call ESMF_LogWrite(trim(subname)//': atm2ocn_vmapname = '// & + trim(hafs_attr%atm2ocn_vmap), ESMF_LOGMSG_INFO) + endif + + call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO) + end subroutine esmFldsExchange_hafs_attr + !----------------------------------------------------------------------------- + + function systemType_eq(type1, type2) + logical systemType_eq + type(systemType), intent(in) :: type1, type2 + systemType_eq = (type1%system == type2%system) + end function + + !----------------------------------------------------------------------------- + + subroutine systemType_tostring(string, tval) + character(len=*), intent(out) :: string + type(systemType), intent(in) :: tval + select case (tval%system) + case(SYS_CDP%system) + string = 'CDEPS' + case(SYS_UFS%system) + string = 'UFS' + case default + string = 'ERROR' + end select + end subroutine + + !----------------------------------------------------------------------------- + + subroutine systemType_frstring(tval, string) + type(systemType), intent(out) :: tval + character(len=*), intent(in) :: string + select case (ESMF_UtilStringUpperCase(string)) + case ('CDEPS') + tval = SYS_CDP + case ('UFS') + tval = SYS_UFS + case default + tval = SYS_ERR + end select + end subroutine + end module esmFldsExchange_hafs_mod diff --git a/mediator/fd_hafs.yaml b/mediator/fd_hafs.yaml deleted file mode 100644 index a4d737360..000000000 --- a/mediator/fd_hafs.yaml +++ /dev/null @@ -1,485 +0,0 @@ - field_dictionary: - version_number: 0.0.0 - institution: National ESPC, CSC & MCL Working Groups - source: automatically generated by the NUOPC Layer - description: Community-based dictionary for shared coupling fields - entries: - # - #----------------------------------- - # section: atmosphere export - #----------------------------------- - # - # - - standard_name: Faxa_snowc - canonical_units: kg m-2 s-1 - description: atmosphere export - # - - standard_name: Faxa_snowl - canonical_units: kg m-2 s-1 - description: atmosphere export - # - - standard_name: Faxa_swnet - canonical_units: W m-2 - description: atmosphere export - # - - standard_name: Faxa_lwnet - canonical_units: W m-2 - description: atmosphere export - # - - standard_name: Sa_topo - alias: inst_surface_height - canonical_units: m - description: atmosphere export - topographic height - # - - standard_name: Sa_z - alias: inst_height_lowest - canonical_units: m - description: atmosphere export - bottom layer height - # - - standard_name: Sa_pbot - alias: inst_pres_height_lowest - canonical_units: Pa - description: atmosphere export - pressure at lowest model layer - # - - standard_name: Sa_ptem - canonical_units: K - description: atmosphere export - bottom layer potential temperature - # - - standard_name: Faxa_lwdn - alias: mean_down_lw_flx - canonical_units: W m-2 - description: atmosphere export - mean downward SW heat flux - # - - standard_name: Faxa_swndf - alias: mean_down_sw_ir_dif_flx - canonical_units: W m-2 - description: atmosphere export - mean surface downward nir diffuse flux - # - - standard_name: Faxa_swndr - alias: mean_down_sw_ir_dir_flx - canonical_units: W m-2 - description: atmosphere export - mean surface downward nir direct flux - # - - standard_name: Faxa_swvdf - alias: mean_down_sw_vis_dif_flx - canonical_units: W m-2 - description: atmosphere export - mean surface downward uv+vis diffuse flux - # - - standard_name: Faxa_swvdr - alias: mean_down_sw_vis_dir_flx - canonical_units: W m-2 - description: atmosphere export - mean surface downward uv+visvdirect flux - # - - standard_name: Faxa_swdn - alias: mean_down_sw_flx - canonical_units: W m-2 - description: atmosphere export - mean downward SW heat flux - # - - standard_name: Faxa_rainc - canonical_units: kg m-2 s-1 - description: atmosphere export - # - - standard_name: Faxa_rainl - canonical_units: kg m-2 s-1 - description: atmosphere export - # - - standard_name: Faxa_rain - alias: mean_prec_rate - canonical_units: kg m-2 s-1 - description: atmosphere export - # - - standard_name: Faxa_lat - alias: mean_laten_heat_flx_atm - canonical_units: W m-2 - description: atmosphere export - # - - standard_name: Faxa_sen - alias: mean_sensi_heat_flx_atm - canonical_units: W m-2 - description: atmosphere export - # - - standard_name: Sa_pslv - alias: inst_pres_height_surface - canonical_units: Pa - description: atmosphere export - # - - standard_name: Sa_u - alias: inst_zonal_wind_height_lowest - canonical_units: m s-1 - description: atmosphere export - bottom layer zonal wind - # - - standard_name: Sa_v - alias: inst_merid_wind_height_lowest - canonical_units: m s-1 - description: atmosphere export - bottom layer meridional wind - # - - standard_name: Sa_wspd - alias: inst_wind_speed_height_lowest - canonical_units: m s-1 - description: atmosphere export - bottom layer wind speed - # - - standard_name: Sa_tbot - alias: inst_temp_height_lowest - canonical_units: K - description: atmosphere export - bottom layer temperature - # - - standard_name: Sa_tskn - alias: inst_temp_skin_temperature - canonical_units: K - description: atmosphere export - sea surface skin temperature - # - - standard_name: Sa_shum - alias: inst_spec_humid_height_lowest - canonical_units: kg kg-1 - description: atmosphere export - bottom layer specific humidity - # - - standard_name: Faxa_taux - alias: mean_zonal_moment_flx_atm - canonical_units: N m-2 - description: atmosphere export - zonal component of momentum flux - # - - standard_name: Faxa_tauy - alias: mean_merid_moment_flx_atm - canonical_units: N m-2 - description: atmosphere export - meridional component of momentum flux - # - - standard_name: Sa_dens - alias: air_density_height_lowest - canonical_units: kg m-3 - description: atmosphere export - density at the lowest model layer - # - #----------------------------------- - # section: atmosphere import - #----------------------------------- - # - - standard_name: Faxx_taux - alias: mean_zonal_moment_flx - canonical_units: N m-2 - description: atmosphere import - zonal component of momentum flux - # - - standard_name: Faxx_tauy - alias: mean_merid_moment_flx - canonical_units: N m-2 - description: atmosphere import - meridional component of momentum flux - # - - standard_name: Sx_anidf - canonical_units: 1 - description: atmosphere import - # - - standard_name: Sx_anidr - canonical_units: 1 - description: atmosphere import - # - - standard_name: Sx_avsdf - canonical_units: 1 - description: atmosphere import - # - - standard_name: Sx_avsdr - canonical_units: 1 - description: atmosphere import - # - - standard_name: Sx_tref - canonical_units: K - description: atmosphere import - # - - standard_name: Sx_qref - canonical_units: kg kg-1 - description: atmosphere import - # - - standard_name: Sx_t - alias: surface_temperature - canonical_units: K - description: atmosphere import - # - - standard_name: Sx_u10 - canonical_units: m - description: atmosphere import - # - #----------------------------------- - # section: ocean export to mediator - #----------------------------------- - # - - standard_name: So_t - alias: sea_surface_temperature - canonical_units: K - description: ocean export - # - - standard_name: So_s - alias: s_surf - canonical_units: g kg-1 - description: ocean export - # - - standard_name: So_ssq - canonical_units: kg kg-1 - description: ocean export - # - - standard_name: So_u - alias: ocn_current_zonal - canonical_units: m s-1 - description: ocean export - # - - standard_name: So_v - alias: ocn_current_merid - canonical_units: m s-1 - description: ocean export - # - - standard_name: So_ustar - canonical_units: m s-1 - description: ocean export - # - - standard_name: So_re - canonical_units: 1 - description: ocean export - # - - standard_name: So_duu10n - canonical_units: m2 s-2 - description: ocean export - # - - standard_name: So_omask - alias: ocean_mask - canonical_units: 1 - description: ocean export - # - - standard_name: So_ofrac - canonical_units: 1 - description: ocean export - # - #----------------------------------- - # section: ocean import - #----------------------------------- - # - - standard_name: Foxx_evap - alias: mean_evap_rate - canonical_units: kg m-2 s-1 - description: ocean import - specific humidity flux - # - - standard_name: Foxx_evap_wiso - alias: mean_evap_rate_wiso - canonical_units: kg m-2 s-1 - description: ocean import - specific humidity flux 16O, 18O, HDO - # - - standard_name: Foxx_swnet - alias: mean_net_sw_flx - canonical_units: W m-2 - description: ocean import - net shortwave radiation to ocean - # - - standard_name: Foxx_lwnet - alias: mean_net_lw_flx - canonical_units: W m-2 - description: ocean import - net long wave radiation to ocean - # - - standard_name: Foxx_lwup - canonical_units: W m-2 - description: ocean import - surface upward longwave heat flux - # - - standard_name: Foxx_swnet_vdr - alias: mean_net_sw_vis_dir_flx - canonical_units: W m-2 - description: ocean import - net shortwave visible direct radiation to ocean - # - - standard_name: Foxx_swnet_vdf - alias: mean_net_sw_vis_dif_flx - canonical_units: W m-2 - description: ocean import - net shortwave visible diffuse radiation to ocean - # - - standard_name: Foxx_swnet_idr - alias: mean_net_sw_ir_dir_flx - canonical_units: W m-2 - description: ocean import - net shortwave ir direct radiation to ocean - # - - standard_name: Foxx_swnet_idf - alias: mean_net_sw_ir_dif_flx - canonical_units: W m-2 - description: ocean import - net shortwave ir diffuse radiation to ocean - # - - standard_name: Foxx_sen - alias: mean_sensi_heat_flx - canonical_units: W m-2 - description: ocean import - sensible heat flux into ocean - # - - standard_name: Foxx_lat - canonical_units: W m-2 - description: ocean import - latent heat flux into ocean - # - - standard_name: Foxx_lat_wiso - canonical_units: W m-2 - description: ocean import - latent heat flux into ocean for 16O, 18O, HDO - # - - standard_name: Foxx_taux - alias: mean_zonal_moment_flx - canonical_units: N m-2 - description: ocean import - zonal surface stress - # - - standard_name: Foxx_tauy - alias: mean_merid_moment_flx - canonical_units: N m-2 - description: ocean import - meridional surface stress - # - #----------------------------------- - # section: sea-ice export - #----------------------------------- - # - - standard_name: Si_ifrac - alias: ice_fraction - canonical_units: 1 - description: sea-ice export to atm ice fraction (varies with time) - # - - standard_name: Si_imask - alias: ice_mask - canonical_units: 1 - description: sea-ice export - ice mask - # - - standard_name: Faii_swnet - canonical_units: W m-2 - description: sea-ice export to atm - # - - standard_name: Si_anidf - alias: inst_ice_ir_dif_albedo - canonical_units: 1 - description: sea-ice export to atm - # - - standard_name: Si_anidr - alias: inst_ice_ir_dir_albedo - canonical_units: 1 - description: sea-ice export to atm - # - - standard_name: Si_avsdf - alias: inst_ice_vis_dif_albedo - canonical_units: 1 - description: sea-ice export to atm - # - - standard_name: Si_avsdr - alias: inst_ice_vis_dir_albedo - canonical_units: 1 - description: sea-ice export to atm - # - - standard_name: Si_t - alias: sea_ice_temperature - canonical_units: K - description: sea-ice export - # - - standard_name: Si_tref - canonical_units: K - description: sea-ice export - # - - standard_name: Si_qref - canonical_units: kg kg-1 - description: sea-ice export to atm - # - - standard_name: Si_u10 - canonical_units: m - description: sea-ice export - # - - standard_name: Faii_taux - alias: stress_on_air_ice_zonal - canonical_units: N m-2 - description: sea-ice export to atm - air ice zonal stress - # - - standard_name: Faii_tauy - alias: stress_on_air_ice_merid - canonical_units: N m-2 - description: sea-ice export - air ice meridional stress - # - - standard_name: Fioi_swpen - alias: mean_sw_pen_to_ocn - canonical_units: W m-2 - description: sea-ice export to ocean - flux of shortwave through ice to ocean - # - - standard_name: Fioi_swpen_vdr - alias: mean_sw_pen_to_ocn_vis_dir_flx - canonical_units: W m-2 - description: sea-ice export to ocean - flux of vis dir shortwave through ice to ocean - # - - standard_name: Fioi_swpen_vdf - alias: mean_sw_pen_to_ocn_vis_dif_flx - canonical_units: W m-2 - description: sea-ice export to ocean - flux of vif dir shortwave through ice to ocean - # - - standard_name: Fioi_swpen_idr - alias: mean_sw_pen_to_ocn_ir_dir_flx - canonical_units: W m-2 - description: sea-ice export to ocean - flux of ir dir shortwave through ice to ocean - # - - standard_name: Fioi_swpen_idf - alias: mean_sw_pen_to_ocn_ir_dif_flx - canonical_units: W m-2 - description: sea-ice export to ocean - flux of ir dif shortwave through ice to ocean - # - - standard_name: Fioi_melth - alias: net_heat_flx_to_ocn - canonical_units: W m-2 - description: sea-ice export to ocean - net heat flux to ocean - # - - standard_name: Fioi_taux - alias: stress_on_ocn_ice_zonal - canonical_units: N m-2 - description: sea-ice export to ocean - ice ocean zonal stress - # - - standard_name: Fioi_tauy - alias: stress_on_ocn_ice_merid - canonical_units: N m-2 - description: sea-ice export to ocean - ice ocean meridional stress - # - #----------------------------------- - # section: sea-ice import - #----------------------------------- - # - # - #----------------------------------- - # section: land export - #----------------------------------- - # - - standard_name: Sl_lfrac - canonical_units: 1 - description: land export - # - - standard_name: Fall_swnet - canonical_units: W m-2 - description: land export - # - - standard_name: Sl_anidf - canonical_units: 1 - description: land export - # - - standard_name: Sl_anidr - canonical_units: 1 - description: land export - # - - standard_name: Sl_avsdf - canonical_units: 1 - description: land export - # - - standard_name: Sl_avsdr - canonical_units: 1 - description: land export - # - - standard_name: Sl_t - canonical_units: K - description: land export - # - - standard_name: Sl_tref - canonical_units: K - description: mediator export to glc - no elevation classes - # - - standard_name: Sl_qref - canonical_units: kg kg-1 - description: land export - # - - standard_name: Fall_taux - canonical_units: N m-2 - description: land export - # - - standard_name: Fall_tauy - canonical_units: N m-2 - description: land export - # - - standard_name: Sl_u10 - canonical_units: m - description: land export - # - #----------------------------------- - # mediator fields - #----------------------------------- - # - - standard_name: cpl_scalars - canonical_units: unitless diff --git a/mediator/fd_nems.yaml b/mediator/fd_nems.yaml index 6ab76f8db..1fc70726d 100644 --- a/mediator/fd_nems.yaml +++ b/mediator/fd_nems.yaml @@ -64,11 +64,27 @@ canonical_units: kg m-2 s-1 description: atmosphere export # + - standard_name: Faxa_rainc + canonical_units: kg m-2 s-1 + description: atmosphere export + # + - standard_name: Faxa_rainl + canonical_units: kg m-2 s-1 + description: atmosphere export + # - standard_name: Faxa_snow alias: mean_fprec_rate canonical_units: kg m-2 s-1 description: atmosphere export # + - standard_name: Faxa_snowc + canonical_units: kg m-2 s-1 + description: atmosphere export + # + - standard_name: Faxa_snowl + canonical_units: kg m-2 s-1 + description: atmosphere export + # - standard_name: Faxa_swnet canonical_units: W m-2 description: atmosphere export @@ -122,6 +138,11 @@ canonical_units: K description: atmosphere export - bottom layer temperature # + - standard_name: Sa_tskn + alias: inst_temp_skin_temperature + canonical_units: K + description: atmosphere export - sea surface skin temperature + # - standard_name: Sa_u alias: inst_zonal_wind_height_lowest canonical_units: m s-1 @@ -132,11 +153,21 @@ canonical_units: m s-1 description: atmosphere export - bottom layer meridional wind # + - standard_name: Sa_wspd + alias: inst_wind_speed_height_lowest + canonical_units: m s-1 + description: atmosphere export - bottom layer wind speed + # - standard_name: Sa_z alias: inst_height_lowest canonical_units: m description: atmosphere export - bottom layer height # + - standard_name: Sa_topo + alias: inst_surface_height + canonical_units: m + description: atmosphere export - topographic height + # - standard_name: Faxa_taux alias: mean_zonal_moment_flx_atm canonical_units: N m-2 @@ -483,6 +514,15 @@ canonical_units: W m-2 description: ocean import - net shortwave ir diffuse radiation to ocean # + - standard_name: Foxx_sen + alias: mean_sensi_heat_flx + canonical_units: W m-2 + description: ocean import - sensible heat flux into ocean + # + - standard_name: Foxx_lat + canonical_units: W m-2 + description: ocean import - latent heat flux into ocean + # - standard_name: Foxx_taux alias: mean_zonal_moment_flx canonical_units: N m-2 diff --git a/mediator/med.F90 b/mediator/med.F90 index 06035a7a6..9b2bbcbef 100644 --- a/mediator/med.F90 +++ b/mediator/med.F90 @@ -38,6 +38,8 @@ module MED use esmFlds , only : med_fldList_GetNumFlds, med_fldList_GetFldNames, med_fldList_GetFldInfo use esmFlds , only : med_fldList_Document_Mapping, med_fldList_Document_Merging use esmFlds , only : coupling_mode + use esmFlds , only : med_name, atm_name, lnd_name, ocn_name + use esmFlds , only : ice_name, rof_name, wav_name, glc_name use esmFldsExchange_nems_mod , only : esmFldsExchange_nems use esmFldsExchange_cesm_mod , only : esmFldsExchange_cesm use esmFldsExchange_hafs_mod , only : esmFldsExchange_hafs @@ -778,42 +780,56 @@ subroutine InitializeIPDv03p1(gcomp, importState, exportState, clock, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then if (trim(cvalue) /= 'satm') atm_present = "true" + atm_name = trim(cvalue) end if + call NUOPC_CompAttributeGet(gcomp, name='LND_model', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then if (trim(cvalue) /= 'slnd') lnd_present = "true" + lnd_name = trim(cvalue) end if + call NUOPC_CompAttributeGet(gcomp, name='OCN_model', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then if (trim(cvalue) /= 'socn') ocn_present = "true" + ocn_name = trim(cvalue) end if + call NUOPC_CompAttributeGet(gcomp, name='ICE_model', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then if (trim(cvalue) /= 'sice') ice_present = "true" + ice_name = trim(cvalue) end if + call NUOPC_CompAttributeGet(gcomp, name='ROF_model', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then if (trim(cvalue) /= 'srof') rof_present = "true" + rof_name = trim(cvalue) end if + call NUOPC_CompAttributeGet(gcomp, name='WAV_model', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then if (trim(cvalue) /= 'swav') wav_present = "true" + wav_name = trim(cvalue) end if + call NUOPC_CompAttributeGet(gcomp, name='GLC_model', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then if (trim(cvalue) /= 'sglc') glc_present = "true" + glc_name = trim(cvalue) end if call NUOPC_CompAttributeGet(gcomp, name='mediator_present', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then med_present = trim(cvalue) + med_name = trim(cvalue) end if call NUOPC_CompAttributeSet(gcomp, name="atm_present", value=atm_present, rc=rc) @@ -835,14 +851,14 @@ subroutine InitializeIPDv03p1(gcomp, importState, exportState, clock, rc) if (mastertask) then write(logunit,*) - write(logunit,*) "atm_present="//trim(atm_present) - write(logunit,*) "lnd_present="//trim(lnd_present) - write(logunit,*) "ocn_present="//trim(ocn_present) - write(logunit,*) "ice_present="//trim(ice_present) - write(logunit,*) "rof_present="//trim(rof_present) - write(logunit,*) "wav_present="//trim(wav_present) - write(logunit,*) "glc_present="//trim(glc_present) - write(logunit,*) "med_present="//trim(med_present) + if (trim(atm_present).eq."true") write(logunit,*) "atm_name="//trim(atm_name) + if (trim(lnd_present).eq."true") write(logunit,*) "lnd_name="//trim(lnd_name) + if (trim(ocn_present).eq."true") write(logunit,*) "ocn_name="//trim(ocn_name) + if (trim(ice_present).eq."true") write(logunit,*) "ice_name="//trim(ice_name) + if (trim(rof_present).eq."true") write(logunit,*) "rof_name="//trim(rof_name) + if (trim(wav_present).eq."true") write(logunit,*) "wav_name="//trim(wav_name) + if (trim(glc_present).eq."true") write(logunit,*) "glc_name="//trim(glc_name) + if (trim(med_present).eq."true") write(logunit,*) "med_name="//trim(med_name) write(logunit,*) end if diff --git a/mediator/med_fraction_mod.F90 b/mediator/med_fraction_mod.F90 index 045075374..0d083f0e6 100644 --- a/mediator/med_fraction_mod.F90 +++ b/mediator/med_fraction_mod.F90 @@ -143,6 +143,7 @@ subroutine med_fraction_init(gcomp, rc) use ESMF , only : ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_LOGMSG_ERROR use ESMF , only : ESMF_SUCCESS, ESMF_FAILURE + use ESMF , only : ESMF_LogSetError, ESMF_RC_NOT_VALID use ESMF , only : ESMF_GridComp, ESMF_GridCompGet, ESMF_StateIsCreated use ESMF , only : ESMF_FieldBundle, ESMF_FieldBundleIsCreated, ESMF_FieldBundleDestroy use ESMF , only : ESMF_FieldBundleGet @@ -238,7 +239,9 @@ subroutine med_fraction_init(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call fldbun_getdata1d(is_local%wrap%FBFrac(complnd) , 'lfrac', lfrac, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - lfrac(:) = Sl_lfrin(:) + if (associated(lfrac)) then + lfrac(:) = Sl_lfrin(:) + end if end if !--------------------------------------- @@ -251,7 +254,9 @@ subroutine med_fraction_init(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call fldbun_getdata1d(is_local%wrap%FBFrac(compice), 'ifrac', ifrac, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - ifrac(:) = Si_imask(:) + if (associated(ifrac)) then + ifrac(:) = Si_imask(:) + end if end if !--------------------------------------- @@ -299,7 +304,9 @@ subroutine med_fraction_init(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call fldbun_getdata1d(is_local%wrap%FBFrac(compocn), 'ofrac', ofrac, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - ofrac(:) = So_omask(:) + if (associated(ofrac)) then + ofrac(:) = So_omask(:) + end if end if !--------------------------------------- @@ -356,15 +363,17 @@ subroutine med_fraction_init(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call fldbun_getdata1d(is_local%wrap%FBfrac(compatm), 'ofrac', ofrac, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - if (is_local%wrap%comp_present(complnd)) then - do n = 1,size(lfrac) - lfrac(n) = 1.0_R8 - ofrac(n) - if (abs(lfrac(n)) < eps_fraclim) then - lfrac(n) = 0.0_R8 - end if - end do - else - lfrac(:) = 0.0_R8 + if (associated(lfrac)) then + if (is_local%wrap%comp_present(complnd)) then + do n = 1,size(lfrac) + lfrac(n) = 1.0_R8 - ofrac(n) + if (abs(lfrac(n)) < eps_fraclim) then + lfrac(n) = 0.0_R8 + end if + end do + else + lfrac(:) = 0.0_R8 + end if end if else if (is_local%wrap%comp_present(complnd) .and. is_local%wrap%med_coupling_active(complnd,compatm)) then @@ -395,12 +404,14 @@ subroutine med_fraction_init(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call fldbun_getdata1d(is_local%wrap%FBfrac(compatm), 'ofrac', ofrac, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - do n = 1,size(lfrac) - ofrac(n) = 1.0_R8 - lfrac(n) - if (abs(ofrac(n)) < eps_fraclim) then - ofrac(n) = 0.0_R8 - end if - end do + if (associated(ofrac)) then + do n = 1,size(lfrac) + ofrac(n) = 1.0_R8 - lfrac(n) + if (abs(ofrac(n)) < eps_fraclim) then + ofrac(n) = 0.0_R8 + end if + end do + end if end if end if @@ -448,12 +459,16 @@ subroutine med_fraction_init(gcomp, rc) call fldbun_getdata1d(is_local%wrap%FBImp(comprof,comprof), 'frac', frac, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call fldbun_getdata1d(is_local%wrap%FBfrac(comprof), 'rfrac', rfrac, rc) - rfrac(:) = frac(:) + if (associated(rfrac)) then + rfrac(:) = frac(:) + endif else ! Set 'rfrac' in FBfrac(comprof) to 1. call fldbun_getdata1d(is_local%wrap%FBfrac(comprof), 'rfrac', rfrac, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - rfrac(:) = 1.0_R8 + if (associated(rfrac)) then + rfrac(:) = 1.0_R8 + endif endif ! Set 'lfrac' in FBFrac(comprof) @@ -489,12 +504,16 @@ subroutine med_fraction_init(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call fldbun_getdata1d(is_local%wrap%FBfrac(compglc(ns)), 'gfrac', gfrac, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - gfrac(:) = frac(:) + if (associated(gfrac)) then + gfrac(:) = frac(:) + endif else ! Set 'gfrac' in FBfrac(compglc(ns)) to 1. call fldbun_getdata1d(is_local%wrap%FBfrac(compglc(ns)), 'gfrac', gfrac, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - gfrac(:) = 1.0_R8 + if (associated(gfrac)) then + gfrac(:) = 1.0_R8 + endif endif ! Set 'lfrac' in FBFrac(compglc(ns)) @@ -525,7 +544,9 @@ subroutine med_fraction_init(gcomp, rc) ! Set 'wfrac' in FBfrac(compwav) to 1. call fldbun_getdata1d(is_local%wrap%FBfrac(compwav), 'wfrac', wfrac, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - wfrac(:) = 1.0_R8 + if (associated(wfrac)) then + wfrac(:) = 1.0_R8 + endif endif !--------------------------------------- @@ -661,10 +682,14 @@ subroutine med_fraction_set(gcomp, rc) ! So in it is (1-land fraction) on the atm grid ! set ifrac - ifrac(:) = Si_ifrac(:) * Si_imask(:) + if (associated(ifrac)) then + ifrac(:) = Si_ifrac(:) * Si_imask(:) + endif ! set ofrac = Si_imask - ifrac - ofrac(:) = Si_imask(:) - ifrac(:) + if (associated(ofrac)) then + ofrac(:) = Si_imask(:) - ifrac(:) + endif ! ------------------------------------------- ! Set FBfrac(compocn) diff --git a/mediator/med_map_mod.F90 b/mediator/med_map_mod.F90 index 2467d56a3..c7e10469f 100644 --- a/mediator/med_map_mod.F90 +++ b/mediator/med_map_mod.F90 @@ -213,9 +213,11 @@ subroutine med_map_routehandles_initfrom_field(n1, n2, fldsrc, flddst, mapindex, use esmFlds , only : mapbilnr, mapconsf, mapconsd, mappatch, mappatch_uv3d, mapfcopy use esmFlds , only : mapunset, mapnames, nmappers use esmFlds , only : mapnstod, mapnstod_consd, mapnstod_consf, mapnstod_consd + use esmFlds , only : mapfillv_bilnr use esmFlds , only : ncomps, compatm, compice, compocn, compname use esmFlds , only : mapfcopy, mapconsd, mapconsf, mapnstod use esmFlds , only : coupling_mode, compname + use esmFlds , only : atm_name use med_constants_mod , only : ispval_mask => med_constants_ispval_mask ! input/output variables @@ -272,6 +274,15 @@ subroutine med_map_routehandles_initfrom_field(n1, n2, fldsrc, flddst, mapindex, srcMaskValue = ispval_mask if (n1 == compocn .or. n1 == compice) srcMaskValue = 0 if (n2 == compocn .or. n2 == compice) dstMaskValue = 0 + if (n1 == compatm .and. n2 == compocn) then + if (trim(atm_name).ne.'datm') then + srcMaskValue = 1 + endif + dstMaskValue = 0 + elseif (n1 == compocn .and. n2 == compatm) then + srcMaskValue = 0 + dstMaskValue = ispval_mask + endif end if write(string,'(a)') trim(compname(n1))//' to '//trim(compname(n2)) @@ -306,6 +317,19 @@ subroutine med_map_routehandles_initfrom_field(n1, n2, fldsrc, flddst, mapindex, ignoreDegenerate=.true., & unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return + else if (mapindex == mapfillv_bilnr) then + if (mastertask) then + write(logunit,'(A)') trim(subname)//' creating RH '//trim(mapname)//' for '//trim(string) + end if + call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=routehandles(mapfillv_bilnr), & + srcMaskValues=(/srcMaskValue/), & + dstMaskValues=(/dstMaskValue/), & + regridmethod=ESMF_REGRIDMETHOD_BILINEAR, & + polemethod=polemethod, & + srcTermProcessing=srcTermProcessing_Value, & + ignoreDegenerate=.true., & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return else if (mapindex == mapconsf .or. mapindex == mapnstod_consf) then if (mastertask) then write(logunit,'(A)') trim(subname)//' creating RH '//trim(mapname)//' for '//trim(string) @@ -762,6 +786,7 @@ subroutine med_map_field_packed(FBSrc, FBDst, FBFracSrc, field_normOne, packed_d use ESMF , only : ESMF_Field, ESMF_FieldGet, ESMF_FieldIsCreated use ESMF , only : ESMF_FieldBundle, ESMF_FieldBundleGet + use ESMF , only : ESMF_FieldBundleIsCreated use ESMF , only : ESMF_FieldRedist, ESMF_RouteHandle use esmFlds , only : nmappers, mapfcopy, mappatch_uv3d, mappatch use med_internalstate_mod , only : packed_data_type @@ -798,16 +823,21 @@ subroutine med_map_field_packed(FBSrc, FBDst, FBFracSrc, field_normOne, packed_d rc = ESMF_SUCCESS ! Get field count for both FBsrc and FBdst - call ESMF_FieldBundleGet(FBsrc, fieldCount=fieldCount, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (ESMF_FieldBundleIsCreated(FBsrc)) then + call ESMF_FieldBundleGet(FBsrc, fieldCount=fieldCount, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(fieldlist_src(fieldcount)) - call ESMF_FieldBundleGet(FBsrc, fieldlist=fieldlist_src, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(fieldlist_src(fieldcount)) + call ESMF_FieldBundleGet(FBsrc, fieldlist=fieldlist_src, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + allocate(fieldlist_dst(fieldcount)) + call ESMF_FieldBundleGet(FBdst, fieldlist=fieldlist_dst, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + else + fieldcount=0 + endif - allocate(fieldlist_dst(fieldcount)) - call ESMF_FieldBundleGet(FBdst, fieldlist=fieldlist_dst, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return ! Loop over mapping types do mapindex = 1,nmappers @@ -955,8 +985,10 @@ subroutine med_map_field_packed(FBSrc, FBDst, FBFracSrc, field_normOne, packed_d end if end do ! end of loop over mapindex - deallocate(fieldlist_src) - deallocate(fieldlist_dst) + if (ESMF_FieldBundleIsCreated(FBsrc)) then + deallocate(fieldlist_src) + deallocate(fieldlist_dst) + end if call t_stopf('MED:'//subname) @@ -1085,12 +1117,15 @@ subroutine med_map_field(field_src, field_dst, routehandles, maptype, fldname, r use ESMF , only : ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_SUCCESS use ESMF , only : ESMF_LOGMSG_ERROR, ESMF_FAILURE, ESMF_MAXSTR + use ESMF , only : ESMF_KIND_R8 use ESMF , only : ESMF_Field, ESMF_FieldRegrid + use ESMF , only : ESMF_FieldFill use ESMF , only : ESMF_TERMORDER_SRCSEQ, ESMF_Region_Flag, ESMF_REGION_TOTAL use ESMF , only : ESMF_REGION_SELECT use ESMF , only : ESMF_RouteHandle use esmFlds , only : mapnstod_consd, mapnstod_consf, mapnstod_consd, mapnstod use esmFlds , only : mapconsd, mapconsf + use esmFlds , only : mapfillv_bilnr use med_methods_mod , only : Field_diagnose => med_methods_Field_diagnose ! input/output variables @@ -1104,6 +1139,7 @@ subroutine med_map_field(field_src, field_dst, routehandles, maptype, fldname, r ! local variables logical :: checkflag = .false. character(len=CS) :: lfldname + real(ESMF_KIND_R8), parameter :: fillValue = 9.99e20_ESMF_KIND_R8 character(len=*), parameter :: subname='(module_MED_map:med_map_field) ' !--------------------------------------------------- @@ -1145,6 +1181,20 @@ subroutine med_map_field(field_src, field_dst, routehandles, maptype, fldname, r call Field_diagnose(field_dst, lfldname, " --> after consf: ", rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return end if + else if (maptype == mapfillv_bilnr) then + call ESMF_FieldFill(field_dst, dataFillScheme="const", const1=fillValue, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (dbug_flag > 1) then + call Field_diagnose(field_dst, lfldname, " --> after fillv: ", rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end if + call ESMF_FieldRegrid(field_src, field_dst, routehandle=RouteHandles(mapfillv_bilnr), & + termorderflag=ESMF_TERMORDER_SRCSEQ, checkflag=checkflag, zeroregion=ESMF_REGION_SELECT, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + if (dbug_flag > 1) then + call Field_diagnose(field_dst, lfldname, " --> after bilnr: ", rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end if else call ESMF_FieldRegrid(field_src, field_dst, routehandle=RouteHandles(maptype), & termorderflag=ESMF_TERMORDER_SRCSEQ, checkflag=checkflag, zeroregion=ESMF_REGION_TOTAL, rc=rc) diff --git a/mediator/med_methods_mod.F90 b/mediator/med_methods_mod.F90 index 63eb4890c..9a88aba32 100644 --- a/mediator/med_methods_mod.F90 +++ b/mediator/med_methods_mod.F90 @@ -709,6 +709,7 @@ subroutine med_methods_FB_reset(FB, value, rc) ! ---------------------------------------------- use ESMF, only : ESMF_FieldBundle, ESMF_FieldBundleGet, ESMF_Field + use ESMF, only : ESMF_FieldBundleIsCreated ! intput/output variables type(ESMF_FieldBundle) , intent(inout) :: FB @@ -737,11 +738,16 @@ subroutine med_methods_FB_reset(FB, value, rc) lvalue = value endif - call ESMF_FieldBundleGet(FB, fieldCount=fieldCount, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - allocate(lfieldnamelist(fieldCount)) - call ESMF_FieldBundleGet(FB, fieldNameList=lfieldnamelist, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + if (ESMF_FieldBundleIsCreated(fieldbundle=FB)) then + call ESMF_FieldBundleGet(FB, fieldCount=fieldCount, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + allocate(lfieldnamelist(fieldCount)) + call ESMF_FieldBundleGet(FB, fieldNameList=lfieldnamelist, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + fieldCount=0 + endif + do n = 1, fieldCount call ESMF_FieldBundleGet(FB, fieldName=trim(lfieldnamelist(n)), field=lfield, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -761,7 +767,10 @@ subroutine med_methods_FB_reset(FB, value, rc) return endif enddo - deallocate(lfieldnamelist) + + if (ESMF_FieldBundleIsCreated(fieldbundle=FB)) then + deallocate(lfieldnamelist) + endif if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO) diff --git a/mediator/med_utils_mod.F90 b/mediator/med_utils_mod.F90 index 12a846466..fc012217b 100644 --- a/mediator/med_utils_mod.F90 +++ b/mediator/med_utils_mod.F90 @@ -22,13 +22,11 @@ subroutine med_memcheck(string, level, mastertask) integer, intent(in) :: level logical, intent(in) :: mastertask integer :: ierr -#ifndef INTERNAL_PIO_INIT #ifdef CESMCOUPLED integer, external :: GPTLprint_memusage if((mastertask .and. memdebug_level > level) .or. memdebug_level > level+1) then ierr = GPTLprint_memusage(string) endif -#endif #endif end subroutine med_memcheck diff --git a/util/Makefile b/util/Makefile index 58b97df4f..5cb72884a 100644 --- a/util/Makefile +++ b/util/Makefile @@ -4,6 +4,10 @@ endif include $(ESMFMKFILE) +ifndef PIO_INC +$(error PIO_INC should point to PIO include directory.) +endif + LIBRARY = libcmeps_util.a OBJ1= \ @@ -26,10 +30,9 @@ $(LIBRARY): $(OBJ1) %.o: %.F90.in perl genf90.pl $< > $(@:.o=.F90) - $(ESMF_F90COMPILER) -c $(ESMF_F90COMPILEOPTS) $(ESMF_F90COMPILEPATHS) -I$(PIO_ROOT)/include -DFORTRANUNDERSCORE -DCPRINTEL $(@:.o=.F90) - + $(ESMF_F90COMPILER) -c $(ESMF_F90COMPILEOPTS) $(ESMF_F90COMPILEPATHS) -I$(PIO_INC) -DFORTRANUNDERSCORE -DCPRINTEL $(@:.o=.F90) %.o: %.F90 - $(ESMF_F90COMPILER) -c $(ESMF_F90COMPILEOPTS) $(ESMF_F90COMPILEPATHS) -I$(PIO_ROOT)/include -I. $*.F90 + $(ESMF_F90COMPILER) -c $(ESMF_F90COMPILEOPTS) $(ESMF_F90COMPILEPATHS) -I$(PIO_INC) -I. $*.F90 clean: $(RM) -f $(LIBRARY) *.f90 *.i90 *.o *.mod