source: palm/trunk/SOURCE/eqn_state_seawater_mod.f90 @ 1850

Last change on this file since 1850 was 1850, checked in by maronga, 8 years ago

added _mod string to several filenames to meet the naming convection for modules

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