diff --git a/src/core/MOM.F90 b/src/core/MOM.F90 index a6da3b5333..5eff86cdcd 100644 --- a/src/core/MOM.F90 +++ b/src/core/MOM.F90 @@ -2901,6 +2901,7 @@ subroutine MOM_end(CS) call tracer_registry_end(CS%tracer_Reg) call tracer_flow_control_end(CS%tracer_flow_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) diff --git a/src/parameterizations/vertical/MOM_diabatic_driver.F90 b/src/parameterizations/vertical/MOM_diabatic_driver.F90 index 07cfb558cd..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. @@ -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) @@ -2452,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 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)