FV3 Bundle
gsw_melting_seaice_into_seawater.f90
Go to the documentation of this file.
1 !==========================================================================
2 elemental subroutine gsw_melting_seaice_into_seawater (sa, ct, p, &
3  w_seaice, sa_seaice, t_seaice, sa_final, ct_final)
4 !==========================================================================
5 !
6 ! Calculates the Absolute Salinity and Conservative Temperature that
7 ! results when a given mass of sea ice (or ice) melts and is mixed into a
8 ! known mass of seawater (whose properties are (SA,CT,p)).
9 !
10 ! If the ice contains no salt (e.g. if it is of glacial origin), then the
11 ! input 'SA_seaice' should be set to zero.
12 !
13 ! Ice formed at the sea surface (sea ice) typically contains between 2 g/kg
14 ! and 12 g/kg of salt (defined as the mass of salt divided by the mass of
15 ! ice Ih plus brine) and this programme returns NaN's if the input
16 ! SA_seaice is greater than 15 g/kg. If the SA_seaice input is not zero,
17 ! usually this would imply that the pressure p should be zero, as sea ice
18 ! only occurs near the sea surface. The code does not impose that p = 0
19 ! if SA_seaice is non-zero. Rather, this is left to the user.
20 !
21 ! The Absolute Salinity, SA_brine, of the brine trapped in little pockets
22 ! in the sea ice, is in thermodynamic equilibrium with the ice Ih that
23 ! surrounds these pockets. As the sea ice temperature, t_seaice, may be
24 ! less than the freezing temperature, SA_brine is usually greater than the
25 ! Absolute Salinity of the seawater at the time and place when and where
26 ! the sea ice was formed. So usually SA_brine will be larger than SA.
27 !
28 ! SA = Absolute Salinity of seawater [ g/kg ]
29 ! CT = Conservative Temperature of seawater (ITS-90) [ deg C ]
30 ! p = sea pressure at which the melting occurs [ dbar ]
31 ! ( i.e. absolute pressure - 10.1325 dbar )
32 ! w_seaice = mass fraction of sea ice, that is the mass of sea ice
33 ! divided by the sum of the masses of sea ice and seawater.
34 ! That is, the mass of sea ice divided by the mass of the
35 ! final mixed fluid. w_seaice must be between 0 and 1.
36 ! [ unitless ]
37 ! SA_seaice = Absolute Salinity of sea ice, that is, the mass fraction of
38 ! salt in sea ice, expressed in g of salt per kg of sea ice.
39 ! [ g/kg ]
40 ! t_seaice = the in-situ temperature of the sea ice (or ice) (ITS-90)
41 ! [ deg C ]
42 !
43 ! SA_final = Absolute Salinity of the mixture of the melted sea ice
44 ! (or ice) and the orignal seawater [ g/kg ]
45 ! CT_final = Conservative Temperature of the mixture of the melted
46 ! sea ice (or ice) and the orignal seawater [ deg C ]
47 !--------------------------------------------------------------------------
48 
53 
55 
56 use gsw_mod_kinds
57 
58 implicit none
59 
60 real (r8), intent(in) :: sa, ct, p, w_seaice, sa_seaice, t_seaice
61 real (r8), intent(out) :: sa_final, ct_final
62 
63 real (r8) :: ctf, h, h_brine, h_final, h_ih, sa_brine, tf_sa_seaice
64 
65 real (r8), parameter :: saturation_fraction = 0.0_r8
66 
67 character (*), parameter :: func_name = "gsw_melting_seaice_into_seawater"
68 
69 ctf = gsw_ct_freezing_exact(sa,p,saturation_fraction)
70 if (ct .lt. ctf) then
71  ! The seawater ct input is below the freezing temp
72  sa_final = gsw_error_code(1,func_name)
73  ct_final = sa_final
74  return
75 end if
76 
77 tf_sa_seaice = gsw_t_freezing_exact(sa_seaice,p,saturation_fraction) - 1e-6_r8
78 if (t_seaice .gt. tf_sa_seaice) then
79  ! The 1e-6 C buffer in the allowable t_seaice is to ensure that there is
80  ! some ice Ih in the sea ice. Without this buffer, that is if t_seaice
81  ! is allowed to be exactly equal to tf_sa_seaice, the seaice is
82  ! actually 100% brine at Absolute Salinity of SA_seaice.
83  sa_final = gsw_error_code(2,func_name)
84  ct_final = sa_final
85  return
86 end if
87 
88 sa_brine = gsw_sa_freezing_from_t(t_seaice,p,saturation_fraction)
89 if (sa_brine .gt. gsw_error_limit) then
90  sa_final = gsw_error_code(3,func_name,sa_brine)
91  ct_final = sa_final
92  return
93 end if
94 h_brine = gsw_enthalpy_t_exact(sa_brine,t_seaice,p)
95 
96 h = gsw_enthalpy_ct_exact(sa,ct,p)
97 h_ih = gsw_enthalpy_ice(t_seaice,p)
98 
99 h_final = h - w_seaice*(h - h_ih - (h_brine - h_ih)*sa_seaice/sa_brine)
100 
101 sa_final = sa - w_seaice*(sa - sa_seaice)
102 
103 !ctf = gsw_ct_freezing_exact(sa_final,p,saturation_fraction)
104 !
105 !if (h_final .lt. gsw_enthalpy_ct_exact(sa_final,ctf,p)) then
106 ! ! Melting this much seaice is not possible as it would result in
107 ! ! frozen seawater
108 ! sa_final = gsw_error_code(4,func_name)
109 ! ct_final = sa_final
110 ! return
111 !end if
112 
113 ct_final = gsw_ct_from_enthalpy_exact(sa_final,h_final,p)
114 if (ct_final .gt. gsw_error_limit) then
115  sa_final = ct_final
116  return
117 endif
118 
119 return
120 end subroutine
121 
122 !--------------------------------------------------------------------------
elemental subroutine gsw_melting_seaice_into_seawater(sa, ct, p, w_seaice, sa_seaice, t_seaice, sa_final, ct_final)
real(r8), parameter, public gsw_error_limit
elemental real(r8) function, public gsw_error_code(err_num, func_name, error_code)