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

Last change on this file since 2194 was 2194, checked in by raasch, 7 years ago

bugfix: density is now used in single-value reference state instead of potential density

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