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

Last change on this file since 2502 was 2502, checked in by gronemeier, 7 years ago

Bugfix: corrected reference state for rho_ocean

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