FV3 Bundle
gsw_pressure_freezing_ct.f90
Go to the documentation of this file.
1 !==========================================================================
2 elemental function gsw_pressure_freezing_ct (sa, ct, saturation_fraction)
3 !==========================================================================
4 !
5 ! Calculates the pressure (in dbar) of seawater at the freezing
6 ! temperature. That is, the output is the pressure at which seawater,
7 ! with Absolute Salinity SA, Conservative Temperature CT, and with
8 ! saturation_fraction of dissolved air, freezes. If the input values are
9 ! such that there is no value of pressure in the range between 0 dbar and
10 ! 10,000 dbar for which seawater is at the freezing temperature, the
11 ! output, pressure_freezing, is put equal to NaN.
12 !
13 ! SA = Absolute Salinity of seawater [ g/kg ]
14 ! CT = Conservative Temperature (ITS-90) [ deg C ]
15 ! saturation_fraction = the saturation fraction of dissolved air in
16 ! seawater
17 !
18 ! pressure_freezing = sea pressure at which the seawater freezes [ dbar ]
19 ! ( i.e. absolute pressure - 10.1325 dbar )
20 !--------------------------------------------------------------------------
21 
24 
26 
28 
29 use gsw_mod_kinds
30 
31 implicit none
32 
33 real (r8), intent(in) :: sa, ct, saturation_fraction
34 
35 real (r8) :: gsw_pressure_freezing_ct
36 
37 integer :: i_iter
38 real (r8) :: ct_freezing_p0, ct_freezing_p10000, dctf_dp, f
39 real (r8) :: pf, pfm, pf_old, ctfreezing_p
40 
41 integer, parameter :: number_of_iterations = 3
42 
43 ! rec_Pa2dbar is to have dCTf_dp in units of K/dbar rather than K/Pa
44 
45 character (*), parameter :: func_name = "gsw_pressure_freezing_ct"
46 
47 ! Find CT > CT_freezing_p0. If this is the case, the input CT value
48 ! represent seawater that will not be frozen at any positive p.
49 ct_freezing_p0 = gsw_ct_freezing_exact(sa,0.0_r8,saturation_fraction)
50 if (ct .gt. ct_freezing_p0) then
52  return
53 end if
54 
55 ! Find CT < CT_freezing_p10000. If this is the case, the input CT value
56 ! represent seawater that is frozen even at p = 10,000 dbar.
57 ct_freezing_p10000 = gsw_ct_freezing_exact(sa,1e4_r8,saturation_fraction)
58 if (ct .lt. ct_freezing_p10000) then
60  return
61 end if
62 
63 ! This is the initial (linear) guess of the freezing pressure, in dbar.
64 pf = rec_pa2db*(ct_freezing_p0 - ct)/(ct_freezing_p0 - ct_freezing_p10000)
65 
66 call gsw_ct_freezing_first_derivatives(sa,pf,saturation_fraction, &
67  ctfreezing_p=ctfreezing_p)
68 dctf_dp = rec_pa2db*ctfreezing_p
69  ! this dctf_dp is the initial value of the partial derivative of
70  ! ct_freezing with respect to pressure (in dbar) at fixed sa,
71  ! assuming that the saturation_fraction is zero.
72 
73 do i_iter = 1, number_of_iterations
74  pf_old = pf
75  f = gsw_ct_freezing_exact(sa,pf_old,saturation_fraction) - ct
76  pf = pf_old - f/dctf_dp
77  pfm = 0.5_r8*(pf + pf_old)
78  call gsw_ct_freezing_first_derivatives(sa,pfm,saturation_fraction, &
79  ctfreezing_p=ctfreezing_p)
80  dctf_dp = rec_pa2db*ctfreezing_p
81  pf = pf_old - f/dctf_dp
82 end do
83 
84 if (gsw_sa_p_inrange(sa,pf)) then
86 else
88 end if
89 
90 return
91 end function
92 
93 !--------------------------------------------------------------------------
elemental real(r8) function gsw_pressure_freezing_ct(sa, ct, saturation_fraction)
real(r8), parameter, public gsw_error_limit
elemental real(r8) function, public gsw_error_code(err_num, func_name, error_code)