FV3 Bundle
gsw_melting_ice_into_seawater.f90
Go to the documentation of this file.
1 !==========================================================================
2 elemental subroutine gsw_melting_ice_into_seawater (sa, ct, p, w_ih, t_ih,&
3  sa_final, ct_final, w_ih_final)
4 !==========================================================================
5 !
6 ! Calculates the final Absolute Salinity, final Conservative Temperature
7 ! and final ice mass fraction that results when a given mass fraction of
8 ! ice melts and is mixed into seawater whose properties are (SA,CT,p).
9 ! This code takes the seawater to contain no dissolved air.
10 !
11 ! When the mass fraction w_Ih_final is calculated as being a positive
12 ! value, the seawater-ice mixture is at thermodynamic equlibrium.
13 !
14 ! This code returns w_Ih_final = 0 when the input bulk enthalpy, h_bulk,
15 ! is sufficiently large (i.e. sufficiently "warm") so that there is no ice
16 ! present in the final state. In this case the final state consists of
17 ! only seawater rather than being an equlibrium mixture of seawater and
18 ! ice which occurs when w_Ih_final is positive. Note that when
19 ! w_Ih_final = 0, the final seawater is not at the freezing temperature.
20 !
21 ! SA = Absolute Salinity of seawater [ g/kg ]
22 ! CT = Conservative Temperature of seawater (ITS-90) [ deg C ]
23 ! p = sea pressure at which the melting occurs [ dbar ]
24 ! ( i.e. absolute pressure - 10.1325 dbar )
25 ! w_Ih = mass fraction of ice, that is the mass of ice divided by the
26 ! sum of the masses of ice and seawater. That is, the mass of
27 ! ice divided by the mass of the final mixed fluid.
28 ! w_Ih must be between 0 and 1. [ unitless ]
29 ! t_Ih = the in-situ temperature of the ice (ITS-90) [ deg C ]
30 !
31 ! SA_final = Absolute Salinity of the seawater in the final state,
32 ! whether or not any ice is present. [ g/kg ]
33 ! CT_final = Conservative Temperature of the seawater in the the final
34 ! state, whether or not any ice is present. [ deg C ]
35 ! w_Ih_final = mass fraction of ice in the final seawater-ice mixture.
36 ! If this ice mass fraction is positive, the system is at
37 ! thermodynamic equilibrium. If this ice mass fraction is
38 ! zero there is no ice in the final state which consists
39 ! only of seawater which is warmer than the freezing
40 ! temperature. [unitless]
41 !--------------------------------------------------------------------------
42 
46 
48 
49 use gsw_mod_kinds
50 
51 implicit none
52 
53 real (r8), intent(in) :: sa, ct, p, w_ih, t_ih
54 real (r8), intent(out) :: sa_final, ct_final, w_ih_final
55 
56 real (r8) :: ctf, h_bulk, sa_bulk, tf_ih
57 
58 real (r8), parameter :: saturation_fraction = 0.0_r8
59 
60 character (*), parameter :: func_name = "gsw_melting_ice_into_seawater"
61 
62 ctf = gsw_ct_freezing_exact(sa,p,saturation_fraction)
63 if (ct .lt. ctf) then
64  ! The seawater ct input is below the freezing temp
65  sa_final = gsw_error_code(1,func_name)
66  ct_final = sa_final
67  w_ih_final = sa_final
68  return
69 end if
70 
71 tf_ih = gsw_t_freezing_exact(0.0_r8,p,saturation_fraction) - 1e-6_r8
72 if (t_ih .gt. tf_ih) then
73  ! t_ih input exceeds the freezing temp. The 1e-6 C buffer in the allowable
74  ! t_Ih is to ensure that there is some ice Ih in the sea ice.
75  sa_final = gsw_error_code(2,func_name)
76  ct_final = sa_final
77  w_ih_final = sa_final
78  return
79 end if
80 
81 sa_bulk = (1.0_r8 - w_ih)*sa
82 h_bulk = (1.0_r8 - w_ih)*gsw_enthalpy_ct_exact(sa,ct,p) &
83  + w_ih*gsw_enthalpy_ice(t_ih,p)
84 call gsw_frazil_properties(sa_bulk,h_bulk,p,sa_final,ct_final,w_ih_final)
85 if (sa_final .gt. gsw_error_limit) then
86  sa_final = gsw_error_code(3,func_name,sa_final)
87  ct_final = sa_final
88  w_ih_final = sa_final
89  return
90 endif
91 
92 return
93 end subroutine
94 
95 !--------------------------------------------------------------------------
elemental subroutine gsw_melting_ice_into_seawater(sa, ct, p, w_ih, t_ih, sa_final, ct_final, w_ih_final)
real(r8), parameter, public gsw_error_limit
elemental real(r8) function, public gsw_error_code(err_num, func_name, error_code)