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