34 real (r8),
intent(in) :: sa(:), ct(:), p(:), lat(:)
35 real (r8),
intent(out) :: n2(:), p_mid(:)
38 real (r8),
dimension(:),
allocatable :: dsa, sa_mid, dct, ct_mid, dp, rho_mid
39 real (r8),
dimension(:),
allocatable :: alpha_mid, beta_mid, grav_local,
grav 41 character (*),
parameter :: func_name =
"gsw_nsquared" 44 if (
size(n2).lt.nz-1 .or.
size(p_mid).lt.nz-1)
then 50 allocate (
grav(nz), dsa(nz-1), sa_mid(nz-1), dct(nz-1), ct_mid(nz-1), dp(nz-1))
51 allocate (rho_mid(nz-1), alpha_mid(nz-1), beta_mid(nz-1), grav_local(nz-1))
56 grav_local(k) = 0.5_r8*(
grav(k) +
grav(k+1))
57 dsa(k) = (sa(k+1) - sa(k))
58 sa_mid(k) = 0.5_r8*(sa(k) + sa(k+1))
59 dct(k) = (ct(k+1) - ct(k))
60 ct_mid(k) = 0.5_r8*(ct(k) + ct(k+1))
61 dp(k) = (p(k+1) - p(k))
62 p_mid(k) = 0.5_r8*(p(k) + p(k+1))
67 n2(1:nz-1) = (grav_local**2) * (rho_mid/(
db2pa*dp)) * &
68 (beta_mid*dsa - alpha_mid*dct)
70 deallocate (
grav, dsa, sa_mid, dct, ct_mid, dp)
71 deallocate (rho_mid, alpha_mid, beta_mid, grav_local)
pure subroutine gsw_nsquared(sa, ct, p, lat, n2, p_mid)
real(r8), parameter db2pa
real, parameter, public grav
Acceleration due to gravity [m/s^2].
elemental real(r8) function, public gsw_error_code(err_num, func_name, error_code)