source: palm/trunk/SOURCE/init_ocean.f90 @ 3272

Last change on this file since 3272 was 3270, checked in by raasch, 6 years ago

bugfix for r2502: wrong calculation of hyp(nzt) in second iterative step

  • Property svn:keywords set to Id
File size: 6.3 KB
Line 
1!> @file init_ocean.f90
2!------------------------------------------------------------------------------!
3! This file is part of the PALM model system.
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-2018 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! ------------------
26! $Id: init_ocean.f90 3270 2018-09-24 06:28:20Z suehring $
27! bugfix for r2502: wrong calculation of hyp(nzt) in second iterative step
28!
29! 2846 2018-03-01 08:48:47Z raasch
30! FORTRAN bugfix for r2845
31!
32! 2845 2018-03-01 08:32:34Z raasch
33! bugfix: set kinematic viscosity for sea water
34!
35! 2718 2018-01-02 08:49:38Z maronga
36! Corrected "Former revisions" section
37!
38! 2696 2017-12-14 17:12:51Z kanani
39! Change in file header (GPL part)
40!
41! 2502 2017-09-26 15:51:59Z gronemeier
42! Bugfix: use equation of state for seawater to calculate rho_ocean_init at nzt
43!
44! 2195 2017-03-23 08:15:17Z raasch
45!
46! 2194 2017-03-23 08:03:04Z raasch
47! bugfix: density is now used in single-value reference state instead of
48! potential density
49!
50! 2031 2016-10-21 15:11:58Z knoop
51! renamed variable rho_init to rho_ocean_init
52!
53! 2000 2016-08-20 18:09:15Z knoop
54! Forced header and separation lines into 80 columns
55!
56! 1682 2015-10-07 23:56:08Z knoop
57! Code annotations made doxygen readable
58!
59! 1353 2014-04-08 15:21:23Z heinze
60! REAL constants provided with KIND-attribute
61!
62! 1322 2014-03-20 16:38:49Z raasch
63! REAL constants defined as wp_kind
64!
65! 1320 2014-03-20 08:40:49Z raasch
66! ONLY-attribute added to USE-statements,
67! kind-parameters added to all INTEGER and REAL declaration statements,
68! kinds are defined in new module kinds,
69! revision history before 2012 removed,
70! comment fields (!:) to be used for variable explanations added to
71! all variable declaration statements
72!
73! 1179 2013-06-14 05:57:58Z raasch
74! Initial density profile is stored in array hom
75!
76! 1036 2012-10-22 13:43:42Z raasch
77! code put under GPL (PALM 3.9)
78!
79! 97 2007-06-21 08:23:15Z raasch
80! Initial revision
81!
82! Description:
83! ------------
84!> Initialization of quantities needed for the ocean version
85!------------------------------------------------------------------------------!
86 SUBROUTINE init_ocean
87 
88
89    USE arrays_3d,                                                             &
90        ONLY:  dzu, hyp, pt_init, ref_state, sa_init, zu, zw
91
92    USE control_parameters,                                                    &
93        ONLY:  g, molecular_viscosity, prho_reference, rho_surface,            &
94               rho_reference, surface_pressure, use_single_reference_value
95
96    USE eqn_state_seawater_mod,                                                &
97        ONLY:  eqn_state_seawater, eqn_state_seawater_func
98
99    USE indices,                                                               &
100        ONLY:  nzb, nzt
101
102    USE kinds
103
104    USE pegrid
105
106    USE statistics,                                                            &
107        ONLY:  hom, statistic_regions
108
109    IMPLICIT NONE
110
111    INTEGER(iwp) ::  k !<
112    INTEGER(iwp) ::  n !<
113
114    REAL(wp)     ::  pt_l !<
115    REAL(wp)     ::  sa_l !<
116
117    REAL(wp), DIMENSION(nzb:nzt+1) ::  rho_ocean_init !<
118
119    ALLOCATE( hyp(nzb:nzt+1) )
120
121!
122!-- Set water density near the ocean surface
123    rho_surface = 1027.62_wp
124
125!
126!-- Set kinematic viscosity to sea water at 20C
127!-- WARNING: This value is especially used for calculating terminal fall
128!--          velocities in the LPM, so lpm_init should always be called after
129!--          init_ocean!
130    molecular_viscosity = 1.05E-6_wp
131
132!
133!-- Calculate initial vertical profile of hydrostatic pressure (in Pa)
134!-- and the reference density (used later in buoyancy term)
135!-- First step: Calculate pressure using reference density
136    hyp(nzt+1) = surface_pressure * 100.0_wp
137    hyp(nzt)   = hyp(nzt+1) + rho_surface * g * 0.5_wp * dzu(nzt+1)
138    rho_ocean_init(nzt)   = rho_surface
139    rho_ocean_init(nzt+1) = rho_surface  ! only required for output
140
141    DO  k = nzt-1, 1, -1
142       hyp(k) = hyp(k+1) + rho_surface * g * dzu(k)
143    ENDDO
144    hyp(0) = hyp(1) + rho_surface * g * dzu(1)
145
146!
147!-- Second step: Iteratively calculate in situ density (based on presssure)
148!-- and pressure (based on in situ density)
149    DO  n = 1, 5
150
151       rho_reference = rho_surface * 0.5_wp * dzu(nzt+1)
152
153       DO  k = nzt, 0, -1
154
155          sa_l = 0.5_wp * ( sa_init(k) + sa_init(k+1) )
156          pt_l = 0.5_wp * ( pt_init(k) + pt_init(k+1) )
157
158          rho_ocean_init(k) = eqn_state_seawater_func( hyp(k), pt_l, sa_l )
159
160          rho_reference = rho_reference + rho_ocean_init(k) * dzu(k+1)
161
162       ENDDO
163
164       rho_reference = rho_reference / ( zw(nzt) - zu(nzb) )
165
166       hyp(nzt) = hyp(nzt+1) + rho_surface * g * 0.5_wp * dzu(nzt+1)
167       DO  k = nzt-1, 0, -1
168          hyp(k) = hyp(k+1) + g * 0.5_wp * ( rho_ocean_init(k)                 &
169                                           + rho_ocean_init(k+1) ) * dzu(k+1)
170       ENDDO
171
172    ENDDO
173
174!
175!-- Calculate the reference potential density
176    prho_reference = 0.0_wp
177    DO  k = 0, nzt
178
179       sa_l = 0.5_wp * ( sa_init(k) + sa_init(k+1) )
180       pt_l = 0.5_wp * ( pt_init(k) + pt_init(k+1) )
181
182       prho_reference = prho_reference + dzu(k+1) * &
183                        eqn_state_seawater_func( 0.0_wp, pt_l, sa_l )
184
185    ENDDO
186
187    prho_reference = prho_reference / ( zu(nzt) - zu(nzb) )
188
189!
190!-- Calculate the 3d array of initial in situ and potential density,
191!-- based on the initial temperature and salinity profile
192    CALL eqn_state_seawater
193
194!
195!-- Store initial density profile
196    hom(:,1,77,:)  = SPREAD( rho_ocean_init(:), 2, statistic_regions+1 )
197
198!
199!-- Set the reference state to be used in the buoyancy terms
200    IF ( use_single_reference_value )  THEN
201       ref_state(:) = rho_reference
202    ELSE
203       ref_state(:) = rho_ocean_init(:)
204    ENDIF
205
206
207 END SUBROUTINE init_ocean
Note: See TracBrowser for help on using the repository browser.