30 implicit none ;
private 32 #include <MOM_memory.h> 55 real,
parameter ::
a0 = 7.057924e-4,
a1 = 3.480336e-7,
a2 = -1.112733e-7
56 real,
parameter ::
b0 = 5.790749e8,
b1 = 3.516535e6,
b2 = -4.002714e4
57 real,
parameter ::
b3 = 2.084372e2,
b4 = 5.944068e5,
b5 = -9.643486e3
58 real,
parameter ::
c0 = 1.704853e5,
c1 = 7.904722e2,
c2 = -7.984422
59 real,
parameter ::
c3 = 5.140652e-2,
c4 = -2.302158e2,
c5 = -3.079464
71 real,
intent(in) :: pressure
72 real,
intent(out) :: rho
89 real :: al0, p0, lambda
91 real,
dimension(1) :: T0, S0, pressure0
92 real,
dimension(1) :: rho0
96 pressure0(1) = pressure
109 real,
intent(in),
dimension(:) :: T
111 real,
intent(in),
dimension(:) :: S
112 real,
intent(in),
dimension(:) :: pressure
113 real,
intent(out),
dimension(:) :: rho
114 integer,
intent(in) :: start
115 integer,
intent(in) :: npts
131 real :: al0, p0, lambda
134 do j=start,start+npts-1
135 al0 = (
a0 +
a1*t(j)) +
a2*s(j)
136 p0 = (
b0 +
b4*s(j)) + t(j) * (
b1 + t(j)*((
b2 +
b3*t(j))) +
b5*s(j))
137 lambda = (
c0 +
c4*s(j)) + t(j) * (
c1 + t(j)*((
c2 +
c3*t(j))) +
c5*s(j))
139 rho(j) = (pressure(j) + p0) / (lambda + al0*(pressure(j) + p0))
145 real,
intent(in),
dimension(:) :: T
147 real,
intent(in),
dimension(:) :: S
148 real,
intent(in),
dimension(:) :: pressure
149 real,
intent(out),
dimension(:) :: drho_dT
151 real,
intent(out),
dimension(:) :: drho_dS
153 integer,
intent(in) :: start
154 integer,
intent(in) :: npts
165 real :: al0, p0, lambda, I_denom2
168 do j=start,start+npts-1
169 al0 = (
a0 +
a1*t(j)) +
a2*s(j)
170 p0 = (
b0 +
b4*s(j)) + t(j) * (
b1 + t(j)*((
b2 +
b3*t(j))) +
b5*s(j))
171 lambda = (
c0 +
c4*s(j)) + t(j) * (
c1 + t(j)*((
c2 +
c3*t(j))) +
c5*s(j))
173 i_denom2 = 1.0 / (lambda + al0*(pressure(j) + p0))
174 i_denom2 = i_denom2 *i_denom2
175 drho_dt(j) = i_denom2 * &
176 (lambda* (
b1 + t(j)*(2.0*
b2 + 3.0*
b3*t(j)) +
b5*s(j)) - &
177 (pressure(j)+p0) * ( (pressure(j)+p0)*
a1 + &
178 (
c1 + t(j)*(
c2*2.0 +
c3*3.0*t(j)) +
c5*s(j)) ))
179 drho_ds(j) = i_denom2 * (lambda* (
b4 +
b5*t(j)) - &
180 (pressure(j)+p0) * ( (pressure(j)+p0)*
a2 + (
c4 +
c5*t(j)) ))
186 real,
intent(in),
dimension(:) :: T
188 real,
intent(in),
dimension(:) :: S
189 real,
intent(in),
dimension(:) :: pressure
190 real,
intent(out),
dimension(:) :: dSV_dT
192 real,
intent(out),
dimension(:) :: dSV_dS
194 integer,
intent(in) :: start
195 integer,
intent(in) :: npts
206 real :: al0, p0, lambda, I_denom
209 do j=start,start+npts-1
211 p0 = (
b0 +
b4*s(j)) + t(j) * (
b1 + t(j)*((
b2 +
b3*t(j))) +
b5*s(j))
212 lambda = (
c0 +
c4*s(j)) + t(j) * (
c1 + t(j)*((
c2 +
c3*t(j))) +
c5*s(j))
216 i_denom = 1.0 / (pressure(j) + p0)
217 dsv_dt(j) = (
a1 + i_denom * (
c1 + t(j)*((2.0*
c2 + 3.0*
c3*t(j))) +
c5*s(j))) - &
218 (i_denom**2 * lambda) * (
b1 + t(j)*((2.0*
b2 + 3.0*
b3*t(j))) +
b5*s(j))
219 dsv_ds(j) = (
a2 + i_denom * (
c4 +
c5*t(j))) - &
220 (i_denom**2 * lambda) * (
b4 +
b5*t(j))
232 real,
intent(in),
dimension(:) :: T
234 real,
intent(in),
dimension(:) :: S
235 real,
intent(in),
dimension(:) :: pressure
236 real,
intent(out),
dimension(:) :: rho
237 real,
intent(out),
dimension(:) :: drho_dp
240 integer,
intent(in) :: start
241 integer,
intent(in) :: npts
260 real :: al0, p0, lambda, I_denom
263 do j=start,start+npts-1
264 al0 = (
a0 +
a1*t(j)) +
a2*s(j)
265 p0 = (
b0 +
b4*s(j)) + t(j) * (
b1 + t(j)*((
b2 +
b3*t(j))) +
b5*s(j))
266 lambda = (
c0 +
c4*s(j)) + t(j) * (
c1 + t(j)*((
c2 +
c3*t(j))) +
c5*s(j))
268 i_denom = 1.0 / (lambda + al0*(pressure(j) + p0))
269 rho(j) = (pressure(j) + p0) * i_denom
270 drho_dp(j) = lambda * i_denom * i_denom
278 dpa, intz_dpa, intx_dpa, inty_dpa)
280 real,
dimension(HII%isd:HII%ied,HII%jsd:HII%jed), &
283 real,
dimension(HII%isd:HII%ied,HII%jsd:HII%jed), &
285 real,
dimension(HII%isd:HII%ied,HII%jsd:HII%jed), &
287 real,
dimension(HII%isd:HII%ied,HII%jsd:HII%jed), &
289 real,
intent(in) :: rho_ref
292 real,
intent(in) :: rho_0
295 real,
intent(in) :: G_e
296 real,
dimension(HIO%isd:HIO%ied,HIO%jsd:HIO%jed), &
299 real,
dimension(HIO%isd:HIO%ied,HIO%jsd:HIO%jed), &
300 optional,
intent(out) :: intz_dpa
303 real,
dimension(HIO%IsdB:HIO%IedB,HIO%jsd:HIO%jed), &
304 optional,
intent(out) :: intx_dpa
307 real,
dimension(HIO%isd:HIO%ied,HIO%JsdB:HIO%JedB), &
308 optional,
intent(out) :: inty_dpa
339 real,
dimension(HII%isd:HII%ied,HII%jsd:HII%jed) :: al0_2d, p0_2d, lambda_2d
340 real :: al0, p0, lambda
341 real :: eps, eps2, rho_anom, rem
342 real :: w_left, w_right, intz(5)
343 real,
parameter :: C1_3 = 1.0/3.0, c1_7 = 1.0/7.0
344 real,
parameter :: C1_9 = 1.0/9.0, c1_90 = 1.0/90.0
346 real :: dz, p_ave, I_al0, I_Lzz
347 integer :: is, ie, js, je, Isq, Ieq, Jsq, Jeq, i, j, ioff, joff, m
349 ioff = hio%idg_offset - hii%idg_offset
350 joff = hio%jdg_offset - hii%jdg_offset
354 isq = hio%IscB + ioff ; ieq = hio%IecB + ioff
355 jsq = hio%JscB + joff ; jeq = hio%JecB + joff
356 is = hio%isc + ioff ; ie = hio%iec + ioff
357 js = hio%jsc + joff ; je = hio%jec + joff
362 do j=jsq,jeq+1 ;
do i=isq,ieq+1
363 al0_2d(i,j) = (
a0 +
a1*t(i,j)) +
a2*s(i,j)
364 p0_2d(i,j) = (
b0 +
b4*s(i,j)) + t(i,j) * (
b1 + t(i,j)*((
b2 +
b3*t(i,j))) +
b5*s(i,j))
365 lambda_2d(i,j) = (
c0 +
c4*s(i,j)) + t(i,j) * (
c1 + t(i,j)*((
c2 +
c3*t(i,j))) +
c5*s(i,j))
367 al0 = al0_2d(i,j) ; p0 = p0_2d(i,j) ; lambda = lambda_2d(i,j)
369 dz = z_t(i,j) - z_b(i,j)
370 p_ave = -0.5*gxrho*(z_t(i,j)+z_b(i,j))
373 i_lzz = 1.0 / (p0 + (lambda * i_al0) + p_ave)
374 eps = 0.5*gxrho*dz*i_lzz ; eps2 = eps*eps
378 rho_anom = (p0 + p_ave)*(i_lzz*i_al0) - rho_ref
379 rem = i_rho * (lambda * i_al0**2) * eps2 * &
380 (c1_3 + eps2*(0.2 + eps2*(c1_7 + c1_9*eps2)))
381 dpa(i-ioff,j-joff) = g_e*rho_anom*dz - 2.0*eps*rem
382 if (
present(intz_dpa)) &
383 intz_dpa(i-ioff,j-joff) = 0.5*g_e*rho_anom*dz**2 - dz*(1.0+eps)*rem
386 if (
present(intx_dpa))
then ;
do j=js,je ;
do i=isq,ieq
387 intz(1) = dpa(i-ioff,j-joff) ; intz(5) = dpa(i+1-ioff,j-joff)
389 w_left = 0.25*
real(m-1) ; w_right = 1.0-w_left
390 al0 = w_left*al0_2d(i,j) + w_right*al0_2d(i+1,j)
391 p0 = w_left*p0_2d(i,j) + w_right*p0_2d(i+1,j)
392 lambda = w_left*lambda_2d(i,j) + w_right*lambda_2d(i+1,j)
394 dz = w_left*(z_t(i,j) - z_b(i,j)) + w_right*(z_t(i+1,j) - z_b(i+1,j))
395 p_ave = -0.5*gxrho*(w_left*(z_t(i,j)+z_b(i,j)) + &
396 w_right*(z_t(i+1,j)+z_b(i+1,j)))
399 i_lzz = 1.0 / (p0 + (lambda * i_al0) + p_ave)
400 eps = 0.5*gxrho*dz*i_lzz ; eps2 = eps*eps
402 intz(m) = g_e*dz*((p0 + p_ave)*(i_lzz*i_al0) - rho_ref) - 2.0*eps * &
403 i_rho * (lambda * i_al0**2) * eps2 * &
404 (c1_3 + eps2*(0.2 + eps2*(c1_7 + c1_9*eps2)))
407 intx_dpa(i-ioff,j-joff) = c1_90*(7.0*(intz(1)+intz(5)) + 32.0*(intz(2)+intz(4)) + &
409 enddo ;
enddo ;
endif 411 if (
present(inty_dpa))
then ;
do j=jsq,jeq ;
do i=is,ie
412 intz(1) = dpa(i-ioff,j-joff) ; intz(5) = dpa(i-ioff,j+1-joff)
414 w_left = 0.25*
real(m-1) ; w_right = 1.0-w_left
415 al0 = w_left*al0_2d(i,j) + w_right*al0_2d(i,j+1)
416 p0 = w_left*p0_2d(i,j) + w_right*p0_2d(i,j+1)
417 lambda = w_left*lambda_2d(i,j) + w_right*lambda_2d(i,j+1)
419 dz = w_left*(z_t(i,j) - z_b(i,j)) + w_right*(z_t(i,j+1) - z_b(i,j+1))
420 p_ave = -0.5*gxrho*(w_left*(z_t(i,j)+z_b(i,j)) + &
421 w_right*(z_t(i,j+1)+z_b(i,j+1)))
424 i_lzz = 1.0 / (p0 + (lambda * i_al0) + p_ave)
425 eps = 0.5*gxrho*dz*i_lzz ; eps2 = eps*eps
427 intz(m) = g_e*dz*((p0 + p_ave)*(i_lzz*i_al0) - rho_ref) - 2.0*eps * &
428 i_rho * (lambda * i_al0**2) * eps2 * &
429 (c1_3 + eps2*(0.2 + eps2*(c1_7 + c1_9*eps2)))
432 inty_dpa(i-ioff,j-joff) = c1_90*(7.0*(intz(1)+intz(5)) + 32.0*(intz(2)+intz(4)) + &
434 enddo ;
enddo ;
endif 444 intp_dza, intx_dza, inty_dza, halo_size)
446 real,
dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
449 real,
dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
451 real,
dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
453 real,
dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
455 real,
intent(in) :: alpha_ref
459 real,
dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
462 real,
dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
463 optional,
intent(out) :: intp_dza
466 real,
dimension(HI%IsdB:HI%IedB,HI%jsd:HI%jed), &
467 optional,
intent(out) :: intx_dza
471 real,
dimension(HI%isd:HI%ied,HI%JsdB:HI%JedB), &
472 optional,
intent(out) :: inty_dza
476 integer,
optional,
intent(in) :: halo_size
509 real,
dimension(HI%isd:HI%ied,HI%jsd:HI%jed) :: al0_2d, p0_2d, lambda_2d
510 real :: al0, p0, lambda
511 real :: alpha_anom, dp, p_ave
512 real :: rem, eps, eps2
513 real :: w_left, w_right, intp(5)
514 real,
parameter :: C1_3 = 1.0/3.0, c1_7 = 1.0/7.0
515 real,
parameter :: C1_9 = 1.0/9.0, c1_90 = 1.0/90.0
516 integer :: Isq, Ieq, Jsq, Jeq, ish, ieh, jsh, jeh, i, j, m, halo
518 isq = hi%IscB ; ieq = hi%IecB ; jsq = hi%JscB ; jeq = hi%JecB
519 halo = 0 ;
if (
present(halo_size)) halo = max(halo_size,0)
520 ish = hi%isc-halo ; ieh = hi%iec+halo ; jsh = hi%jsc-halo ; jeh = hi%jec+halo
521 if (
present(intx_dza))
then ; ish = min(isq,ish) ; ieh = max(ieq+1,ieh);
endif 522 if (
present(inty_dza))
then ; jsh = min(jsq,jsh) ; jeh = max(jeq+1,jeh);
endif 524 if (
present(intp_dza))
then 525 do j=jsh,jeh ;
do i=ish,ieh
526 al0_2d(i,j) = (
a0 +
a1*t(i,j)) +
a2*s(i,j)
527 p0_2d(i,j) = (
b0 +
b4*s(i,j)) + t(i,j) * (
b1 + t(i,j)*((
b2 +
b3*t(i,j))) +
b5*s(i,j))
528 lambda_2d(i,j) = (
c0 +
c4*s(i,j)) + t(i,j) * (
c1 + t(i,j)*((
c2 +
c3*t(i,j))) +
c5*s(i,j))
530 al0 = al0_2d(i,j) ; p0 = p0_2d(i,j) ; lambda = lambda_2d(i,j)
531 dp = p_b(i,j) - p_t(i,j)
532 p_ave = 0.5*(p_t(i,j)+p_b(i,j))
534 eps = 0.5 * dp / (p0 + p_ave) ; eps2 = eps*eps
535 alpha_anom = al0 + lambda / (p0 + p_ave) - alpha_ref
536 rem = lambda * eps2 * (c1_3 + eps2*(0.2 + eps2*(c1_7 + c1_9*eps2)))
537 dza(i,j) = alpha_anom*dp + 2.0*eps*rem
538 intp_dza(i,j) = 0.5*alpha_anom*dp**2 - dp*(1.0-eps)*rem
541 do j=jsh,jeh ;
do i=ish,ieh
542 al0_2d(i,j) = (
a0 +
a1*t(i,j)) +
a2*s(i,j)
543 p0_2d(i,j) = (
b0 +
b4*s(i,j)) + t(i,j) * (
b1 + t(i,j)*((
b2 +
b3*t(i,j))) +
b5*s(i,j))
544 lambda_2d(i,j) = (
c0 +
c4*s(i,j)) + t(i,j) * (
c1 + t(i,j)*((
c2 +
c3*t(i,j))) +
c5*s(i,j))
546 al0 = al0_2d(i,j) ; p0 = p0_2d(i,j) ; lambda = lambda_2d(i,j)
547 dp = p_b(i,j) - p_t(i,j)
548 p_ave = 0.5*(p_t(i,j)+p_b(i,j))
550 eps = 0.5 * dp / (p0 + p_ave) ; eps2 = eps*eps
551 alpha_anom = al0 + lambda / (p0 + p_ave) - alpha_ref
552 rem = lambda * eps2 * (c1_3 + eps2*(0.2 + eps2*(c1_7 + c1_9*eps2)))
553 dza(i,j) = alpha_anom*dp + 2.0*eps*rem
557 if (
present(intx_dza))
then ;
do j=hi%jsc,hi%jec ;
do i=isq,ieq
558 intp(1) = dza(i,j) ; intp(5) = dza(i+1,j)
560 w_left = 0.25*
real(5-m) ; w_right = 1.0-w_left
561 al0 = w_left*al0_2d(i,j) + w_right*al0_2d(i+1,j)
562 p0 = w_left*p0_2d(i,j) + w_right*p0_2d(i+1,j)
563 lambda = w_left*lambda_2d(i,j) + w_right*lambda_2d(i+1,j)
565 dp = w_left*(p_b(i,j) - p_t(i,j)) + w_right*(p_b(i+1,j) - p_t(i+1,j))
566 p_ave = 0.5*(w_left*(p_t(i,j)+p_b(i,j)) + w_right*(p_t(i+1,j)+p_b(i+1,j)))
568 eps = 0.5 * dp / (p0 + p_ave) ; eps2 = eps*eps
569 intp(m) = (al0 + lambda / (p0 + p_ave) - alpha_ref)*dp + 2.0*eps* &
570 lambda * eps2 * (c1_3 + eps2*(0.2 + eps2*(c1_7 + c1_9*eps2)))
573 intx_dza(i,j) = c1_90*(7.0*(intp(1)+intp(5)) + 32.0*(intp(2)+intp(4)) + &
575 enddo ;
enddo ;
endif 577 if (
present(inty_dza))
then ;
do j=jsq,jeq ;
do i=hi%isc,hi%iec
578 intp(1) = dza(i,j) ; intp(5) = dza(i,j+1)
580 w_left = 0.25*
real(5-m) ; w_right = 1.0-w_left
581 al0 = w_left*al0_2d(i,j) + w_right*al0_2d(i,j+1)
582 p0 = w_left*p0_2d(i,j) + w_right*p0_2d(i,j+1)
583 lambda = w_left*lambda_2d(i,j) + w_right*lambda_2d(i,j+1)
585 dp = w_left*(p_b(i,j) - p_t(i,j)) + w_right*(p_b(i,j+1) - p_t(i,j+1))
586 p_ave = 0.5*(w_left*(p_t(i,j)+p_b(i,j)) + w_right*(p_t(i,j+1)+p_b(i,j+1)))
588 eps = 0.5 * dp / (p0 + p_ave) ; eps2 = eps*eps
589 intp(m) = (al0 + lambda / (p0 + p_ave) - alpha_ref)*dp + 2.0*eps* &
590 lambda * eps2 * (c1_3 + eps2*(0.2 + eps2*(c1_7 + c1_9*eps2)))
593 inty_dza(i,j) = c1_90*(7.0*(intp(1)+intp(5)) + 32.0*(intp(2)+intp(4)) + &
595 enddo ;
enddo ;
endif
subroutine, public calculate_density_derivs_wright(T, S, pressure, drho_dT, drho_dS, start, npts)
subroutine, public calculate_density_scalar_wright(T, S, pressure, rho)
This subroutine computes the in situ density of sea water (rho in units of kg/m^3) from salinity (S i...
Defines the horizontal index type (hor_index_type) used for providing index ranges.
Container for horizontal index ranges for data, computational and global domains. ...
subroutine, public calculate_specvol_derivs_wright(T, S, pressure, dSV_dT, dSV_dS, start, npts)
subroutine, public calculate_compress_wright(T, S, pressure, rho, drho_dp, start, npts)
This subroutine computes the in situ density of sea water (rho in units of kg/m^3) and the compressib...
subroutine, public int_spec_vol_dp_wright(T, S, p_t, p_b, alpha_ref, HI, dza, intp_dza, intx_dza, inty_dza, halo_size)
This subroutine calculates analytical and nearly-analytical integrals in pressure across layers of ge...
subroutine, public calculate_density_array_wright(T, S, pressure, rho, start, npts)
This subroutine computes the in situ density of sea water (rho in units of kg/m^3) from salinity (S i...
subroutine, public int_density_dz_wright(T, S, z_t, z_b, rho_ref, rho_0, G_e, HII, HIO, dpa, intz_dpa, intx_dpa, inty_dpa)
This subroutine calculates analytical and nearly-analytical integrals of pressure anomalies across la...