FV3 Bundle
gsw_enthalpy_second_derivatives.f90
Go to the documentation of this file.
1 !==========================================================================
2 elemental subroutine gsw_enthalpy_second_derivatives (sa, ct, p, h_sa_sa, &
3  h_sa_ct, h_ct_ct)
4 ! =========================================================================
5 !
6 ! Calculates the following three second-order derivatives of specific
7 ! enthalpy (h),using the computationally-efficient expression for
8 ! specific volume in terms of SA, CT and p (Roquet et al., 2014).
9 ! (1) h_SA_SA, second-order derivative with respect to Absolute Salinity
10 ! at constant CT & p.
11 ! (2) h_SA_CT, second-order derivative with respect to SA & CT at
12 ! constant p.
13 ! (3) h_CT_CT, second-order derivative with respect to CT at constant SA
14 ! and p.
15 !
16 ! SA = Absolute Salinity [ g/kg ]
17 ! CT = Conservative Temperature (ITS-90) [ deg C ]
18 ! p = sea pressure [ dbar ]
19 ! ( i.e. absolute pressure - 10.1325 dbar )
20 !
21 ! h_SA_SA = The second derivative of specific enthalpy with respect to
22 ! Absolute Salinity at constant CT & p. [ J/(kg (g/kg)^2) ]
23 ! h_SA_CT = The second derivative of specific enthalpy with respect to
24 ! SA and CT at constant p. [ J/(kg K(g/kg)) ]
25 ! h_CT_CT = The second derivative of specific enthalpy with respect to
26 ! CT at constant SA and p. [ J/(kg K^2) ]
27 !--------------------------------------------------------------------------
28 
30 
32 
33 use gsw_mod_kinds
34 
35 implicit none
36 
37 real (r8), intent(in) :: sa, ct, p
38 real (r8), intent(out), optional :: h_sa_sa, h_sa_ct, h_ct_ct
39 
40 real (r8) :: dynamic_h_ct_ct_part, dynamic_h_sa_ct_part, dynamic_h_sa_sa_part
41 real (r8) :: xs, xs2, ys, z
42 
43 xs = sqrt(gsw_sfac*sa + offset)
44 ys = ct*0.025_r8
45 z = p*1e-4_r8
46 
47 if (present(h_sa_sa)) then
48 
49  xs2 = xs**2
50  dynamic_h_sa_sa_part = z*(-h101 + xs2*(3.0_r8*h301 + xs*(8.0_r8*h401 &
51  + xs*(15.0_r8*h501 + 24.0_r8*h601*xs))) + ys*(- h111 &
52  + xs2*(3.0_r8*h311 + xs*(8.0_r8*h411 + 15.0_r8*h511*xs)) + ys*(-h121 &
53  + xs2*(3.0_r8*h321 + 8.0_r8*h421*xs) + ys*(-h131 + 3.0_r8*h331*xs2 &
54  + ys*(-h141 - h151*ys)))) + z*(-h102 + xs2*(3.0_r8*h302 &
55  + xs*(8.0_r8*h402 + 15.0_r8*h502*xs)) + ys*(-h112 + xs2*(3.0_r8*h312 &
56  + 8.0_r8*h412*xs) + ys*(-h122 + 3.0_r8*h322*xs2 + ys*(-h132 &
57  - h142*ys ))) + z*(xs2*(8.0_r8*h403*xs + 3.0_r8*h313*ys) &
58  + z*(-h103 + 3.0_r8*h303*xs2 + ys*(-h113 + ys*(-h123 - h133*ys)) &
59  + z*(-h104 - h114*ys - h105*z)))))
60 
61  h_sa_sa = 1e8_r8*0.25_r8*gsw_sfac*gsw_sfac*dynamic_h_sa_sa_part/xs**3
62 
63 end if
64 
65 if (present(h_sa_ct)) then
66 
67  dynamic_h_sa_ct_part = z*(h111 + xs*(2.0_r8*h211 + xs*(3.0_r8*h311 &
68  + xs*(4.0_r8*h411 + 5.0_r8*h511*xs))) + ys*(2.0_r8*h121 &
69  + xs*(4.0_r8*h221 + xs*(6.0_r8*h321 + 8.0_r8*h421*xs)) &
70  + ys*(3.0_r8*h131 + xs*(6.0_r8*h231 + 9.0_r8*h331*xs) &
71  + ys*(4.0_r8*h141 + 8.0_r8*h241*xs + 5.0_r8*h151*ys ))) + z*(h112 &
72  + xs*(2.0_r8*h212 + xs*(3.0_r8*h312 + 4.0_r8*h412*xs)) &
73  + ys*(2.0_r8*h122 + xs*(4.0_r8*h222 + 6.0_r8*h322*xs) &
74  + ys*(3.0_r8*h132 + 6.0_r8*h232*xs + 4.0_r8*h142*ys)) + z*(h113 &
75  + xs*(2.0_r8*h213 + 3.0_r8*h313*xs) + ys*(2.0_r8*h123 &
76  + 4.0_r8*h223*xs + 3.0_r8*h133*ys) + h114*z)))
77 
78  h_sa_ct = 1e8_r8*0.025_r8*0.5_r8*gsw_sfac*dynamic_h_sa_ct_part/xs
79 
80 end if
81 
82 if (present(h_ct_ct)) then
83 
84  dynamic_h_ct_ct_part = z*(2.0_r8*h021 + xs*(2.0_r8*h121 + xs*(2.0_r8*h221 &
85  + xs*(2.0_r8*h321 + 2.0_r8*h421*xs))) + ys*(6.0_r8*h031 &
86  + xs*(6.0_r8*h131 + xs*(6.0_r8*h231 + 6.0_r8*h331*xs)) &
87  + ys*(12.0_r8*h041 + xs*(12.0_r8*h141 + 12.0_r8*h241*xs) &
88  + ys*(20.0_r8*h051 + 20.0_r8*h151*xs + 30.0_r8*h061*ys))) &
89  + z*(2.0_r8*h022 + xs*(2.0_r8*h122 + xs*(2.0_r8*h222 &
90  + 2.0_r8*h322*xs)) + ys*(6.0_r8*h032 + xs*(6.0_r8*h132 &
91  + 6.0_r8*h232*xs) + ys*(12.0_r8*h042 + 12.0_r8*h142*xs &
92  + 20.0_r8*h052*ys)) + z*(2.0_r8*h023 + xs*(2.0_r8*h123 &
93  + 2.0_r8*h223*xs) + ys*(6.0_r8*h133*xs + 6.0_r8*h033 &
94  + 12.0_r8*h043*ys) + 2.0_r8*h024*z)))
95 
96  h_ct_ct = 1e8_r8*6.25e-4_r8*dynamic_h_ct_ct_part
97 
98 end if
99 
100 return
101 end subroutine
102 
103 !--------------------------------------------------------------------------
elemental subroutine gsw_enthalpy_second_derivatives(sa, ct, p, h_sa_sa, h_sa_ct, h_ct_ct)