102 type(diffconvection_cs),
pointer :: cs
103 type(ocean_grid_type),
intent(in) :: g
104 type(verticalgrid_type),
intent(in) :: gv
105 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)),
intent(in) :: h
106 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)),
intent(in) :: temp
107 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)),
intent(in) :: salt
108 type(eos_type),
pointer :: eos
109 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)+1),
intent(inout) :: kd_int
113 real,
dimension( G%ke+1 ) :: n2_1d
114 real,
dimension( G%ke+1 ) :: kd_1d
115 real :: gorho, pref, rhok, rhokm1
117 gorho = gv%g_Earth / gv%Rho0
123 do j=g%jsc,g%jec ;
do i=g%isc,g%iec
129 pref = pref + gv%g_Earth * gv%Rho0 * h(i,j,k-1) * gv%H_to_m
131 call calculate_density(temp(i,j,k), salt(i,j,k), pref, rhok, eos)
132 call calculate_density(temp(i,j,k-1), salt(i,j,k-1), pref, rhokm1, eos)
133 n2_1d(k) = gorho * (rhok - rhokm1) / &
134 (0.5*(h(i,j,k-1) + h(i,j,k)) + gv%H_subroundoff)
136 if (n2_1d(k) < 0.) kd_1d(k) = cs%Kd_convection
139 if (.not. cs%passiveMode) kd_int(i,j,:) = kd_int(i,j,:) + kd_1d(:)
141 if (cs%id_N2 > 0) cs%N2(i,j,:) = n2_1d(:)
142 if (cs%id_Kd_conv > 0) cs%Kd_conv(i,j,:) = kd_1d(:)
146 if (cs%id_N2 > 0)
call post_data(cs%id_N2, cs%N2, cs%diag)
147 if (cs%id_Kd_conv > 0)
call post_data(cs%id_Kd_conv, cs%Kd_conv, cs%diag)