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

Last change on this file since 1320 was 1320, checked in by raasch, 10 years ago

ONLY-attribute added to USE-statements,
kind-parameters added to all INTEGER and REAL declaration statements,
kinds are defined in new module kinds,
old module precision_kind is removed,
revision history before 2012 removed,
comment fields (!:) to be used for variable explanations added to all variable declaration statements

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