FV3 Bundle
gsw_pt_from_t_ice.f90
Go to the documentation of this file.
1 ! =========================================================================
2 elemental function gsw_pt_from_t_ice (t, p, p_ref)
3 ! =========================================================================
4 !
5 ! Calculates potential temperature of ice Ih with the general reference
6 ! pressure, p_ref, from in-situ temperature, t.
7 !
8 ! A faster gsw routine exists if p_ref is indeed zero dbar. This routine
9 ! is "gsw_pt0_from_t_ice(t,p)".
10 !
11 ! t = in-situ temperature (ITS-90) [ deg C ]
12 ! p = sea pressure [ dbar ]
13 ! ( i.e. absolute pressure - 10.1325 dbar )
14 ! p_ref = reference pressure [ dbar ]
15 !--------------------------------------------------------------------------
16 
18 
20 
21 use gsw_mod_kinds
22 
23 implicit none
24 
25 real (r8), intent(in) :: t, p, p_ref
26 
27 real (r8) :: gsw_pt_from_t_ice
28 
29 integer :: number_of_iterations
30 real (r8) :: dentropy, dentropy_dt, dp
31 real (r8) :: pt_ice, pt_ice_old, ptm_ice, true_entropy
32 
33 real (r8), parameter :: p1 = -2.259745637898635e-4_r8
34 real (r8), parameter :: p2 = 1.486236778150360e-9_r8
35 real (r8), parameter :: p3 = 6.257869607978536e-12_r8
36 real (r8), parameter :: p4 = -5.253795281359302e-7_r8
37 real (r8), parameter :: p5 = 6.752596995671330e-9_r8
38 real (r8), parameter :: p6 = 2.082992190070936e-11_r8
39 
40 real (r8), parameter :: q1 = -5.849191185294459e-15_r8
41 real (r8), parameter :: q2 = 9.330347971181604e-11_r8
42 real (r8), parameter :: q3 = 3.415888886921213e-13_r8
43 real (r8), parameter :: q4 = 1.064901553161811e-12_r8
44 real (r8), parameter :: q5 = -1.454060359158787e-10_r8
45 real (r8), parameter :: q6 = -5.323461372791532e-13_r8
46 
47 ! This is the starting polynomial for pt of ice Ih.
48 dp = p - p_ref
49 
50 pt_ice = t + dp*(p1 + (p + p_ref)*(p2 + p3*t) + t*(p4 + t*(p5 + p6*t)))
51 
52 if (pt_ice.lt.-gsw_t0) pt_ice = -gsw_t0
53 
54 if (pt_ice.lt.-273.0_r8) pt_ice = pt_ice + 0.05_r8
55 ! we add 0.05 to the initial estimate of pt_ice at temps less than -273 to
56 ! ensure that it is never less than -273.15.
57 
58 dentropy_dt = -gsw_gibbs_ice(2,0,pt_ice,p_ref)
59 
60 true_entropy = -gsw_gibbs_ice_part_t(t,p)
61 
62 do number_of_iterations = 1, 3
63  pt_ice_old = pt_ice
64  dentropy = -gsw_gibbs_ice_part_t(pt_ice_old,p_ref) - true_entropy
65  pt_ice = pt_ice_old - dentropy/dentropy_dt
66  ptm_ice = 0.5_r8*(pt_ice + pt_ice_old)
67  dentropy_dt = -gsw_gibbs_ice(2,0,ptm_ice,p_ref)
68  pt_ice = pt_ice_old - dentropy/dentropy_dt
69 end do
70 
71 if (pt_ice.lt.-273.0_r8) then
72 
73  pt_ice = t + (p - p_ref)*(q1 + (p + p_ref)*(q2 + q3*t) &
74  + t*(q4 + t*(q5 + q6*t)))
75 
76  dentropy_dt = -gsw_gibbs_ice(2,0,pt_ice+0.01_r8,p_ref)
77  ! we add 0.01 to the initial estimate of pt_ice used in the derivative to
78  ! ensure that it is never less than -273.15 because the derivative
79  ! approaches zero at absolute zero.
80 
81  do number_of_iterations = 1, 3
82  pt_ice_old = pt_ice
83  dentropy = -gsw_gibbs_ice_part_t(pt_ice_old,p_ref) - true_entropy
84  pt_ice = pt_ice_old - dentropy/dentropy_dt
85  ptm_ice = 0.5_r8*(pt_ice + pt_ice_old)
86  ptm_ice = ptm_ice + 0.01_r8
87  dentropy_dt = -gsw_gibbs_ice(2,0,ptm_ice,p_ref)
88  pt_ice = pt_ice_old - dentropy/dentropy_dt
89  end do
90 
91 end if
92 
93 ! For temperatures less than -273.1 degsC the maximum error is less than
94 ! 2x10^-7 degsC. For temperatures between -273.1 and 273 the maximum error
95 ! is less than 8x10^-8 degsC, and for temperatures greater than -273 degsC the
96 ! maximum error is 1.5x10^-12 degsC. These errors are over the whole
97 ! ocean depths with both p and pref varying independently between 0 and
98 ! 10,000 dbar, while the in-situ temperature varied independently between
99 ! -273.15 and +2 degsC.
100 
101 gsw_pt_from_t_ice = pt_ice
102 
103 return
104 end function
105 
106 !--------------------------------------------------------------------------
elemental real(r8) function gsw_pt_from_t_ice(t, p, p_ref)