1 | !> @file coriolis.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM. |
---|
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-2017 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: coriolis.f90 2233 2017-05-30 18:08:54Z raasch $ |
---|
27 | ! |
---|
28 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
29 | ! Adjustments to new topography concept |
---|
30 | ! |
---|
31 | ! 2118 2017-01-17 16:38:49Z raasch |
---|
32 | ! OpenACC version of subroutine removed |
---|
33 | ! |
---|
34 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
35 | ! Forced header and separation lines into 80 columns |
---|
36 | ! |
---|
37 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
38 | ! Module renamed (removed _mod) |
---|
39 | ! |
---|
40 | ! |
---|
41 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
42 | ! Module renamed |
---|
43 | ! |
---|
44 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
45 | ! Code annotations made doxygen readable |
---|
46 | ! |
---|
47 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
48 | ! REAL constants provided with KIND-attribute |
---|
49 | ! |
---|
50 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
51 | ! ONLY-attribute added to USE-statements, |
---|
52 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
53 | ! kinds are defined in new module kinds, |
---|
54 | ! revision history before 2012 removed, |
---|
55 | ! comment fields (!:) to be used for variable explanations added to |
---|
56 | ! all variable declaration statements |
---|
57 | ! |
---|
58 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
59 | ! openacc loop and loop vector clauses removed |
---|
60 | ! |
---|
61 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
62 | ! loop index bounds in accelerator version replaced by i_left, i_right, j_south, |
---|
63 | ! j_north |
---|
64 | ! |
---|
65 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
66 | ! code put under GPL (PALM 3.9) |
---|
67 | ! |
---|
68 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
69 | ! accelerator version (*_acc) added |
---|
70 | ! |
---|
71 | ! Revision 1.1 1997/08/29 08:57:38 raasch |
---|
72 | ! Initial revision |
---|
73 | ! |
---|
74 | ! |
---|
75 | ! Description: |
---|
76 | ! ------------ |
---|
77 | !> Computation of all Coriolis terms in the equations of motion. |
---|
78 | !------------------------------------------------------------------------------! |
---|
79 | MODULE coriolis_mod |
---|
80 | |
---|
81 | |
---|
82 | PRIVATE |
---|
83 | PUBLIC coriolis |
---|
84 | |
---|
85 | INTERFACE coriolis |
---|
86 | MODULE PROCEDURE coriolis |
---|
87 | MODULE PROCEDURE coriolis_ij |
---|
88 | END INTERFACE coriolis |
---|
89 | |
---|
90 | CONTAINS |
---|
91 | |
---|
92 | |
---|
93 | !------------------------------------------------------------------------------! |
---|
94 | ! Description: |
---|
95 | ! ------------ |
---|
96 | !> Call for all grid points |
---|
97 | !------------------------------------------------------------------------------! |
---|
98 | SUBROUTINE coriolis( component ) |
---|
99 | |
---|
100 | USE arrays_3d, & |
---|
101 | ONLY: tend, u, ug, v, vg, w |
---|
102 | |
---|
103 | USE control_parameters, & |
---|
104 | ONLY: f, fs, message_string |
---|
105 | |
---|
106 | USE indices, & |
---|
107 | ONLY: nxl, nxlu, nxr, nyn, nys, nysv, nzb, nzt, wall_flags_0 |
---|
108 | |
---|
109 | USE kinds |
---|
110 | |
---|
111 | IMPLICIT NONE |
---|
112 | |
---|
113 | INTEGER(iwp) :: component !< |
---|
114 | INTEGER(iwp) :: i !< running index x direction |
---|
115 | INTEGER(iwp) :: j !< running index y direction |
---|
116 | INTEGER(iwp) :: k !< running index z direction |
---|
117 | |
---|
118 | REAL(wp) :: flag !< flag to mask topography |
---|
119 | ! |
---|
120 | !-- Compute Coriolis terms for the three velocity components |
---|
121 | SELECT CASE ( component ) |
---|
122 | |
---|
123 | ! |
---|
124 | !-- u-component |
---|
125 | CASE ( 1 ) |
---|
126 | DO i = nxlu, nxr |
---|
127 | DO j = nys, nyn |
---|
128 | DO k = nzb+1, nzt |
---|
129 | ! |
---|
130 | !-- Predetermine flag to mask topography |
---|
131 | flag = MERGE( 1.0_wp, 0.0_wp, & |
---|
132 | BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
133 | |
---|
134 | tend(k,j,i) = tend(k,j,i) + f * ( 0.25_wp * & |
---|
135 | ( v(k,j,i-1) + v(k,j,i) + v(k,j+1,i-1) + & |
---|
136 | v(k,j+1,i) ) - vg(k) ) * flag & |
---|
137 | - fs * ( 0.25_wp * & |
---|
138 | ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) + & |
---|
139 | w(k,j,i) ) & |
---|
140 | ) * flag |
---|
141 | ENDDO |
---|
142 | ENDDO |
---|
143 | ENDDO |
---|
144 | |
---|
145 | ! |
---|
146 | !-- v-component |
---|
147 | CASE ( 2 ) |
---|
148 | DO i = nxl, nxr |
---|
149 | DO j = nysv, nyn |
---|
150 | DO k = nzb+1, nzt |
---|
151 | tend(k,j,i) = tend(k,j,i) - f * ( 0.25_wp * & |
---|
152 | ( u(k,j-1,i) + u(k,j,i) + u(k,j-1,i+1) + & |
---|
153 | u(k,j,i+1) ) - ug(k) ) * & |
---|
154 | MERGE( 1.0_wp, 0.0_wp, & |
---|
155 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
156 | ENDDO |
---|
157 | ENDDO |
---|
158 | ENDDO |
---|
159 | |
---|
160 | ! |
---|
161 | !-- w-component |
---|
162 | CASE ( 3 ) |
---|
163 | DO i = nxl, nxr |
---|
164 | DO j = nys, nyn |
---|
165 | DO k = nzb+1, nzt |
---|
166 | tend(k,j,i) = tend(k,j,i) + fs * 0.25_wp * & |
---|
167 | ( u(k,j,i) + u(k+1,j,i) + u(k,j,i+1) + & |
---|
168 | u(k+1,j,i+1) ) * & |
---|
169 | MERGE( 1.0_wp, 0.0_wp, & |
---|
170 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
171 | ENDDO |
---|
172 | ENDDO |
---|
173 | ENDDO |
---|
174 | |
---|
175 | CASE DEFAULT |
---|
176 | |
---|
177 | WRITE( message_string, * ) ' wrong component: ', component |
---|
178 | CALL message( 'coriolis', 'PA0173', 1, 2, 0, 6, 0 ) |
---|
179 | |
---|
180 | END SELECT |
---|
181 | |
---|
182 | END SUBROUTINE coriolis |
---|
183 | |
---|
184 | |
---|
185 | !------------------------------------------------------------------------------! |
---|
186 | ! Description: |
---|
187 | ! ------------ |
---|
188 | !> Call for grid point i,j |
---|
189 | !------------------------------------------------------------------------------! |
---|
190 | SUBROUTINE coriolis_ij( i, j, component ) |
---|
191 | |
---|
192 | USE arrays_3d, & |
---|
193 | ONLY: tend, u, ug, v, vg, w |
---|
194 | |
---|
195 | USE control_parameters, & |
---|
196 | ONLY: f, fs, message_string |
---|
197 | |
---|
198 | USE indices, & |
---|
199 | ONLY: nzb, nzt, wall_flags_0 |
---|
200 | |
---|
201 | USE kinds |
---|
202 | |
---|
203 | IMPLICIT NONE |
---|
204 | |
---|
205 | INTEGER(iwp) :: component !< |
---|
206 | INTEGER(iwp) :: i !< running index x direction |
---|
207 | INTEGER(iwp) :: j !< running index y direction |
---|
208 | INTEGER(iwp) :: k !< running index z direction |
---|
209 | |
---|
210 | REAL(wp) :: flag !< flag to mask topography |
---|
211 | |
---|
212 | ! |
---|
213 | !-- Compute Coriolis terms for the three velocity components |
---|
214 | SELECT CASE ( component ) |
---|
215 | |
---|
216 | ! |
---|
217 | !-- u-component |
---|
218 | CASE ( 1 ) |
---|
219 | DO k = nzb+1, nzt |
---|
220 | ! |
---|
221 | !-- Predetermine flag to mask topography |
---|
222 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 1 ) ) |
---|
223 | |
---|
224 | tend(k,j,i) = tend(k,j,i) + f * ( 0.25_wp * & |
---|
225 | ( v(k,j,i-1) + v(k,j,i) + v(k,j+1,i-1) + & |
---|
226 | v(k,j+1,i) ) - vg(k) ) * flag & |
---|
227 | - fs * ( 0.25_wp * & |
---|
228 | ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) + & |
---|
229 | w(k,j,i) ) ) * flag |
---|
230 | ENDDO |
---|
231 | |
---|
232 | ! |
---|
233 | !-- v-component |
---|
234 | CASE ( 2 ) |
---|
235 | DO k = nzb+1, nzt |
---|
236 | tend(k,j,i) = tend(k,j,i) - f * ( 0.25_wp * & |
---|
237 | ( u(k,j-1,i) + u(k,j,i) + u(k,j-1,i+1) + & |
---|
238 | u(k,j,i+1) ) - ug(k) ) * & |
---|
239 | MERGE( 1.0_wp, 0.0_wp, & |
---|
240 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
241 | ENDDO |
---|
242 | |
---|
243 | ! |
---|
244 | !-- w-component |
---|
245 | CASE ( 3 ) |
---|
246 | DO k = nzb+1, nzt |
---|
247 | tend(k,j,i) = tend(k,j,i) + fs * 0.25_wp * & |
---|
248 | ( u(k,j,i) + u(k+1,j,i) + u(k,j,i+1) + & |
---|
249 | u(k+1,j,i+1) ) * & |
---|
250 | MERGE( 1.0_wp, 0.0_wp, & |
---|
251 | BTEST( wall_flags_0(k,j,i), 3 ) ) |
---|
252 | ENDDO |
---|
253 | |
---|
254 | CASE DEFAULT |
---|
255 | |
---|
256 | WRITE( message_string, * ) ' wrong component: ', component |
---|
257 | CALL message( 'coriolis', 'PA0173', 1, 2, 0, 6, 0 ) |
---|
258 | |
---|
259 | END SELECT |
---|
260 | |
---|
261 | END SUBROUTINE coriolis_ij |
---|
262 | |
---|
263 | END MODULE coriolis_mod |
---|