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

Last change on this file since 1322 was 1322, checked in by raasch, 8 years ago

REAL functions and a lot of REAL constants provided with KIND-attribute,
some small bugfixes

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