From 60f68089ee4c9b0de968851ea73961287ca77176 Mon Sep 17 00:00:00 2001 From: Robert Hallberg Date: Thu, 30 Jun 2016 16:42:29 -0400 Subject: [PATCH] Deallocate G%Domain in destroy_dyn_horgrid 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. --- src/framework/MOM_dyn_horgrid.F90 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/framework/MOM_dyn_horgrid.F90 b/src/framework/MOM_dyn_horgrid.F90 index 2d42e7f13a..8a57ac6c90 100644 --- a/src/framework/MOM_dyn_horgrid.F90 +++ b/src/framework/MOM_dyn_horgrid.F90 @@ -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 @@ -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)