FV3 Bundle
gsw_pt_from_t.f90
Go to the documentation of this file.
1 !==========================================================================
2 elemental function gsw_pt_from_t (sa, t, p, p_ref)
3 !==========================================================================
4 !
5 ! Calculates potential temperature of seawater from in-situ temperature
6 !
7 ! sa : Absolute Salinity [g/kg]
8 ! t : in-situ temperature [deg C]
9 ! p : sea pressure [dbar]
10 ! p_ref : reference sea pressure [dbar]
11 !
12 ! gsw_pt_from_t : potential temperature [deg C]
13 !--------------------------------------------------------------------------
14 
16 
18 
19 use gsw_mod_kinds
20 
21 implicit none
22 
23 real (r8), intent(in) :: sa, t, p, p_ref
24 
25 real (r8) :: gsw_pt_from_t
26 
27 integer no_iter
28 real (r8) :: s1, pt, pt_old, dentropy, dentropy_dt
29 real (r8) :: true_entropy_part, ptm
30 
31 integer, parameter :: n0=0, n2=2
32 
33 s1 = sa/gsw_ups
34 
35 pt = t + (p-p_ref)*( 8.65483913395442e-6_r8 - &
36  s1 * 1.41636299744881e-6_r8 - &
37  (p+p_ref)* 7.38286467135737e-9_r8 + &
38  t *(-8.38241357039698e-6_r8 + &
39  s1 * 2.83933368585534e-8_r8 + &
40  t * 1.77803965218656e-8_r8 + &
41  (p+p_ref)* 1.71155619208233e-10_r8))
42 
43 dentropy_dt = gsw_cp0/((gsw_t0 + pt)*(1.0_r8 - 0.05_r8*(1.0_r8 - sa/gsw_sso)))
44 
45 true_entropy_part = gsw_entropy_part(sa,t,p)
46 
47 do no_iter = 1, 2
48  pt_old = pt
49  dentropy = gsw_entropy_part(sa,pt_old,p_ref) - true_entropy_part
50  pt = pt_old - dentropy/dentropy_dt
51  ptm = 0.5_r8*(pt + pt_old)
52  dentropy_dt = -gsw_gibbs(n0,n2,n0,sa,ptm,p_ref)
53  pt = pt_old - dentropy/dentropy_dt
54 end do
55 
56 gsw_pt_from_t = pt
57 
58 return
59 end function
60 
61 !--------------------------------------------------------------------------
elemental real(r8) function gsw_pt_from_t(sa, t, p, p_ref)