@@ -289,9 +289,9 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
289289 integer :: i, j, k, m, is, ie, js, je, nz
290290 logical :: showCallTree ! If true, show the call tree
291291
292- real , allocatable (:,:,:) :: h_in ! thickness before thermodynamics
293- real , allocatable (:,:,:) :: t_in ! temperature before thermodynamics
294- real , allocatable (:,:,:) :: s_in ! salinity before thermodynamics
292+ real , allocatable , dimension (:,:,:) :: h_in ! thickness before thermodynamics
293+ real , allocatable , dimension (:,:,:) :: t_in ! temperature before thermodynamics
294+ real , allocatable , dimension (:,:,:) :: s_in ! salinity before thermodynamics
295295 real :: t_tend,s_tend,h_tend ! holder for tendencey needed for SPPT
296296 real :: t_pert,s_pert,h_pert ! holder for perturbations needed for SPPT
297297
@@ -302,9 +302,9 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
302302 allocate (h_in(G% isd:G% ied, G% jsd:G% jed,G% ke))
303303 allocate (t_in(G% isd:G% ied, G% jsd:G% jed,G% ke))
304304 allocate (s_in(G% isd:G% ied, G% jsd:G% jed,G% ke))
305- h_in(:,:) = h( :,:)
306- t_in(:,:) = tv% T(:,:)
307- s_in(:,:) = tv% S(:,:)
305+ h_in(:,:,:) = h(:, :,:)
306+ t_in(:,:,:) = tv% T(:, :,:)
307+ s_in(:,:,:) = tv% S(:, :,:)
308308
309309 if (CS% id_sppt_wts > 0 ) then
310310 call post_data(CS% id_sppt_wts, fluxes% sppt_wts, CS% diag)
@@ -458,6 +458,7 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
458458 if (CS% debugConservation) call MOM_state_stats(' leaving diabatic' , u, v, h, tv% T, tv% S, G, GV, US)
459459
460460 if (CS% do_sppt) then
461+ ! perturb diabatic tendecies
461462 do k= 1 ,nz
462463 do j= js,je
463464 do i= is,ie
@@ -468,17 +469,20 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
468469 t_pert= t_tend+ t_in(i,j,k)
469470 s_pert= s_tend+ s_in(i,j,k)
470471 if (h_pert > GV% Angstrom_H) then
471- h(i,j,k)= h_pert
472+ h(i,j,k) = h_pert
472473 else
473- h(i,j,k)= GV% Angstrom_H
474+ h(i,j,k) = GV% Angstrom_H
474475 endif
475- tv% T(i,j,k)= t_pert
476+ tv% T(i,j,k) = t_pert
476477 if (s_pert > 0.0 ) then
477- tv% S(i,j,k)= s_pert
478+ tv% S(i,j,k) = s_pert
478479 endif
479480 enddo
480481 enddo
481482 enddo
483+ deallocate (h_in)
484+ deallocate (t_in)
485+ deallocate (s_in)
482486 endif
483487
484488end subroutine diabatic
0 commit comments