FV3 Bundle
gsw_pt0_from_t_ice.f90
Go to the documentation of this file.
1 ! =========================================================================
2 elemental function gsw_pt0_from_t_ice (t, p)
3 ! =========================================================================
4 !
5 ! Calculates potential temperature of ice Ih with a reference pressure of
6 ! 0 dbar, from in-situ temperature, t.
7 !
8 ! t = in-situ temperature (ITS-90) [ deg C ]
9 ! p = sea pressure [ dbar ]
10 ! ( i.e. absolute pressure - 10.1325 dbar )
11 !
12 ! pt0_ice = potential temperature of ice Ih with reference pressure of
13 ! zero dbar (ITS-90) [ deg C ]
14 !--------------------------------------------------------------------------
15 
17 
20 
21 use gsw_mod_kinds
22 
23 implicit none
24 
25 real (r8), intent(in) :: t, p
26 
27 real (r8) :: gsw_pt0_from_t_ice
28 
29 integer :: number_of_iterations
30 real (r8) :: dentropy, dentropy_dt, pt0_ice
31 real (r8) :: pt0_ice_old, ptm_ice, true_entropy
32 
33 ! This is the starting polynomial for pt0 of ice Ih.
34 real (r8), parameter :: s1 = -2.256611570832386e-4_r8
35 real (r8), parameter :: s2 = -6.045305921314694e-7_r8
36 real (r8), parameter :: s3 = 5.546699019612661e-9_r8
37 real (r8), parameter :: s4 = 1.795030639186685e-11_r8
38 real (r8), parameter :: s5 = 1.292346094030742e-9_r8
39 
40 real (r8), parameter :: p1 = -2.259745637898635e-4_r8
41 real (r8), parameter :: p2 = 1.486236778150360e-9_r8
42 real (r8), parameter :: p3 = 6.257869607978536e-12_r8
43 real (r8), parameter :: p4 = -5.253795281359302e-7_r8
44 real (r8), parameter :: p5 = 6.752596995671330e-9_r8
45 real (r8), parameter :: p6 = 2.082992190070936e-11_r8
46 
47 real (r8), parameter :: q1 = -5.849191185294459e-15_r8
48 real (r8), parameter :: q2 = 9.330347971181604e-11_r8
49 real (r8), parameter :: q3 = 3.415888886921213e-13_r8
50 real (r8), parameter :: q4 = 1.064901553161811e-12_r8
51 real (r8), parameter :: q5 = -1.454060359158787e-10_r8
52 real (r8), parameter :: q6 = -5.323461372791532e-13_r8
53 
54 true_entropy = -gsw_gibbs_ice_part_t(t,p)
55 
56 if (t.lt.-45.0_r8 .and. t.gt.-273.0_r8) then
57 
58  pt0_ice = t + p*(p1 + p*(p2 + p3*t) + t*(p4 + t*(p5 + p6*t)))
59 
60  if (pt0_ice.lt.-gsw_t0) pt0_ice = -gsw_t0
61 
62  ! we add 0.05d0 to the initial estimate of pt0_ice at
63  ! temps less than -273 to ensure that it is never less than -273.15.
64  if (pt0_ice.lt.-273.0_r8) pt0_ice = pt0_ice + 0.05_r8
65 
66  dentropy_dt = -gsw_gibbs_ice_pt0_pt0(pt0_ice)
67 
68  do number_of_iterations = 1, 3
69  pt0_ice_old = pt0_ice
70  dentropy = -gsw_gibbs_ice_pt0(pt0_ice_old) - true_entropy
71  pt0_ice = pt0_ice_old - dentropy/dentropy_dt
72  ptm_ice = 0.5_r8*(pt0_ice + pt0_ice_old)
73  dentropy_dt = -gsw_gibbs_ice_pt0_pt0(ptm_ice)
74  pt0_ice = pt0_ice_old - dentropy/dentropy_dt
75  end do
76 
77 else
78 
79  pt0_ice = t + p*(s1 + t*(s2 + t*(s3 + t*s4)) + s5*p)
80  dentropy_dt = -gsw_gibbs_ice_pt0_pt0(pt0_ice)
81 
82  pt0_ice_old = pt0_ice
83  dentropy = -gsw_gibbs_ice_pt0(pt0_ice_old) - true_entropy
84 
85  pt0_ice = pt0_ice_old - dentropy/dentropy_dt
86  ptm_ice = 0.5_r8*(pt0_ice + pt0_ice_old)
87  dentropy_dt = -gsw_gibbs_ice_pt0_pt0(ptm_ice)
88  pt0_ice = pt0_ice_old - dentropy/dentropy_dt
89 
90 end if
91 
92 if (pt0_ice.lt.-273.0_r8) then
93 
94  pt0_ice = t + p*(q1 + p*(q2 + q3*t) + t*(q4 + t*(q5 + q6*t)))
95 
96  ! add 0.01d0 to the initial estimate of pt_ice used in the derivative to
97  ! ensure that it is never less than -273.15d0 because the derivative
98  ! approaches zero at absolute zero.
99  dentropy_dt = -gsw_gibbs_ice_pt0_pt0(pt0_ice+0.01_r8)
100 
101  do number_of_iterations = 1, 3
102  pt0_ice_old = pt0_ice
103  dentropy = -gsw_gibbs_ice_pt0(pt0_ice_old) - true_entropy
104  pt0_ice = pt0_ice_old - dentropy/dentropy_dt
105  ptm_ice = 0.5_r8*(pt0_ice + pt0_ice_old)
106  ! add 0.01d0 to the estimate of ptm_ice for temperatures less than
107  ! -273 to ensure that they are never less than -273.15d0 because
108  ! the derivative approaches zero at absolute zero and the addition
109  ! of 0.01d0 degrees c ensures that when we divide by the derivatve
110  ! in the modified newton routine the function does not blow up.
111  ptm_ice = ptm_ice + 0.01_r8
112  dentropy_dt = -gsw_gibbs_ice_pt0_pt0(ptm_ice)
113  pt0_ice = pt0_ice_old - dentropy/dentropy_dt
114  end do
115 
116 end if
117 
118 ! For temperatures less than -273.1 degsC the maximum error is less than
119 ! 2x10^-7 degsC. For temperatures between -273.1 and 273 the maximum error
120 ! is less than 8x10^-8 degsC, and for temperatures greater than -273 degsC the
121 ! maximum error is 1.5x10^-12 degsC. These errors are over the whole
122 ! ocean depths with p varying between 0 and 10,000 dbar, while the in-situ
123 ! temperature varied independently between -273.15 and +2 degsC.
124 
125 gsw_pt0_from_t_ice = pt0_ice
126 
127 return
128 end function
129 
130 !--------------------------------------------------------------------------
elemental real(r8) function gsw_pt0_from_t_ice(t, p)