Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/provider_m…
Browse files Browse the repository at this point in the history
…etadata
  • Loading branch information
uturuncoglu committed Dec 4, 2024
2 parents 6994904 + a184c8c commit 45bbc28
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/Infrastructure/Field/src/ESMF_Field.F90
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ subroutine ESMF_FieldDestructGeom(ftype, noGarbage, rc)
if (ftype%is_proxy) then
#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: ever causes 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!!!
Expand Down
114 changes: 61 additions & 53 deletions src/Infrastructure/Field/src/ESMF_FieldEmpty.cppF90
Original file line number Diff line number Diff line change
Expand Up @@ -4314,37 +4314,43 @@ type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below

end function ESMF_FieldEmptyCreate
!------------------------------------------------------------------------------

!------------------------------------------------------------------------------
^undef ESMF_METHOD
^define ESMF_METHOD "ESMF_FieldEmptyReset"
!BOP
! !IROUTINE: ESMF_FieldEmptyReset - Reset a Field back to an earlier status.
! !IROUTINE: ESMF_FieldEmptyReset - Reset a Field back to an earlier status

! !INTERFACE:
subroutine ESMF_FieldEmptyReset(field, status, keywordEnforcer, vm, rc)
subroutine ESMF_FieldEmptyReset(field, keywordEnforcer, status, vm, rc)

!
! !ARGUMENTS:
type(ESMF_Field), intent(inout) :: field
type(ESMF_FieldStatus_Flag), intent(in) :: status
type(ESMF_Field), intent(inout) :: field
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
type(ESMF_VM), intent(in), optional :: vm
integer, intent(out), optional :: rc
type(ESMF_FieldStatus_Flag), intent(in), optional :: status
type(ESMF_VM), intent(in), optional :: vm
integer, intent(out), optional :: rc
!
!
! !DESCRIPTION:
! Reset an {\tt ESMF\_Field} to a less complete status. After this
! operation, methods appropriate to the new status can be used on the Field.
! For example, if reset to status {\tt ESMF\_FIELDSTATUS\_EMPTY}, then {\tt ESMF\_FieldEmpySet()}
! For example, if reset to status {\tt ESMF\_FIELDSTATUS\_EMPTY}, then {\tt ESMF\_FieldEmptySet()}
! could be used to set a new Grid in the Field.
!
! Note that if used improperly, this method can cause inconsistencies. For example, creating a routeHandle
! on a Field and then using this method to change the geometry (e.g. Grid) under the Field could lead to the
! routeHandle no longer being valid for the Field.
!
! The arguments are:
! \begin{description}
! \item [field]
! The {\tt ESMF\_Field} object to reset.
! \item [status]
! The new status to set the Field to.
! The {\tt ESMF\_Field} object to reset.
! \item [{[status]}]
! The new status to set the Field to.
! See section \ref{const:fieldstatus} for a complete list of values.
! The default is {\tt ESMF\_FIELDSTATUS\_EMPTY}.
! \item[{[vm]}]
! If present, the Field object will only be accessed, and the Grid object
! set, on those PETs contained in the specified {\tt ESMF\_VM} object.
Expand All @@ -4356,7 +4362,7 @@ type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
!EOP
!------------------------------------------------------------------------------
type(ESMF_FieldType), pointer :: ftypep
type(ESMF_FieldStatus_Flag) :: currStatus
type(ESMF_FieldStatus_Flag) :: currStatus, setStatus
integer :: localrc
type(ESMF_Pointer) :: vmThis
logical :: actualFlag
Expand All @@ -4366,15 +4372,18 @@ type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below

ESMF_INIT_CHECK_DEEP(ESMF_FieldGetInit,field,rc)

! Handle option status argument
setStatus = ESMF_FIELDSTATUS_EMPTY ! default
if (present(status)) setStatus = status

! Error check status
if(status == ESMF_FIELDSTATUS_UNINIT) then
if(setStatus == ESMF_FIELDSTATUS_UNINIT) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, &
msg="FieldEmptyReset - cannot reset a Field to an uninitialized status.", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif


