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