[1850] | 1 | !> @file eqn_state_seawater_mod.f90 |
---|
[1320] | 2 | !------------------------------------------------------------------------------! |
---|
[1036] | 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 | ! |
---|
[1818] | 16 | ! Copyright 1997-2016 Leibniz Universitaet Hannover |
---|
[1320] | 17 | !------------------------------------------------------------------------------! |
---|
[1036] | 18 | ! |
---|
[484] | 19 | ! Current revisions: |
---|
[96] | 20 | ! ----------------- |
---|
[1354] | 21 | ! |
---|
[1683] | 22 | ! |
---|
[1321] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: eqn_state_seawater_mod.f90 1851 2016-04-08 13:32:50Z raasch $ |
---|
| 26 | ! |
---|
[1851] | 27 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
| 28 | ! Module renamed |
---|
| 29 | ! |
---|
| 30 | ! |
---|
[1683] | 31 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 32 | ! Code annotations made doxygen readable |
---|
| 33 | ! |
---|
[1354] | 34 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 35 | ! REAL constants provided with KIND-attribute |
---|
| 36 | ! |
---|
[1321] | 37 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 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 |
---|
[96] | 44 | ! |
---|
[1037] | 45 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 46 | ! code put under GPL (PALM 3.9) |
---|
| 47 | ! |
---|
[98] | 48 | ! 97 2007-06-21 08:23:15Z raasch |
---|
[96] | 49 | ! Initial revision |
---|
| 50 | ! |
---|
| 51 | ! |
---|
| 52 | ! Description: |
---|
| 53 | ! ------------ |
---|
[1682] | 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. |
---|
[96] | 59 | !------------------------------------------------------------------------------! |
---|
[1682] | 60 | MODULE eqn_state_seawater_mod |
---|
| 61 | |
---|
[1320] | 62 | |
---|
| 63 | USE kinds |
---|
[96] | 64 | |
---|
| 65 | IMPLICIT NONE |
---|
| 66 | |
---|
| 67 | PRIVATE |
---|
| 68 | PUBLIC eqn_state_seawater, eqn_state_seawater_func |
---|
| 69 | |
---|
[1320] | 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 /) |
---|
[1682] | 77 | !< |
---|
[96] | 78 | |
---|
[1320] | 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 /) |
---|
[1682] | 87 | !< |
---|
[96] | 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 | !------------------------------------------------------------------------------! |
---|
[1682] | 102 | ! Description: |
---|
| 103 | ! ------------ |
---|
| 104 | !> Call for all grid points |
---|
[96] | 105 | !------------------------------------------------------------------------------! |
---|
| 106 | SUBROUTINE eqn_state_seawater |
---|
| 107 | |
---|
[1320] | 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 |
---|
[96] | 112 | |
---|
| 113 | IMPLICIT NONE |
---|
| 114 | |
---|
[1682] | 115 | INTEGER(iwp) :: i !< |
---|
| 116 | INTEGER(iwp) :: j !< |
---|
| 117 | INTEGER(iwp) :: k !< |
---|
[96] | 118 | |
---|
[1682] | 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 !< |
---|
[1320] | 131 | |
---|
| 132 | |
---|
[96] | 133 | |
---|
| 134 | DO i = nxl, nxr |
---|
| 135 | DO j = nys, nyn |
---|
[97] | 136 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
[96] | 137 | ! |
---|
| 138 | !-- Pressure is needed in dbar |
---|
[1353] | 139 | p1 = hyp(k) * 1E-4_wp |
---|
[96] | 140 | p2 = p1 * p1 |
---|
| 141 | p3 = p2 * p1 |
---|
| 142 | |
---|
| 143 | ! |
---|
| 144 | !-- Temperature needed in degree Celsius |
---|
[1353] | 145 | pt1 = pt_p(k,j,i) - 273.15_wp |
---|
[96] | 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 | |
---|
[1320] | 154 | pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
| 155 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & |
---|
[388] | 156 | nom(7)*sa2 |
---|
[96] | 157 | |
---|
[1320] | 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 + & |
---|
[388] | 161 | den(10)*sa15*pt2 |
---|
| 162 | |
---|
| 163 | ! |
---|
| 164 | !-- Potential density (without pressure terms) |
---|
| 165 | prho(k,j,i) = pnom / pden |
---|
| 166 | |
---|
[1320] | 167 | pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
[388] | 168 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 |
---|
| 169 | |
---|
[1320] | 170 | pden = pden + den(11)*p1 + den(12)*p2*pt3 + & |
---|
[388] | 171 | den(13)*p3*pt1 |
---|
| 172 | |
---|
| 173 | ! |
---|
| 174 | !-- In-situ density |
---|
| 175 | rho(k,j,i) = pnom / pden |
---|
| 176 | |
---|
[96] | 177 | ENDDO |
---|
[97] | 178 | ! |
---|
| 179 | !-- Neumann conditions are assumed at bottom and top boundary |
---|
[388] | 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 | |
---|
[96] | 185 | ENDDO |
---|
| 186 | ENDDO |
---|
| 187 | |
---|
| 188 | END SUBROUTINE eqn_state_seawater |
---|
| 189 | |
---|
| 190 | |
---|
| 191 | !------------------------------------------------------------------------------! |
---|
[1682] | 192 | ! Description: |
---|
| 193 | ! ------------ |
---|
| 194 | !> Call for grid point i,j |
---|
[96] | 195 | !------------------------------------------------------------------------------! |
---|
| 196 | SUBROUTINE eqn_state_seawater_ij( i, j ) |
---|
| 197 | |
---|
[1320] | 198 | USE arrays_3d, & |
---|
| 199 | ONLY: hyp, prho, pt_p, rho, sa_p |
---|
| 200 | |
---|
| 201 | USE indices, & |
---|
| 202 | ONLY: nzb_s_inner, nzt |
---|
[96] | 203 | |
---|
| 204 | IMPLICIT NONE |
---|
| 205 | |
---|
[1320] | 206 | INTEGER(iwp) :: i, j, k |
---|
[96] | 207 | |
---|
[1320] | 208 | REAL(wp) :: pden, pnom, p1, p2, p3, pt1, pt2, pt3, pt4, sa1, sa15, & |
---|
| 209 | sa2 |
---|
[96] | 210 | |
---|
[97] | 211 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
[96] | 212 | ! |
---|
| 213 | !-- Pressure is needed in dbar |
---|
[1353] | 214 | p1 = hyp(k) * 1E-4_wp |
---|
[96] | 215 | p2 = p1 * p1 |
---|
| 216 | p3 = p2 * p1 |
---|
| 217 | |
---|
| 218 | ! |
---|
| 219 | !-- Temperature needed in degree Celsius |
---|
[1353] | 220 | pt1 = pt_p(k,j,i) - 273.15_wp |
---|
[96] | 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 | |
---|
[1320] | 229 | pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
| 230 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & |
---|
[388] | 231 | nom(7)*sa2 |
---|
| 232 | |
---|
[1320] | 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 + & |
---|
[388] | 236 | den(10)*sa15*pt2 |
---|
| 237 | |
---|
| 238 | ! |
---|
| 239 | !-- Potential density (without pressure terms) |
---|
| 240 | prho(k,j,i) = pnom / pden |
---|
| 241 | |
---|
[1320] | 242 | pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
[388] | 243 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 |
---|
[1320] | 244 | pden = pden + den(11)*p1 + den(12)*p2*pt3 + & |
---|
[388] | 245 | den(13)*p3*pt1 |
---|
| 246 | |
---|
| 247 | ! |
---|
| 248 | !-- In-situ density |
---|
| 249 | rho(k,j,i) = pnom / pden |
---|
| 250 | |
---|
| 251 | |
---|
[96] | 252 | ENDDO |
---|
[388] | 253 | |
---|
[97] | 254 | ! |
---|
| 255 | !-- Neumann conditions are assumed at bottom and top boundary |
---|
[388] | 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) |
---|
[96] | 260 | |
---|
| 261 | END SUBROUTINE eqn_state_seawater_ij |
---|
| 262 | |
---|
| 263 | |
---|
| 264 | !------------------------------------------------------------------------------! |
---|
[1682] | 265 | ! Description: |
---|
| 266 | ! ------------ |
---|
| 267 | !> Equation of state as a function |
---|
[96] | 268 | !------------------------------------------------------------------------------! |
---|
[1320] | 269 | REAL(wp) FUNCTION eqn_state_seawater_func( p, pt, sa ) |
---|
[96] | 270 | |
---|
| 271 | IMPLICIT NONE |
---|
| 272 | |
---|
[1682] | 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 !< |
---|
[96] | 285 | |
---|
| 286 | ! |
---|
| 287 | !-- Pressure is needed in dbar |
---|
[1353] | 288 | p1 = p * 1E-4_wp |
---|
[96] | 289 | p2 = p1 * p1 |
---|
| 290 | p3 = p2 * p1 |
---|
| 291 | |
---|
| 292 | ! |
---|
| 293 | !-- Temperature needed in degree Celsius |
---|
[1353] | 294 | pt1 = pt - 273.15_wp |
---|
[96] | 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 |
---|