FV3 Bundle
gsw_specvol_first_derivatives_wrt_enthalpy.f90
Go to the documentation of this file.
1 !==========================================================================
2 elemental subroutine gsw_specvol_first_derivatives_wrt_enthalpy (sa, ct, &
3  p, v_sa, v_h, iflag)
4 ! =========================================================================
5 !
6 ! Calculates two first-order derivatives of specific volume (v).
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 ! 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_h = The first derivative of specific volume with respect to
18 ! SA and CT at constant p. [ J/(kg K(g/kg)) ]
19 !--------------------------------------------------------------------------
20 
23 
24 use gsw_mod_kinds
25 
26 implicit none
27 
28 real (r8), intent(in) :: sa, ct, p
29 integer, intent(in), optional :: iflag
30 real (r8), intent(out), optional :: v_sa, v_h
31 
32 integer :: i
33 logical :: flags(2)
34 real (r8) :: h_ct, h_sa, rec_h_ct, vct_ct, vct_sa
35 
36 if (present(iflag)) then
37  do i = 1, 2
38  flags(i) = btest(iflag,i)
39  end do
40 else
41  flags = .true.
42 end if
43 
44 if (present(v_sa) .and. flags(1)) then
45 
46  call gsw_specvol_first_derivatives(sa,ct,p,vct_sa,vct_ct)
47  call gsw_enthalpy_first_derivatives(sa,ct,p,h_sa,h_ct)
48 
49 else if (present(v_h) .and. flags(2)) then
50 
51  call gsw_specvol_first_derivatives(sa,ct,p,v_ct=vct_ct)
52  call gsw_enthalpy_first_derivatives(sa,ct,p,h_ct=h_ct)
53 
54 end if
55 
56 rec_h_ct = 1.0_r8/h_ct
57 
58 if (present(v_sa) .and. flags(1)) v_sa = vct_sa - (vct_ct*h_sa)*rec_h_ct
59 
60 if (present(v_h) .and. flags(2)) v_h = vct_ct*rec_h_ct
61 
62 return
63 end subroutine
64 
65 !--------------------------------------------------------------------------
elemental subroutine gsw_specvol_first_derivatives_wrt_enthalpy(sa, ct, p, v_sa, v_h, iflag)