FV3 Bundle
gsw_rho_second_derivatives_wrt_enthalpy.f90
Go to the documentation of this file.
1 !==========================================================================
2 elemental subroutine gsw_rho_second_derivatives_wrt_enthalpy (sa, ct, p, &
3  rho_sa_sa, rho_sa_h, rho_h_h)
4 ! =========================================================================
5 !
6 ! Calculates three second-order derivatives of rho with respect to enthalpy.
7 ! Note that this function uses the using 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 ! rho_SA_SA = The second-order derivative of rho with respect to
16 ! Absolute Salinity at constant h & p. [ J/(kg (g/kg)^2) ]
17 ! rho_SA_h = The second-order derivative of rho with respect to
18 ! SA and h at constant p. [ J/(kg K(g/kg)) ]
19 ! rho_h_h = The second-order derivative of rho with respect to h at
20 ! constant SA & p
21 !--------------------------------------------------------------------------
22 
23 use gsw_mod_toolbox, only : gsw_specvol
26 
27 use gsw_mod_kinds
28 
29 implicit none
30 
31 real (r8), intent(in) :: sa, ct, p
32 real (r8), intent(out), optional :: rho_sa_sa, rho_sa_h, rho_h_h
33 
34 integer :: iflag1, iflag2
35 real (r8) :: rec_v, rec_v2, rec_v3, v_h, v_h_h, v_sa, v_sa_h, v_sa_sa
36 
37 iflag1 = 0
38 if (present(rho_sa_sa) .or. present(rho_sa_h)) iflag1 = ibset(iflag1,1)
39 if (present(rho_sa_h) .or. present(rho_h_h)) iflag1 = ibset(iflag1,2)
40 
41 call gsw_specvol_first_derivatives_wrt_enthalpy(sa,ct,p,v_sa,v_h,iflag=iflag1)
42 
43 iflag2 = 0
44 if (present(rho_sa_sa)) iflag2 = ibset(iflag2,1)
45 if (present(rho_sa_h)) iflag2 = ibset(iflag2,2)
46 if (present(rho_h_h)) iflag2 = ibset(iflag2,3)
47 
48 call gsw_specvol_second_derivatives_wrt_enthalpy(sa,ct,p,v_sa_sa,v_sa_h,v_h_h, &
49  iflag=iflag2)
50 
51 rec_v = 1.0_r8/gsw_specvol(sa,ct,p)
52 rec_v2 = rec_v**2
53 rec_v3 = rec_v2*rec_v
54 
55 if (present(rho_sa_sa)) rho_sa_sa = -v_sa_sa*rec_v2 + 2.0_r8*v_sa*v_sa*rec_v3
56 
57 if (present(rho_sa_h)) rho_sa_h = -v_sa_h*rec_v2 + 2.0_r8*v_sa*v_h*rec_v3
58 
59 if (present(rho_h_h)) rho_h_h = -v_h_h*rec_v2 + 2.0_r8*v_h*v_h*rec_v3
60 
61 return
62 end subroutine
63 
64 !--------------------------------------------------------------------------
elemental subroutine gsw_rho_second_derivatives_wrt_enthalpy(sa, ct, p, rho_sa_sa, rho_sa_h, rho_h_h)