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

Last change on this file since 1982 was 1818, checked in by maronga, 9 years ago

last commit documented / copyright update

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