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

Last change on this file since 1920 was 1818, checked in by maronga, 9 years ago

last commit documented / copyright update

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