! Must make sure the local PET is associated with an actual member
actualFlag = .true.
if (present(vm)) then
Expand All @@ -4392,109 +4401,108 @@ type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
endif

! Get pointer to internal Field
ftypep => field%ftypep
ftypep => field%ftypep

! Get field's current status
currStatus=ftypep%status

! Change Field based on current status and new status
if (currStatus == ESMF_FIELDSTATUS_EMPTY) then
if (status == ESMF_FIELDSTATUS_EMPTY) then
! Don't do anything, since no change in status
else if (status == ESMF_FIELDSTATUS_GRIDSET) then

if (setStatus == ESMF_FIELDSTATUS_EMPTY) then
! Don't do anything, since no change in status
else if (setStatus == ESMF_FIELDSTATUS_GRIDSET) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, &
msg="a Field can't be reset to be more complete than its current status.", &
ESMF_CONTEXT, rcToReturn=rc)
return
else if (status == ESMF_FIELDSTATUS_COMPLETE) then
return
else if (setStatus == ESMF_FIELDSTATUS_COMPLETE) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, &
msg="a Field can't be reset to be more complete than its current status.", &
ESMF_CONTEXT, rcToReturn=rc)
return
return
else
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, &
msg="unknown status type", &
ESMF_CONTEXT, rcToReturn=rc)
return
return
endif

else if (currStatus == ESMF_FIELDSTATUS_GRIDSET) then
if (status == ESMF_FIELDSTATUS_EMPTY) then

if (setStatus == ESMF_FIELDSTATUS_EMPTY) then

! Destroy Geometry to go back to empty status
call ESMF_FieldDestructGeom(ftypep, noGarbage=.false., rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return

! Set flag back to it's inital setting
ftypep%geomb_internal = .false.
ftypep%geomb_internal = .false.

else if (status == ESMF_FIELDSTATUS_GRIDSET) then
! Don't do anything, since no change in status
else if (status == ESMF_FIELDSTATUS_COMPLETE) then
else if (setStatus == ESMF_FIELDSTATUS_GRIDSET) then
! Don't do anything, since no change in status
else if (setStatus == ESMF_FIELDSTATUS_COMPLETE) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, &
msg="a Field can't be reset to be more complete than its current status.", &
ESMF_CONTEXT, rcToReturn=rc)
return
return
else
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, &
msg="unknown status type", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif
return
endif


else if (currStatus == ESMF_FIELDSTATUS_COMPLETE) then
if (status == ESMF_FIELDSTATUS_EMPTY) then

if (setStatus == ESMF_FIELDSTATUS_EMPTY) then

! Destroy Array
call ESMF_FieldDestructArray(ftypep, noGarbage=.false., rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return

! Set Array internal flag back to it's inital setting
ftypep%array_internal = .false.
ftypep%array_internal = .false.

! Destroy Geometry
call ESMF_FieldDestructGeom(ftypep, noGarbage=.false., rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return

! Set geom internal flag back to it's inital setting
ftypep%geomb_internal = .false.
else if (status == ESMF_FIELDSTATUS_GRIDSET) then
ftypep%geomb_internal = .false.

else if (setStatus == ESMF_FIELDSTATUS_GRIDSET) then

! Destroy Array
call ESMF_FieldDestructArray(ftypep, noGarbage=.false., rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return

! Set Array internal flag back to it's inital setting
ftypep%array_internal = .false.
else if (status == ESMF_FIELDSTATUS_COMPLETE) then
! Don't do anything, since no change in status
ftypep%array_internal = .false.

else if (setStatus == ESMF_FIELDSTATUS_COMPLETE) then
! Don't do anything, since no change in status
else
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, &
msg="unknown status type", &
ESMF_CONTEXT, rcToReturn=rc)
return
return
endif

else
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_WRONG, &
msg="unknown status type", &
ESMF_CONTEXT, rcToReturn=rc)
return
return
endif

! Set new status
ftypep%status = status
ftypep%status = setStatus

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

Expand Down

0 comments on commit 45bbc28

Please sign in to comment.