Skip to content

Commit

Permalink
Re-initialize fields within KPP
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
marshallward committed Jul 4, 2024
1 parent b4ae2b7 commit ac2b642
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/parameterizations/vertical/MOM_diabatic_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ac2b642

Please sign in to comment.