Skip to content

Commit

Permalink
Correct usage of ESMF_LogFoundDeallocError() for deallocation errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
theurich committed Oct 24, 2024
1 parent 90b9353 commit 9082e83
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/Infrastructure/Field/interface/ESMF_Field_C.F90
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,9 @@ subroutine f_esmf_fieldcollectgarbage(field, rc)
implicit none

type(ESMF_Field) :: field
integer, intent(out) :: rc
integer, intent(out) :: rc

integer :: localrc
integer :: localrc

! initialize return code; assume routine not implemented
localrc = ESMF_RC_NOT_IMPL
Expand All @@ -751,15 +751,15 @@ subroutine f_esmf_fieldcollectgarbage(field, rc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! deallocate actual FieldType allocation
! deallocate actual FieldType allocation
!print *, "deallocate(field%ftypep)"
deallocate(field%ftypep, stat=localrc)
if (ESMF_LogFoundAllocError(localrc, msg="Deallocating Field", &
if (ESMF_LogFoundDeallocError(localrc, msg="Deallocating Field", &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
nullify(field%ftypep)

! return successfully
! return successfully
rc = ESMF_SUCCESS

end subroutine f_esmf_fieldcollectgarbage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ subroutine f_esmf_fbundlecollectgarbage(fb, rc)
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, &
rcToReturn=rc)) return
! deallocate actual FieldBundleType allocation
! deallocate actual FieldBundleType allocation
deallocate(fb%this, stat=localrc)
if (ESMF_LogFoundAllocError(localrc, msg="Deallocating FieldBundle", &
if (ESMF_LogFoundDeallocError(localrc, msg="Deallocating FieldBundle", &
ESMF_CONTEXT, &
rcToReturn=rc)) return
endif
Expand Down
6 changes: 3 additions & 3 deletions src/Infrastructure/LocStream/interface/ESMF_LocStream_C.F90
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,15 @@ subroutine f_esmf_locstreamcollectgarbage(locstream, rc)
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return

! deallocate actual LocStreamType allocation
! deallocate actual LocStreamType allocation
if (associated(locstream%lstypep)) then
deallocate(locstream%lstypep, stat=localrc)
if (ESMF_LogFoundAllocError(localrc, msg="Deallocating LocStream", &
if (ESMF_LogFoundDeallocError(localrc, msg="Deallocating LocStream", &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
nullify(locstream%lstypep)

! return successfully
! return successfully
rc = ESMF_SUCCESS

end subroutine f_esmf_locstreamcollectgarbage
6 changes: 3 additions & 3 deletions src/Superstructure/Component/interface/ESMF_Comp_C.F90
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,15 @@ recursive subroutine f_esmf_compcollectgarbage2(comp, rc)
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return

! deallocate actual CompClass allocation
! deallocate actual CompClass allocation
if (associated(comp%compp)) then
deallocate(comp%compp, stat=localrc)
if (ESMF_LogFoundAllocError(localrc, msg="Deallocating Comp", &
if (ESMF_LogFoundDeallocError(localrc, msg="Deallocating Comp", &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
nullify(comp%compp)

! return successfully
! return successfully
rc = ESMF_SUCCESS

end subroutine f_esmf_compcollectgarbage2
Expand Down
6 changes: 3 additions & 3 deletions src/Superstructure/State/interface/ESMF_State_C.F90
Original file line number Diff line number Diff line change
Expand Up @@ -476,16 +476,16 @@ subroutine f_esmf_statecollectgarbage(state, rc)
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, &
rcToReturn=rc)) return
! deallocate actual StateClass allocation
! deallocate actual StateClass allocation
deallocate(state%statep, stat=localrc)
localrc = merge (ESMF_SUCCESS, ESMF_RC_MEM_DEALLOCATE, localrc == 0)
if (ESMF_LogFoundAllocError(localrc, msg="Deallocating State", &
if (ESMF_LogFoundDeallocError(localrc, msg="Deallocating State", &
ESMF_CONTEXT, &
rcToReturn=rc)) return
endif
nullify(state%statep)

! return successfully
! return successfully
rc = ESMF_SUCCESS

end subroutine f_esmf_statecollectgarbage

0 comments on commit 9082e83

Please sign in to comment.