1 | !> @file eqn_state_seawater_mod.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
7 | ! either version 3 of the License, or (at your option) any later version. |
---|
8 | ! |
---|
9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
12 | ! |
---|
13 | ! You should have received a copy of the GNU General Public License along with |
---|
14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
15 | ! |
---|
16 | ! Copyright 1997-2016 Leibniz Universitaet Hannover |
---|
17 | !------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! Current revisions: |
---|
20 | ! ----------------- |
---|
21 | ! |
---|
22 | ! |
---|
23 | ! Former revisions: |
---|
24 | ! ----------------- |
---|
25 | ! $Id: eqn_state_seawater_mod.f90 1851 2016-04-08 13:32:50Z raasch $ |
---|
26 | ! |
---|
27 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
28 | ! Module renamed |
---|
29 | ! |
---|
30 | ! |
---|
31 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
32 | ! Code annotations made doxygen readable |
---|
33 | ! |
---|
34 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
35 | ! REAL constants provided with KIND-attribute |
---|
36 | ! |
---|
37 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
38 | ! ONLY-attribute added to USE-statements, |
---|
39 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
40 | ! kinds are defined in new module kinds, |
---|
41 | ! revision history before 2012 removed, |
---|
42 | ! comment fields (!:) to be used for variable explanations added to |
---|
43 | ! all variable declaration statements |
---|
44 | ! |
---|
45 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
46 | ! code put under GPL (PALM 3.9) |
---|
47 | ! |
---|
48 | ! 97 2007-06-21 08:23:15Z raasch |
---|
49 | ! Initial revision |
---|
50 | ! |
---|
51 | ! |
---|
52 | ! Description: |
---|
53 | ! ------------ |
---|
54 | !> Equation of state for seawater as a function of potential temperature, |
---|
55 | !> salinity, and pressure. |
---|
56 | !> For coefficients see Jackett et al., 2006: J. Atm. Ocean Tech. |
---|
57 | !> eqn_state_seawater calculates the potential density referred at hyp(0). |
---|
58 | !> eqn_state_seawater_func calculates density. |
---|
59 | !------------------------------------------------------------------------------! |
---|
60 | MODULE eqn_state_seawater_mod |
---|
61 | |
---|
62 | |
---|
63 | USE kinds |
---|
64 | |
---|
65 | IMPLICIT NONE |
---|
66 | |
---|
67 | PRIVATE |
---|
68 | PUBLIC eqn_state_seawater, eqn_state_seawater_func |
---|
69 | |
---|
70 | REAL(wp), DIMENSION(12), PARAMETER :: nom = & |
---|
71 | (/ 9.9984085444849347D2, 7.3471625860981584D0, & |
---|
72 | -5.3211231792841769D-2, 3.6492439109814549D-4, & |
---|
73 | 2.5880571023991390D0, -6.7168282786692354D-3, & |
---|
74 | 1.9203202055760151D-3, 1.1798263740430364D-2, & |
---|
75 | 9.8920219266399117D-8, 4.6996642771754730D-6, & |
---|
76 | -2.5862187075154352D-8, -3.2921414007960662D-12 /) |
---|
77 | !< |
---|
78 | |
---|
79 | REAL(wp), DIMENSION(13), PARAMETER :: den = & |
---|
80 | (/ 1.0D0, 7.2815210113327091D-3, & |
---|
81 | -4.4787265461983921D-5, 3.3851002965802430D-7, & |
---|
82 | 1.3651202389758572D-10, 1.7632126669040377D-3, & |
---|
83 | -8.8066583251206474D-6, -1.8832689434804897D-10, & |
---|
84 | 5.7463776745432097D-6, 1.4716275472242334D-9, & |
---|
85 | 6.7103246285651894D-6, -2.4461698007024582D-17, & |
---|
86 | -9.1534417604289062D-18 /) |
---|
87 | !< |
---|
88 | |
---|
89 | INTERFACE eqn_state_seawater |
---|
90 | MODULE PROCEDURE eqn_state_seawater |
---|
91 | MODULE PROCEDURE eqn_state_seawater_ij |
---|
92 | END INTERFACE eqn_state_seawater |
---|
93 | |
---|
94 | INTERFACE eqn_state_seawater_func |
---|
95 | MODULE PROCEDURE eqn_state_seawater_func |
---|
96 | END INTERFACE eqn_state_seawater_func |
---|
97 | |
---|
98 | CONTAINS |
---|
99 | |
---|
100 | |
---|
101 | !------------------------------------------------------------------------------! |
---|
102 | ! Description: |
---|
103 | ! ------------ |
---|
104 | !> Call for all grid points |
---|
105 | !------------------------------------------------------------------------------! |
---|
106 | SUBROUTINE eqn_state_seawater |
---|
107 | |
---|
108 | USE arrays_3d, & |
---|
109 | ONLY: hyp, prho, pt_p, rho, sa_p |
---|
110 | USE indices, & |
---|
111 | ONLY: nxl, nxr, nyn, nys, nzb_s_inner, nzt |
---|
112 | |
---|
113 | IMPLICIT NONE |
---|
114 | |
---|
115 | INTEGER(iwp) :: i !< |
---|
116 | INTEGER(iwp) :: j !< |
---|
117 | INTEGER(iwp) :: k !< |
---|
118 | |
---|
119 | REAL(wp) :: pden !< |
---|
120 | REAL(wp) :: pnom !< |
---|
121 | REAL(wp) :: p1 !< |
---|
122 | REAL(wp) :: p2 !< |
---|
123 | REAL(wp) :: p3 !< |
---|
124 | REAL(wp) :: pt1 !< |
---|
125 | REAL(wp) :: pt2 !< |
---|
126 | REAL(wp) :: pt3 !< |
---|
127 | REAL(wp) :: pt4 !< |
---|
128 | REAL(wp) :: sa1 !< |
---|
129 | REAL(wp) :: sa15 !< |
---|
130 | REAL(wp) :: sa2 !< |
---|
131 | |
---|
132 | |
---|
133 | |
---|
134 | DO i = nxl, nxr |
---|
135 | DO j = nys, nyn |
---|
136 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
137 | ! |
---|
138 | !-- Pressure is needed in dbar |
---|
139 | p1 = hyp(k) * 1E-4_wp |
---|
140 | p2 = p1 * p1 |
---|
141 | p3 = p2 * p1 |
---|
142 | |
---|
143 | ! |
---|
144 | !-- Temperature needed in degree Celsius |
---|
145 | pt1 = pt_p(k,j,i) - 273.15_wp |
---|
146 | pt2 = pt1 * pt1 |
---|
147 | pt3 = pt1 * pt2 |
---|
148 | pt4 = pt2 * pt2 |
---|
149 | |
---|
150 | sa1 = sa_p(k,j,i) |
---|
151 | sa15 = sa1 * SQRT( sa1 ) |
---|
152 | sa2 = sa1 * sa1 |
---|
153 | |
---|
154 | pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
155 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & |
---|
156 | nom(7)*sa2 |
---|
157 | |
---|
158 | pden = den(1) + den(2)*pt1 + den(3)*pt2 + & |
---|
159 | den(4)*pt3 + den(5)*pt4 + den(6)*sa1 + & |
---|
160 | den(7)*sa1*pt1 + den(8)*sa1*pt3 + den(9)*sa15 + & |
---|
161 | den(10)*sa15*pt2 |
---|
162 | |
---|
163 | ! |
---|
164 | !-- Potential density (without pressure terms) |
---|
165 | prho(k,j,i) = pnom / pden |
---|
166 | |
---|
167 | pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
168 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 |
---|
169 | |
---|
170 | pden = pden + den(11)*p1 + den(12)*p2*pt3 + & |
---|
171 | den(13)*p3*pt1 |
---|
172 | |
---|
173 | ! |
---|
174 | !-- In-situ density |
---|
175 | rho(k,j,i) = pnom / pden |
---|
176 | |
---|
177 | ENDDO |
---|
178 | ! |
---|
179 | !-- Neumann conditions are assumed at bottom and top boundary |
---|
180 | prho(nzt+1,j,i) = prho(nzt,j,i) |
---|
181 | prho(nzb_s_inner(j,i),j,i) = prho(nzb_s_inner(j,i)+1,j,i) |
---|
182 | rho(nzt+1,j,i) = rho(nzt,j,i) |
---|
183 | rho(nzb_s_inner(j,i),j,i) = rho(nzb_s_inner(j,i)+1,j,i) |
---|
184 | |
---|
185 | ENDDO |
---|
186 | ENDDO |
---|
187 | |
---|
188 | END SUBROUTINE eqn_state_seawater |
---|
189 | |
---|
190 | |
---|
191 | !------------------------------------------------------------------------------! |
---|
192 | ! Description: |
---|
193 | ! ------------ |
---|
194 | !> Call for grid point i,j |
---|
195 | !------------------------------------------------------------------------------! |
---|
196 | SUBROUTINE eqn_state_seawater_ij( i, j ) |
---|
197 | |
---|
198 | USE arrays_3d, & |
---|
199 | ONLY: hyp, prho, pt_p, rho, sa_p |
---|
200 | |
---|
201 | USE indices, & |
---|
202 | ONLY: nzb_s_inner, nzt |
---|
203 | |
---|
204 | IMPLICIT NONE |
---|
205 | |
---|
206 | INTEGER(iwp) :: i, j, k |
---|
207 | |
---|
208 | REAL(wp) :: pden, pnom, p1, p2, p3, pt1, pt2, pt3, pt4, sa1, sa15, & |
---|
209 | sa2 |
---|
210 | |
---|
211 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
212 | ! |
---|
213 | !-- Pressure is needed in dbar |
---|
214 | p1 = hyp(k) * 1E-4_wp |
---|
215 | p2 = p1 * p1 |
---|
216 | p3 = p2 * p1 |
---|
217 | |
---|
218 | ! |
---|
219 | !-- Temperature needed in degree Celsius |
---|
220 | pt1 = pt_p(k,j,i) - 273.15_wp |
---|
221 | pt2 = pt1 * pt1 |
---|
222 | pt3 = pt1 * pt2 |
---|
223 | pt4 = pt2 * pt2 |
---|
224 | |
---|
225 | sa1 = sa_p(k,j,i) |
---|
226 | sa15 = sa1 * SQRT( sa1 ) |
---|
227 | sa2 = sa1 * sa1 |
---|
228 | |
---|
229 | pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
230 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & |
---|
231 | nom(7)*sa2 |
---|
232 | |
---|
233 | pden = den(1) + den(2)*pt1 + den(3)*pt2 + & |
---|
234 | den(4)*pt3 + den(5)*pt4 + den(6)*sa1 + & |
---|
235 | den(7)*sa1*pt1 + den(8)*sa1*pt3 + den(9)*sa15 + & |
---|
236 | den(10)*sa15*pt2 |
---|
237 | |
---|
238 | ! |
---|
239 | !-- Potential density (without pressure terms) |
---|
240 | prho(k,j,i) = pnom / pden |
---|
241 | |
---|
242 | pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
243 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 |
---|
244 | pden = pden + den(11)*p1 + den(12)*p2*pt3 + & |
---|
245 | den(13)*p3*pt1 |
---|
246 | |
---|
247 | ! |
---|
248 | !-- In-situ density |
---|
249 | rho(k,j,i) = pnom / pden |
---|
250 | |
---|
251 | |
---|
252 | ENDDO |
---|
253 | |
---|
254 | ! |
---|
255 | !-- Neumann conditions are assumed at bottom and top boundary |
---|
256 | prho(nzt+1,j,i) = prho(nzt,j,i) |
---|
257 | prho(nzb_s_inner(j,i),j,i) = prho(nzb_s_inner(j,i)+1,j,i) |
---|
258 | rho(nzt+1,j,i) = rho(nzt,j,i) |
---|
259 | rho(nzb_s_inner(j,i),j,i) = rho(nzb_s_inner(j,i)+1,j,i) |
---|
260 | |
---|
261 | END SUBROUTINE eqn_state_seawater_ij |
---|
262 | |
---|
263 | |
---|
264 | !------------------------------------------------------------------------------! |
---|
265 | ! Description: |
---|
266 | ! ------------ |
---|
267 | !> Equation of state as a function |
---|
268 | !------------------------------------------------------------------------------! |
---|
269 | REAL(wp) FUNCTION eqn_state_seawater_func( p, pt, sa ) |
---|
270 | |
---|
271 | IMPLICIT NONE |
---|
272 | |
---|
273 | REAL(wp) :: p !< |
---|
274 | REAL(wp) :: p1 !< |
---|
275 | REAL(wp) :: p2 !< |
---|
276 | REAL(wp) :: p3 !< |
---|
277 | REAL(wp) :: pt !< |
---|
278 | REAL(wp) :: pt1 !< |
---|
279 | REAL(wp) :: pt2 !< |
---|
280 | REAL(wp) :: pt3 !< |
---|
281 | REAL(wp) :: pt4 !< |
---|
282 | REAL(wp) :: sa !< |
---|
283 | REAL(wp) :: sa15 !< |
---|
284 | REAL(wp) :: sa2 !< |
---|
285 | |
---|
286 | ! |
---|
287 | !-- Pressure is needed in dbar |
---|
288 | p1 = p * 1E-4_wp |
---|
289 | p2 = p1 * p1 |
---|
290 | p3 = p2 * p1 |
---|
291 | |
---|
292 | ! |
---|
293 | !-- Temperature needed in degree Celsius |
---|
294 | pt1 = pt - 273.15_wp |
---|
295 | pt2 = pt1 * pt1 |
---|
296 | pt3 = pt1 * pt2 |
---|
297 | pt4 = pt2 * pt2 |
---|
298 | |
---|
299 | sa15 = sa * SQRT( sa ) |
---|
300 | sa2 = sa * sa |
---|
301 | |
---|
302 | |
---|
303 | eqn_state_seawater_func = & |
---|
304 | ( nom(1) + nom(2)*pt1 + nom(3)*pt2 + nom(4)*pt3 + & |
---|
305 | nom(5)*sa + nom(6)*sa*pt1 + nom(7)*sa2 + nom(8)*p1 + & |
---|
306 | nom(9)*p1*pt2 + nom(10)*p1*sa + nom(11)*p2 + nom(12)*p2*pt2 & |
---|
307 | ) / & |
---|
308 | ( den(1) + den(2)*pt1 + den(3)*pt2 + den(4)*pt3 + & |
---|
309 | den(5)*pt4 + den(6)*sa + den(7)*sa*pt1 + den(8)*sa*pt3 + & |
---|
310 | den(9)*sa15 + den(10)*sa15*pt2 + den(11)*p1 + den(12)*p2*pt3 + & |
---|
311 | den(13)*p3*pt1 & |
---|
312 | ) |
---|
313 | |
---|
314 | |
---|
315 | END FUNCTION eqn_state_seawater_func |
---|
316 | |
---|
317 | END MODULE eqn_state_seawater_mod |
---|