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

Last change on this file since 1682 was 1682, checked in by knoop, 9 years ago

Code annotations made doxygen readable

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