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

Last change on this file since 2000 was 2000, checked in by knoop, 5 years ago

Forced header and separation lines into 80 columns

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