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