Skip to content

Commit

Permalink
Avoid allocating unused arrays in diabatic_driver
Browse files Browse the repository at this point in the history
- In order to call calculateBuoyancyFlux2d() along with the ePBL
  the KPP fields are all allocated but not all are needed. This
  allocates only those used.
  • Loading branch information
adcroft committed Jul 2, 2017
1 parent a1ac57f commit 04116e8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/parameterizations/vertical/MOM_diabatic_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2073,13 +2073,15 @@ subroutine diabatic_driver_init(Time, G, GV, param_file, useALEalgorithm, diag,
! CS%useKPP is set to True if KPP-scheme is to be used, False otherwise.
! KPP_init() allocated CS%KPP_Csp and also sets CS%KPPisPassive
CS%useKPP = KPP_init(param_file, G, diag, Time, CS%KPP_CSp, passive=CS%KPPisPassive)
if (CS%useKPP .or. CS%use_energetic_PBL) then
if (CS%useKPP) then
allocate( CS%KPP_NLTheat(isd:ied,jsd:jed,nz+1) ) ; CS%KPP_NLTheat(:,:,:) = 0.
allocate( CS%KPP_NLTscalar(isd:ied,jsd:jed,nz+1) ) ; CS%KPP_NLTscalar(:,:,:) = 0.
endif
if (CS%useKPP .or. CS%use_energetic_PBL) then
allocate( CS%KPP_buoy_flux(isd:ied,jsd:jed,nz+1) ) ; CS%KPP_buoy_flux(:,:,:) = 0.
allocate( CS%KPP_temp_flux(isd:ied,jsd:jed) ) ; CS%KPP_temp_flux(:,:) = 0.
allocate( CS%KPP_salt_flux(isd:ied,jsd:jed) ) ; CS%KPP_salt_flux(:,:) = 0.
endif
endif

call get_param(param_file, mod, "SALT_REJECT_BELOW_ML", CS%salt_reject_below_ML, &
"If true, place salt from brine rejection below the mixed layer,\n"// &
Expand Down Expand Up @@ -2319,11 +2321,13 @@ subroutine diabatic_driver_end(CS)
call entrain_diffusive_end(CS%entrain_diffusive_CSp)
call set_diffusivity_end(CS%set_diff_CSp)
if (CS%useKPP .or. CS%use_energetic_PBL) then
deallocate( CS%KPP_NLTheat )
deallocate( CS%KPP_NLTscalar )
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%useConvection) call diffConvection_end(CS%Conv_CSp)
Expand Down

0 comments on commit 04116e8

Please sign in to comment.