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