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