1 | SUBROUTINE init_slope |
---|
2 | |
---|
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 | ! |
---|
17 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
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 |
---|
28 | ! |
---|
29 | ! Former revisions: |
---|
30 | ! ----------------- |
---|
31 | ! $Id: init_slope.f90 1320 2014-03-20 08:40:49Z raasch $ |
---|
32 | ! |
---|
33 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
34 | ! code put under GPL (PALM 3.9) |
---|
35 | ! |
---|
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! |
---|
46 | !------------------------------------------------------------------------------! |
---|
47 | |
---|
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 | |
---|
66 | USE pegrid |
---|
67 | |
---|
68 | |
---|
69 | IMPLICIT NONE |
---|
70 | |
---|
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 !: |
---|
81 | |
---|
82 | ! |
---|
83 | !-- Calculate reference temperature field needed for computing buoyancy |
---|
84 | ALLOCATE( pt_slope_ref(nzb:nzt+1,nxlg:nxrg) ) |
---|
85 | |
---|
86 | DO i = nxlg, nxrg |
---|
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 |
---|
128 | DO j = nysg, nyng |
---|
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 |
---|
143 | ENDDO |
---|
144 | |
---|
145 | #if defined( __parallel ) |
---|
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 ) |
---|
149 | #else |
---|
150 | pt_init = pt_init_local |
---|
151 | #endif |
---|
152 | |
---|
153 | pt_init = pt_init / ngp_2dh(0) |
---|
154 | DEALLOCATE( pt_init_local ) |
---|
155 | |
---|
156 | ENDIF |
---|
157 | |
---|
158 | END SUBROUTINE init_slope |
---|