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

Last change on this file since 2000 was 2000, checked in by knoop, 8 years ago

Forced header and separation lines into 80 columns

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