From 2800524c2280b3c3dc68ff75687cb28568ed993b Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Thu, 19 Apr 2018 09:12:28 -0600 Subject: [PATCH 1/6] Uncomment calls to deallocate KPP related arrays --- src/core/MOM.F90 | 2 +- .../vertical/MOM_diabatic_driver.F90 | 22 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/core/MOM.F90 b/src/core/MOM.F90 index a6da3b5333..22dbb86b15 100644 --- a/src/core/MOM.F90 +++ b/src/core/MOM.F90 @@ -2901,7 +2901,7 @@ subroutine MOM_end(CS) call tracer_registry_end(CS%tracer_Reg) call tracer_flow_control_end(CS%tracer_flow_CSp) - !if (associated(CS%diabatic_CSp)) call diabatic_driver_end(CS%diabatic_CSp) + if (associated(CS%diabatic_CSp)) call diabatic_driver_end(CS%diabatic_CSp) if (CS%offline_tracer_mode) call offline_transport_end(CS%offline_CSp) diff --git a/src/parameterizations/vertical/MOM_diabatic_driver.F90 b/src/parameterizations/vertical/MOM_diabatic_driver.F90 index 07cfb558cd..be8dafc10b 100644 --- a/src/parameterizations/vertical/MOM_diabatic_driver.F90 +++ b/src/parameterizations/vertical/MOM_diabatic_driver.F90 @@ -2425,18 +2425,16 @@ subroutine diabatic_driver_end(CS) call entrain_diffusive_end(CS%entrain_diffusive_CSp) call set_diffusivity_end(CS%set_diff_CSp) - ! GMM, commeting the following because it fails on Travis (gfortran) - - ! if (CS%useKPP) then - ! if (allocated(CS%KPP_buoy_flux)) deallocate( CS%KPP_buoy_flux ) - ! if (allocated(CS%KPP_temp_flux)) deallocate( CS%KPP_temp_flux ) - ! if (allocated(CS%KPP_salt_flux)) deallocate( CS%KPP_salt_flux ) - ! endif - ! if (CS%useKPP) then - ! if (allocated(CS%KPP_NLTheat)) deallocate( CS%KPP_NLTheat ) - ! if (allocated(CS%KPP_NLTscalar)) deallocate( CS%KPP_NLTscalar ) - ! call KPP_end(CS%KPP_CSp) - ! endif + if (CS%useKPP) then + deallocate( CS%KPP_buoy_flux ) + deallocate( CS%KPP_temp_flux ) + deallocate( CS%KPP_salt_flux ) + endif + if (CS%useKPP) then + deallocate( CS%KPP_NLTheat ) + deallocate( CS%KPP_NLTscalar ) + call KPP_end(CS%KPP_CSp) + endif if (CS%use_tidal_mixing) call tidal_mixing_end(CS%tidal_mixing_CSp) From 65527d6d08c9f9c9813df9e008d0d4bb8572ce6a Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Thu, 19 Apr 2018 14:34:26 -0600 Subject: [PATCH 2/6] Set useKPP = .false. (default) and comment call to diag_grid_storage_end --- src/parameterizations/vertical/MOM_diabatic_driver.F90 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/parameterizations/vertical/MOM_diabatic_driver.F90 b/src/parameterizations/vertical/MOM_diabatic_driver.F90 index be8dafc10b..a17c74b888 100644 --- a/src/parameterizations/vertical/MOM_diabatic_driver.F90 +++ b/src/parameterizations/vertical/MOM_diabatic_driver.F90 @@ -151,7 +151,7 @@ module MOM_diabatic_driver real :: evap_CFL_limit = 0.8 !< The largest fraction of a layer that can be !! evaporated in one time-step (non-dim). - logical :: useKPP !< use CVmix/KPP diffusivities and non-local transport + logical :: useKPP = .false. !< use CVmix/KPP diffusivities and non-local transport logical :: salt_reject_below_ML !< If true, add salt below mixed layer (layer mode only) logical :: KPPisPassive !< If true, KPP is in passive mode, not changing answers. logical :: debug !< If true, write verbose checksums for debugging purposes. @@ -2450,9 +2450,15 @@ subroutine diabatic_driver_end(CS) deallocate(CS%optics) endif - call diag_grid_storage_end(CS%diag_grids_prev) + ! GMM, the following is commented out because arrays in + ! CS%diag_grids_prev are neither pointers or allocatables + ! and, therefore, cannot be deallocated. + + !call diag_grid_storage_end(CS%diag_grids_prev) + if (associated(CS)) deallocate(CS) + end subroutine diabatic_driver_end From e90fbe9443dc45dd5b9d885658a853a619bb7172 Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Thu, 19 Apr 2018 14:35:08 -0600 Subject: [PATCH 3/6] Return if CS is not associated --- src/parameterizations/vertical/MOM_tidal_mixing.F90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/parameterizations/vertical/MOM_tidal_mixing.F90 b/src/parameterizations/vertical/MOM_tidal_mixing.F90 index dcca7d5fb5..90c6bcac88 100644 --- a/src/parameterizations/vertical/MOM_tidal_mixing.F90 +++ b/src/parameterizations/vertical/MOM_tidal_mixing.F90 @@ -1317,6 +1317,8 @@ end subroutine read_tidal_energy subroutine tidal_mixing_end(CS) type(tidal_mixing_cs), pointer :: CS ! This module's control structure + if (.not.associated(CS)) return + !TODO deallocate all the dynamically allocated members here ... if (allocated(CS%tidal_qe_2d)) deallocate(CS%tidal_qe_2d) deallocate(CS%dd) From 4671c0775d9c8388ece1e2a326ad77877d0e4b4e Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Thu, 19 Apr 2018 17:35:06 -0600 Subject: [PATCH 4/6] Comment call diabatic_driver_end to check if Travis still fails --- src/core/MOM.F90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/MOM.F90 b/src/core/MOM.F90 index 22dbb86b15..7fd0cb53a8 100644 --- a/src/core/MOM.F90 +++ b/src/core/MOM.F90 @@ -2901,7 +2901,8 @@ subroutine MOM_end(CS) call tracer_registry_end(CS%tracer_Reg) call tracer_flow_control_end(CS%tracer_flow_CSp) - if (associated(CS%diabatic_CSp)) call diabatic_driver_end(CS%diabatic_CSp) + ! GMM, following call fails on Travis + !if (associated(CS%diabatic_CSp)) call diabatic_driver_end(CS%diabatic_CSp) if (CS%offline_tracer_mode) call offline_transport_end(CS%offline_CSp) From 9f4ce3a8bf794b1437d31680c869d7093efe1f21 Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Thu, 19 Apr 2018 17:57:50 -0600 Subject: [PATCH 5/6] Un-comment call diabatic_driver_end --- src/core/MOM.F90 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/MOM.F90 b/src/core/MOM.F90 index 7fd0cb53a8..22dbb86b15 100644 --- a/src/core/MOM.F90 +++ b/src/core/MOM.F90 @@ -2901,8 +2901,7 @@ subroutine MOM_end(CS) call tracer_registry_end(CS%tracer_Reg) call tracer_flow_control_end(CS%tracer_flow_CSp) - ! GMM, following call fails on Travis - !if (associated(CS%diabatic_CSp)) call diabatic_driver_end(CS%diabatic_CSp) + if (associated(CS%diabatic_CSp)) call diabatic_driver_end(CS%diabatic_CSp) if (CS%offline_tracer_mode) call offline_transport_end(CS%offline_CSp) From 165a5eb6696bce7b0c35ed28495173157c7854cc Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Fri, 20 Apr 2018 08:46:31 -0600 Subject: [PATCH 6/6] Comment call diabatic_driver_end --- src/core/MOM.F90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/MOM.F90 b/src/core/MOM.F90 index 22dbb86b15..5eff86cdcd 100644 --- a/src/core/MOM.F90 +++ b/src/core/MOM.F90 @@ -2901,7 +2901,8 @@ subroutine MOM_end(CS) call tracer_registry_end(CS%tracer_Reg) call tracer_flow_control_end(CS%tracer_flow_CSp) - if (associated(CS%diabatic_CSp)) call diabatic_driver_end(CS%diabatic_CSp) + ! GMM, the following is commented because it fails on Travis. + !if (associated(CS%diabatic_CSp)) call diabatic_driver_end(CS%diabatic_CSp) if (CS%offline_tracer_mode) call offline_transport_end(CS%offline_CSp)