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

Last change on this file since 1350 was 1323, checked in by raasch, 11 years ago

last commit documented

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