From 864600801593e1c08345188f89a9c41067bd5a0f Mon Sep 17 00:00:00 2001 From: Daniel Rosen Date: Thu, 3 Sep 2020 10:16:44 -0600 Subject: [PATCH] Fix CPP ESMF_VERSION_MAJOR and ESMF_VERSION_MINOR definitions. --- mediator/Makefile | 5 +++++ mediator/esmFlds.F90 | 21 ++++++++++++--------- mediator/med.F90 | 12 +++++++++--- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/mediator/Makefile b/mediator/Makefile index fae000dae..8e8a79977 100644 --- a/mediator/Makefile +++ b/mediator/Makefile @@ -12,6 +12,11 @@ ifdef INTERNAL_PIO_INIT CPPDEFS := -DINTERNAL_PIO_INIT endif +ESMF_VERSION_MAJOR ?= 0 +ESMF_VERSION_MINOR ?= 0 +CPPDEFS += -DESMF_VERSION_MAJOR=$(ESMF_VERSION_MAJOR) +CPPDEFS += -DESMF_VERSION_MINOR=$(ESMF_VERSION_MINOR) + LIBRARY := libcmeps.a OBJ = $(patsubst %.F90, %.o, $(wildcard *.F90)) diff --git a/mediator/esmFlds.F90 b/mediator/esmFlds.F90 index 010aa3447..f57575d0c 100644 --- a/mediator/esmFlds.F90 +++ b/mediator/esmFlds.F90 @@ -358,9 +358,11 @@ subroutine med_fldList_Realize(state, fldList, flds_scalar_name, flds_scalar_num use ESMF , only : ESMF_StateGet, ESMF_LogFoundError use ESMF , only : ESMF_LogWrite, ESMF_LOGMSG_ERROR, ESMF_FAILURE, ESMF_LOGERR_PASSTHRU use ESMF , only : ESMF_LOGMSG_INFO, ESMF_StateRemove, ESMF_SUCCESS -#if ESMF_VERSION_MINOR > 0 +#if ESMF_VERSION_MAJOR >= 8 +#if ESMF_VERSION_MINOR > 0 use ESMF , only : ESMF_STATEINTENT_IMPORT, ESMF_STATEINTENT_EXPORT, ESMF_StateIntent_Flag use ESMF , only : ESMF_RC_ARG_BAD, ESMF_LogSetError, operator(==) +#endif #endif ! input/output variables type(ESMF_State) , intent(inout) :: state @@ -378,9 +380,11 @@ subroutine med_fldList_Realize(state, fldList, flds_scalar_name, flds_scalar_num type(ESMF_Field) :: field character(CS) :: shortname character(CS) :: stdname -#if ESMF_VERSION_MINOR > 0 - type(ESMF_StateIntent_Flag) :: stateIntent character(ESMF_MAXSTR) :: transferActionAttr +#if ESMF_VERSION_MAJOR >= 8 +#if ESMF_VERSION_MINOR > 0 + type(ESMF_StateIntent_Flag) :: stateIntent +#endif #endif character(ESMF_MAXSTR) :: transferAction character(ESMF_MAXSTR), pointer :: StandardNameList(:) @@ -445,7 +449,9 @@ subroutine med_fldList_Realize(state, fldList, flds_scalar_name, flds_scalar_num #endif nflds = size(fldList%flds) -#if ESMF_VERSION_MINOR > 0 + transferActionAttr="TransferActionGeomObject" +#if ESMF_VERSION_MAJOR >= 8 +#if ESMF_VERSION_MINOR > 0 call ESMF_StateGet(state, stateIntent=stateIntent, rc=rc) if (stateIntent==ESMF_STATEINTENT_EXPORT) then transferActionAttr="ProducerTransferAction" @@ -459,6 +465,7 @@ subroutine med_fldList_Realize(state, fldList, flds_scalar_name, flds_scalar_num rcToReturn=rc) return ! bail out endif +#endif #endif do n = 1, nflds @@ -469,12 +476,8 @@ subroutine med_fldList_Realize(state, fldList, flds_scalar_name, flds_scalar_num call ESMF_StateGet(state, field=field, itemName=trim(shortname), rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return -#if ESMF_VERSION_MINOR > 0 - call NUOPC_GetAttribute(field, name=TransferActionAttr, value=transferAction, rc=rc) -#else - call NUOPC_GetAttribute(field, name="TransferActionGeomObject", value=transferAction, rc=rc) -#endif + call NUOPC_GetAttribute(field, name=TransferActionAttr, value=transferAction, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return if (trim(transferAction) == "accept") then ! accept diff --git a/mediator/med.F90 b/mediator/med.F90 index a1c627fee..b3f44dbf7 100644 --- a/mediator/med.F90 +++ b/mediator/med.F90 @@ -741,9 +741,11 @@ subroutine InitializeIPDv03p3(gcomp, importState, exportState, clock, rc) use ESMF , only : ESMF_GridComp, ESMF_State, ESMF_Clock, ESMF_VM, ESMF_SUCCESS use ESMF , only : ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_TimeInterval use ESMF , only : ESMF_VMGet, ESMF_StateIsCreated, ESMF_GridCompGet -#if ESMF_VERSION_MINOR > 0 +#if ESMF_VERSION_MAJOR >= 8 +#if ESMF_VERSION_MINOR > 0 use ESMF , only : ESMF_StateSet, ESMF_StateIntent_Import, ESMF_StateIntent_Export use ESMF , only : ESMF_StateIntent_Flag +#endif #endif ! Input/output variables type(ESMF_GridComp) :: gcomp @@ -775,9 +777,11 @@ subroutine InitializeIPDv03p3(gcomp, importState, exportState, clock, rc) ! Realize States do n = 1,ncomps if (ESMF_StateIsCreated(is_local%wrap%NStateImp(n), rc=rc)) then -#if ESMF_VERSION_MINOR > 0 +#if ESMF_VERSION_MAJOR >= 8 +#if ESMF_VERSION_MINOR > 0 call ESMF_StateSet(is_local%wrap%NStateImp(n), stateIntent=ESMF_StateIntent_Import, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return +#endif #endif call med_fldList_Realize(is_local%wrap%NStateImp(n), fldListFr(n), & is_local%wrap%flds_scalar_name, is_local%wrap%flds_scalar_num, & @@ -785,9 +789,11 @@ subroutine InitializeIPDv03p3(gcomp, importState, exportState, clock, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return endif if (ESMF_StateIsCreated(is_local%wrap%NStateExp(n), rc=rc)) then -#if ESMF_VERSION_MINOR > 0 +#if ESMF_VERSION_MAJOR >= 8 +#if ESMF_VERSION_MINOR > 0 call ESMF_StateSet(is_local%wrap%NStateExp(n), stateIntent=ESMF_StateIntent_Export, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return +#endif #endif call med_fldList_Realize(is_local%wrap%NStateExp(n), fldListTo(n), & is_local%wrap%flds_scalar_name, is_local%wrap%flds_scalar_num, &