Skip to content

Commit

Permalink
Merge branch 'work/reconcile-scaling' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
theurich committed Nov 15, 2024
2 parents 66a3877 + b6be293 commit aed3278
Show file tree
Hide file tree
Showing 34 changed files with 4,469 additions and 2,269 deletions.
4 changes: 4 additions & 0 deletions src/Infrastructure/Array/interface/ESMF_ArrayGet.cppF90
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,10 @@ type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
call c_ESMC_GetVM(array, vm, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Set init code on the VM object before returning
call ESMF_VMSetInitCreated(vm, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif

! Obtain DistGrid information
Expand Down
6 changes: 5 additions & 1 deletion src/Infrastructure/Array/src/ESMCI_Array.C
Original file line number Diff line number Diff line change
Expand Up @@ -4151,13 +4151,17 @@ void Array::log(
msg << prefix << "--- Array::log() start -----------------------------------";
ESMC_LogDefault.Write(msg.str(), msgType);

msg.str(""); // clear
msg << prefix << this;
ESMC_LogDefault.Write(msg.str(), msgType);

if (ESMC_BaseGetStatus()!=ESMF_STATUS_READY){
msg.str(""); // clear
msg << prefix << "Array object is invalid! Not created or deleted!";
ESMC_LogDefault.Write(msg.str(), msgType);
}else{
msg.str(""); // clear
msg << prefix << " <name: " << getName() << ">";
msg << prefix << "<name: " << getName() << ">";
ESMC_LogDefault.Write(msg.str(), msgType);
if (deepFlag) getDistGrid()->log(prefix+"! ", msgType, deepFlag);
}
Expand Down
23 changes: 20 additions & 3 deletions src/Infrastructure/ArrayBundle/interface/ESMF_ArrayBundle.F90
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ module ESMF_ArrayBundleMod
use ESMF_IOUtilMod
use ESMF_RHandleMod
use ESMF_ArrayMod

use ESMF_VMMod

implicit none

!------------------------------------------------------------------------------
Expand Down Expand Up @@ -883,9 +884,9 @@ end subroutine ESMF_ArrayBundleDestroy
! !IROUTINE: ESMF_ArrayBundleGet - Get object-wide information from an ArrayBundle
!
! !INTERFACE:
! Private name; call using ESMF_ArrayBundleGet()
! Private name; call using ESMF_ArrayBundleGet()
subroutine ESMF_ArrayBundleGetListAll(arraybundle, keywordEnforcer, &
itemorderflag, arrayCount, arrayList, arrayNameList, name, rc)
itemorderflag, arrayCount, arrayList, arrayNameList, name, vm, rc)
!
! !ARGUMENTS:
type(ESMF_ArrayBundle), intent(in) :: arraybundle
Expand All @@ -895,6 +896,7 @@ subroutine ESMF_ArrayBundleGetListAll(arraybundle, keywordEnforcer, &
type(ESMF_Array), intent(out), optional :: arrayList(:)
character(len=*), intent(out), optional :: arrayNameList(:)
character(len=*), intent(out), optional :: name
type(ESMF_VM), intent(out), optional :: vm
integer, intent(out), optional :: rc
!
! !STATUS:
Expand All @@ -905,6 +907,8 @@ subroutine ESMF_ArrayBundleGetListAll(arraybundle, keywordEnforcer, &
! \item[6.1.0] Added argument {\tt itemorderflag}.
! The new argument gives the user control over the order in which
! the items are returned.
! \item[8.8.0] Added argument {\tt vm} in order to offer information about the
! VM on which the ArrayBundle was created.
! \end{description}
! \end{itemize}
!
Expand All @@ -930,6 +934,8 @@ subroutine ESMF_ArrayBundleGetListAll(arraybundle, keywordEnforcer, &
! size {\tt arrayCount}.
! \item [{[name]}]
! Name of the ArrayBundle object.
! \item [{[vm}]
! The VM on which the ArrayBundle object was created.
! \item [{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
Expand Down Expand Up @@ -1015,6 +1021,17 @@ subroutine ESMF_ArrayBundleGetListAll(arraybundle, keywordEnforcer, &
endif
endif

! Special call to get vm out of Base class
if (present(vm)) then
call c_ESMC_GetVM(arraybundle, vm, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Set init code on the VM object before returning
call ESMF_VMSetInitCreated(vm, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif

! Return successfully
if (present(rc)) rc = ESMF_SUCCESS

Expand Down
6 changes: 5 additions & 1 deletion src/Infrastructure/DistGrid/src/ESMCI_DistGrid.C
Original file line number Diff line number Diff line change
Expand Up @@ -3937,14 +3937,18 @@ void DistGrid::log(
msg << prefix << "--- DistGrid::log() start --------------------------------";
ESMC_LogDefault.Write(msg.str(), msgType);

msg.str(""); // clear
msg << prefix << this;
ESMC_LogDefault.Write(msg.str(), msgType);

if (ESMC_BaseGetStatus()!=ESMF_STATUS_READY){
msg.str(""); // clear
msg << prefix << "DistGrid object is invalid! Not created or deleted!";
ESMC_LogDefault.Write(msg.str(), msgType);
}else{
msg.str(""); // clear
msg << prefix << "DistGrid object is valid!"
<< " <name: " << getName() << ">";
<< "<name: " << getName() << ">";
ESMC_LogDefault.Write(msg.str(), msgType);
}
msg.str(""); // clear
Expand Down
28 changes: 16 additions & 12 deletions src/Infrastructure/Field/src/ESMF_Field.F90
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,12 @@ subroutine ESMF_FieldValidate(field, keywordEnforcer, rc)
integer, allocatable :: distgridToGridMap(:)
integer, allocatable :: distgridToPackedArrayMap(:)
integer, allocatable :: arrayCompUBnd(:, :), arrayCompLBnd(:, :)
type(ESMF_DistGrid) :: arrayDistGrid, gridDistGrid
type(ESMF_GridDecompType) :: decompType
type(ESMF_GeomType_Flag) :: geomtype
type(ESMF_Grid) :: grid
type(ESMF_Status) :: basestatus
type(ESMF_DistGrid) :: arrayDistGrid, geomDistGrid
type(ESMF_GridDecompType) :: decompType
type(ESMF_GeomType_Flag) :: geomtype
type(ESMF_Grid) :: grid
type(ESMF_Status) :: basestatus
type(ESMF_DistGridMatch_Flag) :: dgMatch

! Initialize
localrc = ESMF_RC_NOT_IMPL
Expand Down Expand Up @@ -342,7 +343,7 @@ subroutine ESMF_FieldValidate(field, keywordEnforcer, rc)
endif
! get grid dim and extents for the local piece
call ESMF_GeomGet(ftypep%geom, dimCount=gridrank, &
distgrid=gridDistGrid, localDECount=localDECount, rc=localrc)
distgrid=geomDistGrid, localDECount=localDECount, rc=localrc)
if (localrc .ne. ESMF_SUCCESS) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_OBJ_BAD, &
msg="Cannot retrieve distgrid, gridrank, localDECount from ftypep%grid", &
Expand Down Expand Up @@ -379,13 +380,16 @@ subroutine ESMF_FieldValidate(field, keywordEnforcer, rc)
msg="Cannot retrieve dimCount, localDECount, arrayDistGrid, arrayrank from ftypep%array", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif

! Verify the distgrids in array and grid match.
if(ESMF_DistGridMatch(gridDistGrid, arrayDistGrid, rc=localrc) &
< ESMF_DISTGRIDMATCH_EXACT) then
endif

! Verify the distgrids in array and geom match.
dgMatch = ESMF_DistGridMatch(geomDistGrid, arrayDistGrid, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
if(dgMatch < ESMF_DISTGRIDMATCH_EXACT) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_OBJ_BAD, &
msg="grid DistGrid does not match array DistGrid", &
msg="geom DistGrid does not match array DistGrid", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif
Expand Down
31 changes: 22 additions & 9 deletions src/Infrastructure/Field/src/ESMF_FieldCreate.cppF90
Original file line number Diff line number Diff line change
Expand Up @@ -5363,9 +5363,17 @@ type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
if (ftype%is_proxy .or. ftype%geomb_internal) then

if (ftype%is_proxy) then
! proxies destroy their actual geometry object, but must leave
#if 1
!gjt: Destroying geom object for proxies might not be a good idea. If this
!gjt: every cases issues, then we might want to disable it here.
!gjt: Disable, because proxy geoms might be used outside the original the
!gjt: proxy field... cannot destroy here, but instead must keep proxy the
!gjt: geom alive!!!

! Proxies destroy their actual geometry object, but must leave
! in garbage collection because multiple fields might be referencing
! the same actual geometry object, and try to destroy
! the same actual geometry object, and try to destroy. Garbage
! collection makes those double destroy calls safe noops.

call ESMF_GeomGet(ftype%geom, geomtype=geomtype, rc=localrc)
if (ESMF_LogFoundError(localrc, &
Expand Down Expand Up @@ -5421,14 +5429,19 @@ type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
ESMF_CONTEXT, rcToReturn=rc)
return
endif

! the Geom needs to be destroyed
call ESMF_GeomDestroy(ftype%geom, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
#endif
else
! the Geom needs to be destroyed
call ESMF_GeomDestroy(ftype%geom, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif

! proxy or not, the Geom needs to be destroyed
call ESMF_GeomDestroy(ftype%geom, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif

ftype%status = ESMF_FIELDSTATUS_UNINIT ! mark invalid
Expand Down
17 changes: 17 additions & 0 deletions src/Infrastructure/Field/src/ESMF_FieldHalo.F90
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ subroutine ESMF_FieldLog(field, keywordEnforcer, prefix, logMsgFlag, deepFlag, r
integer :: rank, dimCount
character(ESMF_MAXSTR) :: name, tempString
character(800) :: msgString
type(ESMF_Array) :: array

! initialize return code; assume routine not implemented
localrc = ESMF_RC_NOT_IMPL
Expand Down Expand Up @@ -539,6 +540,8 @@ subroutine ESMF_FieldLog(field, keywordEnforcer, prefix, logMsgFlag, deepFlag, r
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return

call c_esmc_vmlogpointer(field, prefix, logMsg)

if (fieldStatus == ESMF_FIELDSTATUS_COMPLETE) then
call ESMF_FieldGet(field, typekind=typekind, rank=rank, &
dimCount=dimCount, rc=localrc)
Expand All @@ -558,6 +561,20 @@ subroutine ESMF_FieldLog(field, keywordEnforcer, prefix, logMsgFlag, deepFlag, r
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return

if (deepLog) then
call ESMF_FieldGet(field, array=array, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_ArrayLog(array, &
prefix=ESMF_StringConcat(prefix, "! "), &
logMsgFlag=logMsg, deepFlag=deepLog, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif

endif
endif

Expand Down
17 changes: 14 additions & 3 deletions src/Infrastructure/FieldBundle/src/ESMF_FieldBundle.cppF90
Original file line number Diff line number Diff line change
Expand Up @@ -1705,7 +1705,7 @@ type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
! Private name; call using ESMF_FieldBundleGet()
subroutine ESMF_FieldBundleGetListAll(fieldbundle, keywordEnforcer, &
itemorderflag, geomtype, grid, locstream, mesh, xgrid, &
fieldCount, fieldList, fieldNameList, isPacked, name, rc)
fieldCount, fieldList, fieldNameList, isPacked, name, vm, rc)
!
! !ARGUMENTS:
type(ESMF_FieldBundle), intent(in) :: fieldbundle
Expand All @@ -1721,6 +1721,7 @@ type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
character(len=*), intent(out), optional :: fieldNameList(:)
logical, intent(out), optional :: isPacked
character(len=*), intent(out), optional :: name
type(ESMF_VM), intent(out), optional :: vm
integer, intent(out), optional :: rc
!
! !STATUS:
Expand All @@ -1733,6 +1734,8 @@ type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
! the items are returned.
! \item[8.0.0] Added argument {\tt isPacked}.
! The new argument allows the user to query if this is a packed FieldBundle.
! \item[8.8.0] Added argument {\tt vm} in order to offer information about the
! VM on which the FieldBundle was created.
! \end{description}
! \end{itemize}
!
Expand Down Expand Up @@ -1771,7 +1774,9 @@ type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
! \item [{[isPacked]}]
! Upon return holds the information if this FieldBundle is packed.
! \item [{[name]}]
! Name of the fieldbundle object.
! Name of the FieldBundle object.
! \item [{[vm}]
! The VM on which the FieldBundle object was created.
! \item [{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
Expand Down Expand Up @@ -1960,7 +1965,13 @@ type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
ESMF_CONTEXT, rcToReturn=rc)) return
endif
endif


if (present(vm)) then
call ESMF_GetVM(fieldbundle%this%base, vm, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif

! Return successfully
if (present(rc)) rc = ESMF_SUCCESS

Expand Down
Loading

0 comments on commit aed3278

Please sign in to comment.