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