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

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

ONLY-attribute added to USE-statements,
kind-parameters added to all INTEGER and REAL declaration statements,
kinds are defined in new module kinds,
old module precision_kind is removed,
revision history before 2012 removed,
comment fields (!:) to be used for variable explanations added to all variable declaration statements

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