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

Last change on this file since 2284 was 2195, checked in by raasch, 8 years ago

last commit documented

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