FV3 Bundle
gsw_pt_from_ct.f90
Go to the documentation of this file.
1 !==========================================================================
2 elemental function gsw_pt_from_ct (sa, ct)
3 !==========================================================================
4 !
5 ! potential temperature of seawater from conservative temperature
6 !
7 ! sa : Absolute Salinity [g/kg]
8 ! ct : Conservative Temperature [deg C]
9 ! p : sea pressure [dbar]
10 !
11 ! gsw_pt_from_ct : potential temperature with [deg C]
12 ! reference pressure of 0 dbar
13 !--------------------------------------------------------------------------
14 
16 
18 
19 use gsw_mod_kinds
20 
21 implicit none
22 
23 real (r8), intent(in) :: sa, ct
24 
25 real (r8) :: gsw_pt_from_ct
26 
27 real (r8) :: a5ct, b3ct, ct_factor, pt_num, pt_recden, ct_diff
28 real (r8) :: pt, pt_old, ptm, dpt_dct, s1
29 
30 real (r8), parameter :: a0 = -1.446013646344788e-2_r8
31 real (r8), parameter :: a1 = -3.305308995852924e-3_r8
32 real (r8), parameter :: a2 = 1.062415929128982e-4_r8
33 real (r8), parameter :: a3 = 9.477566673794488e-1_r8
34 real (r8), parameter :: a4 = 2.166591947736613e-3_r8
35 real (r8), parameter :: a5 = 3.828842955039902e-3_r8
36 
37 real (r8), parameter :: b0 = 1.0_r8
38 real (r8), parameter :: b1 = 6.506097115635800e-4_r8
39 real (r8), parameter :: b2 = 3.830289486850898e-3_r8
40 real (r8), parameter :: b3 = 1.247811760368034e-6_r8
41 
42 s1 = sa/gsw_ups
43 
44 a5ct = a5*ct
45 b3ct = b3*ct
46 
47 ct_factor = (a3 + a4*s1 + a5ct)
48 pt_num = a0 + s1*(a1 + a2*s1) + ct*ct_factor
49 pt_recden = 1.0_r8/(b0 + b1*s1 + ct*(b2 + b3ct))
50 pt = pt_num*pt_recden
51 
52 dpt_dct = (ct_factor + a5ct - (b2 + b3ct + b3ct)*pt)*pt_recden
53 
54 ! Start the 1.5 iterations through the modified Newton-Rapshon iterative,
55 ! method, which is also known as the Newton-McDougall method.
56 
57 ct_diff = gsw_ct_from_pt(sa,pt) - ct
58 pt_old = pt
59 pt = pt_old - ct_diff*dpt_dct
60 ptm = 0.5_r8*(pt + pt_old)
61 
62 dpt_dct = -gsw_cp0/((ptm + gsw_t0)*gsw_gibbs_pt0_pt0(sa,ptm))
63 
64 pt = pt_old - ct_diff*dpt_dct
65 ct_diff = gsw_ct_from_pt(sa,pt) - ct
66 pt_old = pt
67 gsw_pt_from_ct = pt_old - ct_diff*dpt_dct
68 
69 return
70 end function
71 
72 !--------------------------------------------------------------------------
elemental real(r8) function gsw_pt_from_ct(sa, ct)