From ac2b642f4f60dbfeebcaef5f1d08d202e3a01b56 Mon Sep 17 00:00:00 2001 From: Marshall Ward Date: Tue, 2 Jul 2024 15:44:08 -0400 Subject: [PATCH] Re-initialize fields within KPP Five fields associated with KPP were previously initialized during allocation (using `source=0.`). It was found that the allocations were unnecessary, and the fields were redefined as local variables within functions, without the initialization to zero. Although the uninitialized points were masked and unused in the rest of the model, they were still able to change the checksums and were being reported as regressions. This patch restores the original checksums by re-implementing the zero initialization. Thanks to Bob Hallberg (@Hallberg-NOAA) for diagnosing this issue. --- .../vertical/MOM_diabatic_driver.F90 | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/parameterizations/vertical/MOM_diabatic_driver.F90 b/src/parameterizations/vertical/MOM_diabatic_driver.F90 index b450127156..d7cb102e05 100644 --- a/src/parameterizations/vertical/MOM_diabatic_driver.F90 +++ b/src/parameterizations/vertical/MOM_diabatic_driver.F90 @@ -676,6 +676,14 @@ subroutine diabatic_ALE_legacy(u, v, h, tv, BLD, fluxes, visc, ADp, CDp, dt, Tim call cpu_clock_begin(id_clock_kpp) ! total vertical viscosity in the interior is represented via visc%Kv_shear + ! NOTE: The following do not require initialization, but their checksums do + ! require initialization, and past versions were initialized to zero. + KPP_NLTheat(:,:,:) = 0. + KPP_NLTscalar(:,:,:) = 0. + KPP_buoy_flux(:,:,:) = 0. + KPP_temp_flux(:,:) = 0. + KPP_salt_flux(:,:) = 0. + ! KPP needs the surface buoyancy flux but does not update state variables. ! We could make this call higher up to avoid a repeat unpacking of the surface fluxes. ! Sets: KPP_buoy_flux, KPP_temp_flux, KPP_salt_flux @@ -1288,6 +1296,14 @@ subroutine diabatic_ALE(u, v, h, tv, BLD, fluxes, visc, ADp, CDp, dt, Time_end, visc%Kv_shear(i,j,k) = visc%Kv_shear(i,j,k) + visc%Kv_slow(i,j,k) enddo ; enddo ; enddo + ! NOTE: The following do not require initialization, but their checksums do + ! require initialization, and past versions were initialized to zero. + KPP_NLTheat(:,:,:) = 0. + KPP_NLTscalar(:,:,:) = 0. + KPP_buoy_flux(:,:,:) = 0. + KPP_temp_flux(:,:) = 0. + KPP_salt_flux(:,:) = 0. + ! KPP needs the surface buoyancy flux but does not update state variables. ! We could make this call higher up to avoid a repeat unpacking of the surface fluxes. ! Sets: KPP_buoy_flux, KPP_temp_flux, KPP_salt_flux @@ -1885,6 +1901,15 @@ subroutine layered_diabatic(u, v, h, tv, BLD, fluxes, visc, ADp, CDp, dt, Time_e if (CS%useKPP) then call cpu_clock_begin(id_clock_kpp) + + ! NOTE: The following do not require initialization, but their checksums do + ! require initialization, and past versions were initialized to zero. + KPP_NLTheat(:,:,:) = 0. + KPP_NLTscalar(:,:,:) = 0. + KPP_buoy_flux(:,:,:) = 0. + KPP_temp_flux(:,:) = 0. + KPP_salt_flux(:,:) = 0. + ! KPP needs the surface buoyancy flux but does not update state variables. ! We could make this call higher up to avoid a repeat unpacking of the surface fluxes. ! Sets: KPP_buoy_flux, KPP_temp_flux, KPP_salt_flux