Skip to content

Commit

Permalink
Deallocate G%Domain in destroy_dyn_horgrid
Browse files Browse the repository at this point in the history
  Added calls to deallocate G%Domain and G%Domain%mpp_domain in
destroy_dyn_horgrid.  This eliminates a potential memory leak. It had not been
done before because there was some concern that these pointers might have been
set to point to an element of another type, but this is now all being done via a
copy, so they can (and should) be deallocated.  All answers are bitwise
identical.
  • Loading branch information
Hallberg-NOAA committed Jun 30, 2016
1 parent 984cc75 commit 60f6808
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/framework/MOM_dyn_horgrid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ module MOM_dyn_horgrid
CoriolisBu ! The Coriolis parameter at corner points, in s-1.
real, allocatable, dimension(:,:) :: &
dF_dx, dF_dy ! Derivatives of f (Coriolis parameter) at h-points, in s-1 m-1.
! real :: g_Earth ! The gravitational acceleration in m s-2.

! These variables are global sums that are useful for 1-d diagnostics
real :: areaT_global ! Global sum of h-cell area in m2
Expand Down Expand Up @@ -350,11 +349,8 @@ subroutine destroy_dyn_horgrid(G)
deallocate(G%gridLonT) ; deallocate(G%gridLatT)
deallocate(G%gridLonB) ; deallocate(G%gridLatB)

! Do not deallocate G%Domain%mpp_domain or deallocate(G%Domain) because
! these are pointers to types used elsewhere.
G%Domain => NULL()
! deallocate(G%Domain%mpp_domain)
! deallocate(G%Domain)
deallocate(G%Domain%mpp_domain)
deallocate(G%Domain)

deallocate(G)

Expand Down

0 comments on commit 60f6808

Please sign in to comment.