FV3 Bundle
gsw_specvol_first_derivatives.f90
Go to the documentation of this file.
1 !==========================================================================
2 elemental subroutine gsw_specvol_first_derivatives (sa, ct, p, v_sa, v_ct, &
3  v_p, iflag)
4 ! =========================================================================
5 !
6 ! Calculates three first-order derivatives of specific volume (v).
7 ! Note that this function uses the computationally-efficient
8 ! expression for specific volume (Roquet et al., 2014).
9 !
10 ! SA = Absolute Salinity [ g/kg ]
11 ! CT = Conservative Temperature (ITS-90) [ deg C ]
12 ! p = sea pressure [ dbar ]
13 ! ( i.e. absolute pressure - 10.1325 dbar )
14 !
15 ! v_SA = The first derivative of specific volume with respect to
16 ! Absolute Salinity at constant CT & p. [ J/(kg (g/kg)^2) ]
17 ! v_CT = The first derivative of specific volume with respect to
18 ! CT at constant SA and p. [ J/(kg K(g/kg)) ]
19 ! v_P = The first derivative of specific volume with respect to
20 ! P at constant SA and CT. [ J/(kg K^2) ]
21 !--------------------------------------------------------------------------
22 
24 
26 
27 use gsw_mod_kinds
28 
29 implicit none
30 
31 real (r8), intent(in) :: sa, ct, p
32 integer, intent(in), optional :: iflag
33 real (r8), intent(out), optional :: v_sa, v_ct, v_p
34 
35 integer :: i
36 logical :: flags(3)
37 real (r8) :: v_ct_part, v_p_part, v_sa_part, xs, ys, z
38 
39 xs = sqrt(gsw_sfac*sa + offset)
40 ys = ct*0.025_r8
41 z = p*1e-4_r8
42 
43 if (present(iflag)) then
44  do i = 1, 3
45  flags(i) = btest(iflag,i)
46  end do
47 else
48  flags = .true.
49 end if
50 
51 if (present(v_sa) .and. flags(1)) then
52 
53  v_sa_part = b000 + xs*(b100 + xs*(b200 + xs*(b300 + xs*(b400 + b500*xs)))) &
54  + ys*(b010 + xs*(b110 + xs*(b210 + xs*(b310 + b410*xs))) &
55  + ys*(b020 + xs*(b120 + xs*(b220 + b320*xs)) + ys*(b030 &
56  + xs*(b130 + b230*xs) + ys*(b040 + b140*xs + b050*ys)))) &
57  + z*(b001 + xs*(b101 + xs*(b201 + xs*(b301 + b401*xs))) &
58  + ys*(b011 + xs*(b111 + xs*(b211 + b311*xs)) + ys*(b021 &
59  + xs*(b121 + b221*xs) + ys*(b031 + b131*xs + b041*ys))) &
60  + z*(b002 + xs*(b102 + xs*(b202 + b302*xs))+ ys*(b012 &
61  + xs*(b112 + b212*xs) + ys*(b022 + b122*xs + b032*ys)) &
62  + z*(b003 + b103*xs + b013*ys + b004*z)))
63 
64  v_sa = 0.5_r8*gsw_sfac*v_sa_part/xs
65 
66 end if
67 
68 
69 if (present(v_ct) .and. flags(2)) then
70 
71  v_ct_part = a000 + xs*(a100 + xs*(a200 + xs*(a300 + xs*(a400 + a500*xs)))) &
72  + ys*(a010 + xs*(a110 + xs*(a210 + xs*(a310 + a410*xs))) &
73  + ys*(a020 + xs*(a120 + xs*(a220 + a320*xs)) + ys*(a030 &
74  + xs*(a130 + a230*xs) + ys*(a040 + a140*xs + a050*ys )))) &
75  + z*(a001 + xs*(a101 + xs*(a201 + xs*(a301 + a401*xs))) &
76  + ys*(a011 + xs*(a111 + xs*(a211 + a311*xs)) + ys*(a021 &
77  + xs*(a121 + a221*xs) + ys*(a031 + a131*xs + a041*ys))) &
78  + z*(a002 + xs*(a102 + xs*(a202 + a302*xs)) + ys*(a012 &
79  + xs*(a112 + a212*xs) + ys*(a022 + a122*xs + a032*ys)) &
80  + z*(a003 + a103*xs + a013*ys + a004*z)))
81 
82  v_ct = 0.025_r8*v_ct_part
83 
84 end if
85 
86 if (present(v_p) .and. flags(3)) then
87 
88  v_p_part = c000 + xs*(c100 + xs*(c200 + xs*(c300 + xs*(c400 + c500*xs)))) &
89  + ys*(c010 + xs*(c110 + xs*(c210 + xs*(c310 + c410*xs))) + ys*(c020 &
90  + xs*(c120 + xs*(c220 + c320*xs)) + ys*(c030 + xs*(c130 + c230*xs) &
91  + ys*(c040 + c140*xs + c050*ys)))) + z*(c001 + xs*(c101 + xs*(c201 &
92  + xs*(c301 + c401*xs))) + ys*(c011 + xs*(c111 + xs*(c211 + c311*xs)) &
93  + ys*(c021 + xs*(c121 + c221*xs) + ys*(c031 + c131*xs + c041*ys))) &
94  + z*( c002 + xs*(c102 + c202*xs) + ys*(c012 + c112*xs + c022*ys) &
95  + z*(c003 + c103*xs + c013*ys + z*(c004 + c005*z))))
96 
97  v_p = 1e-8_r8*v_p_part
98 
99 end if
100 
101 return
102 end subroutine
103 
104 !--------------------------------------------------------------------------
elemental subroutine gsw_specvol_first_derivatives(sa, ct, p, v_sa, v_ct, v_p, iflag)