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

Last change on this file since 1693 was 1683, checked in by knoop, 9 years ago

last commit documented

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