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

Last change on this file since 1682 was 1682, checked in by knoop, 8 years ago

Code annotations made doxygen readable

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