FV3 Bundle
gsw_ct_from_enthalpy.f90
Go to the documentation of this file.
1
!==========================================================================
2
elemental function
gsw_ct_from_enthalpy
(sa, h, p)
3
!==========================================================================
4
!
5
! Calculates the Conservative Temperature of seawater, given the Absolute
6
! Salinity, specific enthalpy, h, and pressure p.
7
!
8
! SA = Absolute Salinity [ g/kg ]
9
! h = specific enthalpy [ J/kg ]
10
! p = sea pressure [ dbar ]
11
! ( i.e. absolute pressure - 10.1325d0 dbar )
12
!
13
! CT = Conservative Temperature ( ITS-90) [ deg C ]
14
!--------------------------------------------------------------------------
15
16
use
gsw_mod_toolbox
,
only
:
gsw_ct_freezing_exact
,
gsw_enthalpy
17
use
gsw_mod_toolbox
,
only
:
gsw_enthalpy_first_derivatives
18
19
use
gsw_mod_error_functions
,
only
:
gsw_error_code
20
21
use
gsw_mod_teos10_constants
,
only
:
gsw_cp0
22
23
use
gsw_mod_kinds
24
25
implicit none
26
27
real (r8)
,
intent(in)
:: sa, h, p
28
29
real (r8)
::
gsw_ct_from_enthalpy
30
31
real (r8)
:: ct, ct_freezing, ct_mean, ct_old, f, h_freezing
32
real (r8)
:: h_ct, h_40
33
34
real (r8)
,
parameter
:: ct_40 = 40.0_r8
35
36
character (*)
,
parameter
:: func_name =
"gsw_ct_from_enthalpy"
37
38
ct_freezing =
gsw_ct_freezing_exact
(sa,p,0.0_r8)
39
40
h_freezing =
gsw_enthalpy
(sa,ct_freezing,p)
41
if
(h .lt. h_freezing -
gsw_cp0
)
then
42
! The input, seawater enthalpy h, is less than the enthalpy at the
43
! freezing temperature, i.e. the water is frozen.
44
gsw_ct_from_enthalpy
=
gsw_error_code
(1,func_name)
45
return
46
endif
47
48
h_40 =
gsw_enthalpy
(sa,ct_40,p)
49
if
(h .gt. h_40)
then
50
! The input seawater enthalpy is greater than the enthalpy when CT is 40C
51
gsw_ct_from_enthalpy
=
gsw_error_code
(2,func_name)
52
return
53
endif
54
55
! first guess of ct
56
ct = ct_freezing + (ct_40 - ct_freezing)*(h - h_freezing)/(h_40 - h_freezing)
57
call
gsw_enthalpy_first_derivatives
(sa,ct,p,h_ct=h_ct)
58
59
!--------------------------------------------------------------------------
60
! Begin the modified Newton-Raphson iterative procedure
61
!--------------------------------------------------------------------------
62
63
ct_old = ct
64
f =
gsw_enthalpy
(sa,ct_old,p) - h
65
ct = ct_old - f/h_ct
66
ct_mean = 0.5_r8*(ct + ct_old)
67
call
gsw_enthalpy_first_derivatives
(sa,ct_mean,p,h_ct=h_ct)
68
ct = ct_old - f/h_ct
69
70
ct_old = ct
71
f =
gsw_enthalpy
(sa,ct_old,p) - h
72
ct = ct_old - f/h_ct
73
74
! After 1.5d0 iterations of this modified Newton-Raphson iteration,
75
! the error in CT is no larger than 4x10^-13 degrees C, which
76
! is machine precision for this calculation.
77
78
gsw_ct_from_enthalpy
= ct
79
80
return
81
end function
82
83
!--------------------------------------------------------------------------
gsw_mod_toolbox
Definition:
gsw_mod_toolbox.f90:1
gsw_ct_from_enthalpy
elemental real(r8) function gsw_ct_from_enthalpy(sa, h, p)
Definition:
gsw_ct_from_enthalpy.f90:3
gsw_mod_toolbox::gsw_ct_from_enthalpy
Definition:
gsw_mod_toolbox.f90:354
gsw_mod_teos10_constants
Definition:
gsw_mod_teos10_constants.f90:2
gsw_mod_error_functions
Definition:
gsw_mod_error_functions.f90:2
gsw_mod_toolbox::gsw_ct_freezing_exact
Definition:
gsw_mod_toolbox.f90:324
gsw_mod_toolbox::gsw_enthalpy
Definition:
gsw_mod_toolbox.f90:440
gsw_mod_toolbox::gsw_enthalpy_first_derivatives
Definition:
gsw_mod_toolbox.f90:461
gsw_mod_kinds
Definition:
gsw_mod_kinds.f90:2
gsw_mod_teos10_constants::gsw_cp0
real(r8), parameter gsw_cp0
Definition:
gsw_mod_teos10_constants.f90:24
gsw_mod_error_functions::gsw_error_code
elemental real(r8) function, public gsw_error_code(err_num, func_name, error_code)
Definition:
gsw_mod_error_functions.f90:81
src
fv3-bundle
gsw
toolbox
gsw_ct_from_enthalpy.f90
Generated on Tue Nov 6 2018 11:38:36 for FV3 Bundle by
1.8.14