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

Last change on this file since 2153 was 2101, checked in by suehring, 8 years ago

last commit documented

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