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

Last change on this file since 1433 was 1354, checked in by heinze, 11 years ago

last commit documented

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