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

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

FORTRAN bugfix for r2845

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