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

Last change on this file since 1321 was 1321, checked in by raasch, 10 years ago

last commit documented

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