source: palm/trunk/SOURCE/init_slope.f90 @ 3733

Last change on this file since 3733 was 3655, checked in by knoop, 6 years ago

Bugfix: made "unit" and "found" intend INOUT in module interface subroutines + automatic copyright update

  • Property svn:keywords set to Id
File size: 5.8 KB
RevLine 
[1682]1!> @file init_slope.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!
[3655]17! Copyright 1997-2019 Leibniz Universitaet Hannover
[2000]18!------------------------------------------------------------------------------!
[1036]19!
[484]20! Current revisions:
[1]21! -----------------
[1354]22!
[2001]23!
[1321]24! Former revisions:
25! -----------------
26! $Id: init_slope.f90 3655 2019-01-07 16:51:22Z suehring $
[3274]27! Modularization of all bulk cloud physics code components
28!
29! 2718 2018-01-02 08:49:38Z maronga
[2716]30! Corrected "Former revisions" section
31!
32! 2696 2017-12-14 17:12:51Z kanani
33! Change in file header (GPL part)
[1321]34!
[2716]35! 2101 2017-01-05 16:42:31Z suehring
36!
[2001]37! 2000 2016-08-20 18:09:15Z knoop
38! Forced header and separation lines into 80 columns
39!
[1683]40! 1682 2015-10-07 23:56:08Z knoop
41! Code annotations made doxygen readable
42!
[1354]43! 1353 2014-04-08 15:21:23Z heinze
44! REAL constants provided with KIND-attribute
45!
[1323]46! 1322 2014-03-20 16:38:49Z raasch
47! REAL constants defined as wp_kind
48!
[1321]49! 1320 2014-03-20 08:40:49Z raasch
[1320]50! ONLY-attribute added to USE-statements,
51! kind-parameters added to all INTEGER and REAL declaration statements,
52! kinds are defined in new module kinds,
53! revision history before 2012 removed,
54! comment fields (!:) to be used for variable explanations added to
55! all variable declaration statements
[1]56!
[1037]57! 1036 2012-10-22 13:43:42Z raasch
58! code put under GPL (PALM 3.9)
59!
[1]60! Revision 1.1  2000/04/27 07:06:24  raasch
61! Initial revision
62!
63!
64! Description:
65! ------------
[1682]66!> Initialization of the temperature field and other variables used in case
67!> of a sloping surface.
68!> @note when a sloping surface is used, only one constant temperature
69!>       gradient is allowed!
[3]70!------------------------------------------------------------------------------!
[1682]71 SUBROUTINE init_slope
72 
[1]73
[1320]74    USE arrays_3d,                                                             &
75        ONLY:  pt, pt_init, pt_slope_ref, zu
76       
[3274]77    USE basic_constants_and_equations_mod,                                     &
[1320]78        ONLY:  pi
79                   
80    USE control_parameters,                                                    &
81        ONLY:  alpha_surface, initializing_actions, pt_slope_offset,           &
82               pt_surface, pt_vertical_gradient, sin_alpha_surface
83       
84    USE grid_variables,                                                        &
85        ONLY:  dx
86       
87    USE indices,                                                               &
88        ONLY:  ngp_2dh, nx, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt
89       
90    USE kinds
91
[1]92    USE pegrid
93
[1320]94
[1]95    IMPLICIT NONE
96
[1682]97    INTEGER(iwp) ::  i        !<
98    INTEGER(iwp) ::  j        !<
99    INTEGER(iwp) ::  k        !<
[1320]100   
[1682]101    REAL(wp)     ::  alpha    !<
102    REAL(wp)     ::  height   !<
103    REAL(wp)     ::  pt_value !<
104    REAL(wp)     ::  radius   !<
[1320]105   
[1682]106    REAL(wp), DIMENSION(:), ALLOCATABLE ::  pt_init_local !<
[1]107
108!
109!-- Calculate reference temperature field needed for computing buoyancy
[667]110    ALLOCATE( pt_slope_ref(nzb:nzt+1,nxlg:nxrg) )
[1]111
[667]112    DO  i = nxlg, nxrg
[1]113       DO  k = nzb, nzt+1
114
115!
116!--       Compute height of grid-point relative to lower left corner of
117!--       the total domain.
118!--       First compute the distance between the actual grid point and the
119!--       lower left corner as well as the angle between the line connecting
120!--       these points and the bottom of the model.
121          IF ( k /= nzb )  THEN
122             radius = SQRT( ( i * dx )**2 + zu(k)**2 )
123             height = zu(k)
124          ELSE
125             radius = SQRT( ( i * dx )**2 )
[1353]126             height = 0.0_wp
[1]127          ENDIF
[1353]128          IF ( radius /= 0.0_wp )  THEN
[1]129             alpha = ASIN( height / radius )
130          ELSE
[1353]131             alpha = 0.0_wp
[1]132          ENDIF
133!
134!--       Compute temperatures in the rotated coordinate system
[1322]135          alpha    = alpha + alpha_surface / 180.0_wp * pi
[1]136          pt_value = pt_surface + radius * SIN( alpha ) * &
[1322]137                                  pt_vertical_gradient(1) / 100.0_wp
[1]138          pt_slope_ref(k,i) = pt_value
139       ENDDO               
140    ENDDO
141
142!
143!-- Temperature difference between left and right boundary of the total domain,
144!-- used for the cyclic boundary in x-direction
145    pt_slope_offset = (nx+1) * dx * sin_alpha_surface * &
[1322]146                      pt_vertical_gradient(1) / 100.0_wp
[1]147
148
149!
150!-- Following action must only be executed for initial runs
151    IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
152!
153!--    Set initial temperature equal to the reference temperature field
[667]154       DO  j = nysg, nyng
[1]155          pt(:,j,:) = pt_slope_ref
156       ENDDO
157
158!
159!--    Recompute the mean initial temperature profile (mean along x-direction of
160!--    the rotated coordinate system)
161       ALLOCATE( pt_init_local(nzb:nzt+1) )
[1353]162       pt_init_local = 0.0_wp
[1]163       DO  i = nxl, nxr
164          DO  j =  nys, nyn
165             DO  k = nzb, nzt+1
166                pt_init_local(k) = pt_init_local(k) + pt(k,j,i)
167             ENDDO
168          ENDDO
[622]169       ENDDO
[1]170
171#if defined( __parallel )
[622]172       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
173       CALL MPI_ALLREDUCE( pt_init_local, pt_init, nzt+2-nzb, MPI_REAL, &
174                            MPI_SUM, comm2d, ierr )
[1]175#else
[622]176       pt_init = pt_init_local
[1]177#endif
178
[622]179       pt_init = pt_init / ngp_2dh(0)
180       DEALLOCATE( pt_init_local )
[1]181
[622]182    ENDIF
[1]183
184 END SUBROUTINE init_slope
Note: See TracBrowser for help on using the repository browser.