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