From 285ff051ba6a78142d784c77f47711b9a103a88c Mon Sep 17 00:00:00 2001 From: Gerhard Theurich Date: Fri, 6 Dec 2024 11:03:32 -0800 Subject: [PATCH 1/6] Implement ESMF_InfoLog() for more standard (and convenient) way to log the contents of an Info object. --- .../Base/interface/ESMF_Info.F90 | 68 ++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/src/Infrastructure/Base/interface/ESMF_Info.F90 b/src/Infrastructure/Base/interface/ESMF_Info.F90 index 339df16403..d1ab657d54 100644 --- a/src/Infrastructure/Base/interface/ESMF_Info.F90 +++ b/src/Infrastructure/Base/interface/ESMF_Info.F90 @@ -223,6 +223,7 @@ module ESMF_InfoMod public ESMF_InfoSetDirty public ESMF_InfoIsSet public ESMF_InfoIsPresent +public ESMF_InfoLog public ESMF_InfoPrint public ESMF_InfoDump public ESMF_InfoUpdate @@ -2495,6 +2496,71 @@ end function ESMF_InfoIsSet !------------------------------------------------------------------------------ +#undef ESMF_METHOD +#define ESMF_METHOD "ESMF_InfoLog()" +!BOP +! !IROUTINE: ESMF_InfoLog - Log contents of an Info object +! +! !INTERFACE: +subroutine ESMF_InfoLog(info, keywordEnforcer, prefix, logMsgFlag, rc) +! !ARGUMENTS: + type(ESMF_Info), intent(in) :: info +type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below + character(len=*), intent(in), optional :: prefix + type(ESMF_LogMsg_Flag), intent(in), optional :: logMsgFlag + integer, intent(out), optional :: rc +! +! !DESCRIPTION: +! Write information about {\tt info} object to the ESMF default Log. +! +! The arguments are: +! \begin{description} +! \item[info] +! {\tt ESMF\_Info} object logged. +! \item [{[prefix]}] +! String to prefix the log message. Default is no prefix. +! \item [{[logMsgFlag]}] +! Type of log message generated. See section \ref{const:logmsgflag} for +! a list of valid message types. Default is {\tt ESMF\_LOGMSG\_INFO}. +! \item[{[rc]}] +! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors. +! \end{description} +! +!EOP +!------------------------------------------------------------------------------ + integer :: localrc + character(:), allocatable :: output, local_preString + + ! initialize return code; assume routine not implemented + localrc = ESMF_RC_NOT_IMPL + if (present(rc)) rc = ESMF_RC_NOT_IMPL + + !TODO: This should really be implemented on the C++ side where we could + !TODO: correctly deal with line breaks and prepend the prefix string on + !TODO: each line, much like for ESMF_HConfigLog(). + !TODO: For now implemented quickly on the Fortran side to make available. + + if (present(prefix)) then + local_preString = prefix + else + local_preString = "" + endif + + output = ESMF_InfoDump(info, indent=2, rc=localrc) + if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, & + ESMF_CONTEXT, rcToReturn=rc)) return + + call ESMF_LogWrite(local_preString//output, logMsgFlag, rc=localrc) + if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, & + ESMF_CONTEXT, rcToReturn=rc)) return + + ! return successfully + if (present(rc)) rc = ESMF_SUCCESS + +end subroutine ESMF_InfoLog + +!------------------------------------------------------------------------------ + #undef ESMF_METHOD #define ESMF_METHOD "ESMF_InfoPrint()" !BOP @@ -3929,4 +3995,4 @@ subroutine ESMF_InfoWriteJSON(info, filename, keywordEnforcer, rc) if (present(rc)) rc = ESMF_SUCCESS end subroutine ESMF_InfoWriteJSON -end module ESMF_InfoMod !===================================================== \ No newline at end of file +end module ESMF_InfoMod !===================================================== From e190c6ec24acdd0449af362a4973b5b4576ba666 Mon Sep 17 00:00:00 2001 From: Gerhard Theurich Date: Fri, 6 Dec 2024 11:04:39 -0800 Subject: [PATCH 2/6] Utilize InfoLog() inside StateLog()... at least during development. --- .../State/src/ESMF_StateAPI.cppF90 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Superstructure/State/src/ESMF_StateAPI.cppF90 b/src/Superstructure/State/src/ESMF_StateAPI.cppF90 index 3e786803e4..3e347eaeb5 100644 --- a/src/Superstructure/State/src/ESMF_StateAPI.cppF90 +++ b/src/Superstructure/State/src/ESMF_StateAPI.cppF90 @@ -59,6 +59,7 @@ module ESMF_StateAPIMod use ESMF_IOUtilMod use ESMF_UtilMod use ESMF_UtilStringMod + use ESMF_InfoMod implicit none @@ -1852,6 +1853,21 @@ type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below ESMF_ERR_PASSTHRU, & ESMF_CONTEXT, rcToReturn=rc)) return +#if 1 +!TODO: need a way to indicate from calling side that info should be logged + block + type(ESMF_Info) :: info + call ESMF_InfoGetFromBase(stateR%statep%base, info=info, rc=localrc) + if (ESMF_LogFoundError(localrc, & + ESMF_ERR_PASSTHRU, & + ESMF_CONTEXT, rcToReturn=rc)) return + call ESMF_InfoLog(info, prefix=prefix, rc=localrc) + if (ESMF_LogFoundError(localrc, & + ESMF_ERR_PASSTHRU, & + ESMF_CONTEXT, rcToReturn=rc)) return + end block +#endif + if (itemCount > 0) then allocate(itemNameList(itemCount)) allocate(itemTypeList(itemCount)) From 8ee83797411098639ce078c978c818c8e8b73b3c Mon Sep 17 00:00:00 2001 From: Gerhard Theurich Date: Fri, 6 Dec 2024 13:37:00 -0800 Subject: [PATCH 3/6] Revert back to version before CompName was added - which is not needed. Instead implement Import-/ExportState naming based on compLabel for more clarity. --- src/addon/NUOPC/src/NUOPC_Driver.F90 | 63 ++++++++-------------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/src/addon/NUOPC/src/NUOPC_Driver.F90 b/src/addon/NUOPC/src/NUOPC_Driver.F90 index 4cd171e2ab..07f4476911 100644 --- a/src/addon/NUOPC/src/NUOPC_Driver.F90 +++ b/src/addon/NUOPC/src/NUOPC_Driver.F90 @@ -1170,7 +1170,7 @@ recursive subroutine InitializeIPDv02p1(driver, importState, exportState, & return ! bail out namespace=cmEntry%wrap%label else - ! in the old style (pre v7) there are no component labels availabl + ! in the old style (pre v7) there are no component labels available namespace="DEFAULT" ! cannot be empty for sake of AttributeSet() endif ! add State level attributes, set the namespace according to comp label @@ -1188,6 +1188,14 @@ recursive subroutine InitializeIPDv02p1(driver, importState, exportState, & if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) & return ! bail out + ! for available component label, also set State name for clarity + if (namespace /= "DEFAULT") then + call ESMF_StateSet(is%wrap%modelIS(i), & + name=trim(namespace)//"-ImportState", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) & + return ! bail out + endif endif ! add State level attributes, set the namespace according to comp label stateIsCreated = ESMF_StateIsCreated(is%wrap%modelES(i), rc=rc) @@ -1204,6 +1212,14 @@ recursive subroutine InitializeIPDv02p1(driver, importState, exportState, & if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) & return ! bail out + ! for available component label, also set State name for clarity + if (namespace /= "DEFAULT") then + call ESMF_StateSet(is%wrap%modelES(i), & + name=trim(namespace)//"-ExportState", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) & + return ! bail out + endif endif enddo @@ -1600,8 +1616,6 @@ recursive subroutine loopModelComps(phase, rc) logical :: areServicesSet character(ESMF_MAXSTR) :: iString, pLabel logical :: mustAttributeUpdate(1:is%wrap%modelCount) - logical :: isPresent - type(ESMF_Info) :: info rc = ESMF_SUCCESS mustAttributeUpdate = .false. ! loop through all the model components first time to execute @@ -1644,48 +1658,7 @@ recursive subroutine loopModelComps(phase, rc) return ! bail out endif enddo - ! loop through all the model components second time to add extra metadata - do i=1, is%wrap%modelCount - call ESMF_GridCompGet(is%wrap%modelComp(i), name=compName, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) & - return ! bail out - ! add metadata to import state - call ESMF_InfoGetFromHost(is%wrap%modelIS(i), info=info, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) & - return ! bail out - call ESMF_InfoGet(info, key="/NUOPC/Instance/CompName", & - isPresent=isPresent, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) & - return ! bail out - if (.not. isPresent) then - call ESMF_InfoSet(info, key="/NUOPC/Instance/CompName", & - value=trim(compName), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) & - return ! bail out - end if - ! add metadata to export state - call ESMF_InfoGetFromHost(is%wrap%modelES(i), info=info, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) & - return ! bail out - call ESMF_InfoGet(info, key="/NUOPC/Instance/CompName", & - isPresent=isPresent, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) & - return ! bail out - if (.not. isPresent) then - call ESMF_InfoSet(info, key="/NUOPC/Instance/CompName", & - value=trim(compName), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) & - return ! bail out - end if - end do - ! loop through all the model components third time to update Attributes + ! loop through all the model components second time to update Attributes do i=1, is%wrap%modelCount if (mustAttributeUpdate(i)) then ! need to update the Component attributes across all PETs From 4c8fd1edc68aeec02b59ce338716907ddf8b8675 Mon Sep 17 00:00:00 2001 From: Gerhard Theurich Date: Fri, 6 Dec 2024 13:39:09 -0800 Subject: [PATCH 4/6] Implement Field mirroring with NameSpace transfer. --- src/addon/NUOPC/src/NUOPC_Connector.F90 | 65 +++++++++---------------- 1 file changed, 23 insertions(+), 42 deletions(-) diff --git a/src/addon/NUOPC/src/NUOPC_Connector.F90 b/src/addon/NUOPC/src/NUOPC_Connector.F90 index a549c32507..075734a624 100644 --- a/src/addon/NUOPC/src/NUOPC_Connector.F90 +++ b/src/addon/NUOPC/src/NUOPC_Connector.F90 @@ -436,7 +436,7 @@ subroutine InitializeIPDv05p1(connector, importState, exportState, clock, rc) integer :: i, j character(ESMF_MAXSTR) :: importCplSet, exportCplSet character(len=240) :: msgString - character(ESMF_MAXSTR) :: importProvider, exportProvider + character(ESMF_MAXSTR) :: stateName, namespace rc = ESMF_SUCCESS @@ -609,25 +609,22 @@ subroutine InitializeIPDv05p1(connector, importState, exportState, clock, rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out elseif (trim(exportXferPolicy)=="transferAllAsNests") then - ! check name of provider component - call NUOPC_GetAttribute(importState, name="CompName", & - value=importProvider, rc=rc) + ! access importState namespace so it can be transferred to exportState + call NUOPC_GetAttribute(importState, name="Namespace", & + value=namespace, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out - ! create nested state - exportNestedState = ESMF_StateCreate(name=trim(importProvider)//"-NestedState", rc=rc) + ! access name of exportState for nestedStateName construction for clarity + call ESMF_StateGet(exportState, name=stateName, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out - ! set FieldTransferPolicy metadata for nested state - call NUOPC_SetAttribute(exportNestedState, "FieldTransferPolicy", "transferAll", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out - ! define namespace and nested state - call NUOPC_AddNamespace(exportState, namespace=trim(importProvider), & + ! set namespace on exportState, creating a nestedState + call NUOPC_AddNamespace(exportState, namespace=trim(namespace), & + nestedStateName=trim(stateName)//"-namespace:"//trim(namespace), & nestedState=exportNestedState, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out - ! top level mirroring into exportState + ! mirror importState items into exportNestedState call doMirror(importState, exportNestedState, acceptorVM=vm, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out @@ -707,25 +704,20 @@ subroutine InitializeIPDv05p1(connector, importState, exportState, clock, rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out elseif (trim(importXferPolicy)=="transferAllAsNests") then - ! check name of provider component - call NUOPC_GetAttribute(exportState, name="CompName", & - value=exportProvider, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out - ! create nested state - importNestedState = ESMF_StateCreate(name=trim(exportProvider)//"-NestedState", rc=rc) + ! access exportState namespace so it can be transferred to importState + call NUOPC_GetAttribute(exportState, name="Namespace", & + value=namespace, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out - ! set FieldTransferPolicy metadata for nested state - call NUOPC_SetAttribute(importNestedState, "FieldTransferPolicy", "transferAll", rc=rc) + ! access name of importState for nestedStateName construction for clarity + call ESMF_StateGet(importState, name=stateName, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out - ! define namespace and nested state - call NUOPC_AddNamespace(importState, namespace=trim(exportProvider), & + ! set namespace on importState, creating a nestedState + call NUOPC_AddNamespace(importState, namespace=trim(namespace), & + nestedStateName=trim(stateName)//"-namespace:"//trim(namespace), & nestedState=importNestedState, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out - ! top level mirroring into exportState + ! mirror exportState items into importNestedState call doMirror(exportState, importNestedState, acceptorVM=vm, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out @@ -839,13 +831,12 @@ subroutine InitializeIPDv05p1(connector, importState, exportState, clock, rc) recursive subroutine doMirror(providerState, acceptorState, acceptorVM, rc) type(ESMF_State) :: providerState type(ESMF_State) :: acceptorState - type(ESMF_VM), intent(in) :: acceptorVM + type(ESMF_VM), intent(in) :: acceptorVM integer, intent(out) :: rc integer :: item, itemCount character(ESMF_MAXSTR) :: providerTransferOffer, acceptorTransferOffer character(ESMF_MAXSTR) :: acceptorStateName - character(ESMF_MAXSTR) :: providerCompName type(ESMF_State) :: providerNestedState type(ESMF_State) :: acceptorNestedState character(ESMF_MAXSTR) :: nestedStateName @@ -866,7 +857,7 @@ recursive subroutine doMirror(providerState, acceptorState, acceptorVM, rc) character(ESMF_MAXSTR) :: valueString type(ESMF_Pointer) :: vmThis logical :: actualFlag - + rc = ESMF_SUCCESS nullify(providerStandardNameList) @@ -874,18 +865,13 @@ recursive subroutine doMirror(providerState, acceptorState, acceptorVM, rc) nullify(providerFieldList) nullify(providerCplSetList) nullify(acceptorStandardNameList) - + actualFlag = .true. call ESMF_VMGetThis(acceptorVM, vmThis) if (vmThis == ESMF_NULL_POINTER) then actualFlag = .false. ! local PET is not for an actual member endif - call NUOPC_GetAttribute(providerState, name="CompName", & - value=providerCompName, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out - call ESMF_StateGet(acceptorState, name=acceptorStateName, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out @@ -1062,14 +1048,9 @@ recursive subroutine doMirror(providerState, acceptorState, acceptorVM, rc) line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out endif - ! Add extra metadata to the field in acceptor side about provider - call NUOPC_SetAttribute(fieldAdv, name="ProviderCompName", & - value=trim(providerCompName), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out end do endif - + if (flipIntent) then ! Need to flip the accetorState intent back (same as providerIntent). call ESMF_StateSet(acceptorState, stateIntent=providerIntent, rc=rc) From e569cecae56d79838f968bc7da42e1ba68d280c5 Mon Sep 17 00:00:00 2001 From: Gerhard Theurich Date: Fri, 6 Dec 2024 14:23:03 -0800 Subject: [PATCH 5/6] Add the option to create nested State for NameSpace handling on a explicitly provided VM, and use this to target acceptor VM for field mirroring with NameSpace. --- src/addon/NUOPC/src/NUOPC_Base.F90 | 50 ++++++++++++++++--------- src/addon/NUOPC/src/NUOPC_Connector.F90 | 8 ++-- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/addon/NUOPC/src/NUOPC_Base.F90 b/src/addon/NUOPC/src/NUOPC_Base.F90 index 2f3bf35a4a..891b39f808 100644 --- a/src/addon/NUOPC/src/NUOPC_Base.F90 +++ b/src/addon/NUOPC/src/NUOPC_Base.F90 @@ -154,12 +154,13 @@ module NUOPC_Base ! !IROUTINE: NUOPC_AddNamespace - Add a nested state with Namespace to a State ! !INTERFACE: subroutine NUOPC_AddNamespace(state, Namespace, nestedStateName, & - nestedState, rc) + nestedState, vm, rc) ! !ARGUMENTS: type(ESMF_State), intent(inout) :: state character(len=*), intent(in) :: Namespace character(len=*), intent(in), optional :: nestedStateName type(ESMF_State), intent(out), optional :: nestedState + type(ESMF_VM), intent(in), optional :: vm integer, intent(out), optional :: rc ! !DESCRIPTION: ! Add a Namespace to {\tt state}. Namespaces are implemented via nested @@ -178,6 +179,10 @@ subroutine NUOPC_AddNamespace(state, Namespace, nestedStateName, & ! Name of the nested state. Defaults to {\tt Namespace}. ! \item[{[nestedState]}] ! Optional return of the newly created nested state. +! \item[{[vm]}] +! If present, the nested State created to hold the namespace is created on +! the specified {\tt ESMF\_VM} object. The default is to create the nested +! State on the VM of the current component context. ! \item[{[rc]}] ! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors. ! \end{description} @@ -189,9 +194,10 @@ subroutine NUOPC_AddNamespace(state, Namespace, nestedStateName, & type(ESMF_State) :: nestedS character(len=80) :: nestedSName type(ESMF_StateIntent_Flag) :: stateIntent - + logical :: stateIsCreated + if (present(rc)) rc = ESMF_SUCCESS - + call ESMF_StateGet(state, stateIntent=stateIntent, rc=localrc) if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=FILENAME, rcToReturn=rc)) return ! bail out @@ -201,31 +207,39 @@ subroutine NUOPC_AddNamespace(state, Namespace, nestedStateName, & else nestedSName = trim(Namespace) endif - + nestedS = ESMF_StateCreate(name=nestedSName, stateIntent=stateIntent, & - rc=localrc) - if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=FILENAME, rcToReturn=rc)) return ! bail out - - call NUOPC_InitAttributes(nestedS, rc=localrc) + vm=vm, rc=localrc) if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=FILENAME, rcToReturn=rc)) return ! bail out - call NUOPC_SetAttribute(nestedS, name="Namespace", & - value=trim(Namespace), rc=localrc) - if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=FILENAME, rcToReturn=rc)) return ! bail out - - call ESMF_StateAdd(state, (/nestedS/), rc=localrc) + stateIsCreated = ESMF_StateIsCreated(nestedS, rc=rc) if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=FILENAME, rcToReturn=rc)) return ! bail out + if (stateIsCreated) then + + call NUOPC_InitAttributes(nestedS, rc=localrc) + if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=FILENAME, rcToReturn=rc)) return ! bail out + + call NUOPC_SetAttribute(nestedS, name="Namespace", & + value=trim(Namespace), rc=localrc) + if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=FILENAME, rcToReturn=rc)) return ! bail out + + call ESMF_StateAdd(state, (/nestedS/), rc=localrc) + if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=FILENAME, rcToReturn=rc)) return ! bail out + + endif + if (present(nestedState)) & nestedState = nestedS - + end subroutine - !--------------------------------------------------------------------- - + !----------------------------------------------------------------------------- + !----------------------------------------------------------------------------- !BOP ! !IROUTINE: NUOPC_AddNestedState - Add a nested state to a state with NUOPC attributes diff --git a/src/addon/NUOPC/src/NUOPC_Connector.F90 b/src/addon/NUOPC/src/NUOPC_Connector.F90 index 075734a624..7540b577fd 100644 --- a/src/addon/NUOPC/src/NUOPC_Connector.F90 +++ b/src/addon/NUOPC/src/NUOPC_Connector.F90 @@ -618,10 +618,10 @@ subroutine InitializeIPDv05p1(connector, importState, exportState, clock, rc) call ESMF_StateGet(exportState, name=stateName, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out - ! set namespace on exportState, creating a nestedState + ! set namespace on exportState, creating a nestedState on acceptor VM call NUOPC_AddNamespace(exportState, namespace=trim(namespace), & nestedStateName=trim(stateName)//"-namespace:"//trim(namespace), & - nestedState=exportNestedState, rc=rc) + nestedState=exportNestedState, vm=vm, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out ! mirror importState items into exportNestedState @@ -713,10 +713,10 @@ subroutine InitializeIPDv05p1(connector, importState, exportState, clock, rc) call ESMF_StateGet(importState, name=stateName, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out - ! set namespace on importState, creating a nestedState + ! set namespace on importState, creating a nestedState on acceptor VM call NUOPC_AddNamespace(importState, namespace=trim(namespace), & nestedStateName=trim(stateName)//"-namespace:"//trim(namespace), & - nestedState=importNestedState, rc=rc) + nestedState=importNestedState, vm=vm, rc=rc) ! mirror exportState items into importNestedState call doMirror(exportState, importNestedState, acceptorVM=vm, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & From a5d550d2eceab34b4221c491273aae9b28ce0ec9 Mon Sep 17 00:00:00 2001 From: Gerhard Theurich Date: Fri, 6 Dec 2024 14:24:37 -0800 Subject: [PATCH 6/6] Turn off InfoLog() under StateLog(). --- src/Superstructure/State/src/ESMF_StateAPI.cppF90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Superstructure/State/src/ESMF_StateAPI.cppF90 b/src/Superstructure/State/src/ESMF_StateAPI.cppF90 index 3e347eaeb5..3ebac37213 100644 --- a/src/Superstructure/State/src/ESMF_StateAPI.cppF90 +++ b/src/Superstructure/State/src/ESMF_StateAPI.cppF90 @@ -1853,7 +1853,7 @@ type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below ESMF_ERR_PASSTHRU, & ESMF_CONTEXT, rcToReturn=rc)) return -#if 1 +#if 0 !TODO: need a way to indicate from calling side that info should be logged block type(ESMF_Info) :: info