FV3 Bundle
gsw_pt_from_pot_enthalpy_ice.f90
Go to the documentation of this file.
1 !==========================================================================
2 elemental function gsw_pt_from_pot_enthalpy_ice (pot_enthalpy_ice)
3 !==========================================================================
4 !
5 ! Calculates the potential temperature of ice from the potential enthalpy
6 ! of ice. The reference sea pressure of both the potential temperature
7 ! and the potential enthalpy is zero dbar.
8 !
9 ! pot_enthalpy_ice = potential enthalpy of ice [ J/kg ]
10 !
11 ! pt0_ice = potential temperature of ice (ITS-90) [ deg C ]
12 !--------------------------------------------------------------------------
13 
18 
19 use gsw_mod_kinds
20 
21 implicit none
22 
23 real (r8), intent(in) :: pot_enthalpy_ice
24 
26 
27 integer :: iteration
28 real (r8) :: df_dt, f, mod_pot_enthalpy_ice, pt0_cold_ice, recip_df_dt
29 real (r8) :: pt0_cold_ice_old, pt0_ice, pt0_ice_old, ptm_cold_ice, ptm_ice
30 
31 real (r8), parameter :: h00 = -6.320202333358860e5_r8 !gsw_enthalpy_ice(-gsw_t0,0)
32 real (r8), parameter :: p0 = 0.0_r8
33 
34 mod_pot_enthalpy_ice = max(pot_enthalpy_ice,h00)
35 
36 if (mod_pot_enthalpy_ice.ge.-5.1e5_r8) then
37 
38  ! For input potential enthalpies greater than -5.1e-5, the above part of
39  ! the code gives the output potential temperature of ice accurate to 1e-13
40  ! degrees C.
41 
42  pt0_ice = gsw_pt_from_pot_enthalpy_ice_poly(mod_pot_enthalpy_ice)
43 
44  ! The variable "df_dt" below is the derivative of the above polynomial with
45  ! respect to pot_enthalpy_ice. This is the initial value of the derivative
46  ! of the function f.
47  recip_df_dt = gsw_pt_from_pot_enthalpy_ice_poly_dh(mod_pot_enthalpy_ice)
48 
49  pt0_ice_old = pt0_ice
50  f = gsw_pot_enthalpy_from_pt_ice(pt0_ice_old) - mod_pot_enthalpy_ice
51  pt0_ice = pt0_ice_old - f*recip_df_dt
52  ptm_ice = 0.5_r8*(pt0_ice + pt0_ice_old)
53  recip_df_dt = 1.0_r8/gsw_cp_ice(ptm_ice,p0)
54  pt0_ice = pt0_ice_old - f*recip_df_dt
55 
56 else
57 
58  ! For pot_enthalpy_ice < -5.1e5 (or pt0_ice less than about -100 deg c)
59  ! these temperatures are less than those found in nature on planet earth.
60 
61  pt0_cold_ice = gsw_pt0_cold_ice_poly(mod_pot_enthalpy_ice)
62 
63  df_dt = gsw_cp_ice(pt0_cold_ice+0.02_r8,p0)
64  ! the heat capacity, cp, is
65  ! evaluated at 0.02 c greater than usual in order to avoid stability
66  ! issues and to ensure convergence near zero absolute temperature.
67 
68  do iteration = 1, 6
69  pt0_cold_ice_old = pt0_cold_ice
70  f = gsw_pot_enthalpy_from_pt_ice(pt0_cold_ice_old)-mod_pot_enthalpy_ice
71  pt0_cold_ice = pt0_cold_ice_old - f/df_dt
72  ptm_cold_ice = 0.5_r8*(pt0_cold_ice + pt0_cold_ice_old)
73  df_dt = gsw_cp_ice(ptm_cold_ice+0.02_r8,p0)
74  ! note the extra 0.02 c here as well
75  pt0_cold_ice = pt0_cold_ice_old - f/df_dt
76  end do
77  pt0_ice = pt0_cold_ice
78 
79 end if
80 
81 !The potential temerature has a maximum error as listed in the table below.
82 !
83 ! potential temerature error (deg C) | @ potential temerature (deg C)
84 !--------------------------------------|--------------------------------
85 ! 0.012 | -273.15 to -273.12
86 ! 4 x 10^-4 | -232.12 to -273.0
87 ! 2.5 x 10^-6 | -273
88 ! 7 x 10^-9 | -272
89 ! 3.7 x 10^-10 | -270
90 ! 6 x 10^-11 | -268
91 ! 2.5 x 10^11 | -266
92 ! 3 x 10^-12 | -260
93 ! 7 x 10^-13 | -250
94 ! 2.2 x 10^-13 | -220
95 ! 1.7 x 10^-13 | >= -160
96 !
97 ! Note. The above errors in each temperature range are machine precissions
98 ! for this calculation.
99 
101 
102 return
103 end function
104 
105 !--------------------------------------------------------------------------
elemental real(r8) function gsw_pt_from_pot_enthalpy_ice(pot_enthalpy_ice)
#define max(a, b)
Definition: mosaic_util.h:33