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

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

Code annotations made doxygen readable

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