source: palm/trunk/SOURCE/coriolis.f90 @ 4332

Last change on this file since 4332 was 4329, checked in by motisi, 4 years ago

Renamed wall_flags_0 to wall_flags_static_0

  • Property svn:keywords set to Id
File size: 11.4 KB
Line 
1!> @file coriolis.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: coriolis.f90 4329 2019-12-10 15:46:36Z suehring $
27! Renamed wall_flags_0 to wall_flags_static_0
28!
29! 4196 2019-08-29 11:02:06Z gronemeier
30! Consider rotation of model domain
31!
32! 4182 2019-08-22 15:20:23Z scharf
33! Corrected "Former revisions" section
34!
35! 3655 2019-01-07 16:51:22Z knoop
36! OpenACC port for SPEC
37!
38! Revision 1.1  1997/08/29 08:57:38  raasch
39! Initial revision
40!
41!
42! Description:
43! ------------
44!> Computation of all Coriolis terms in the equations of motion.
45!>
46!> @note In this routine the topography is masked, even though this
47!>       is again done in prognostic_equations. However, omitting the masking
48!>       here lead to slightly different results. Reason unknown.
49!------------------------------------------------------------------------------!
50 MODULE coriolis_mod
51 
52
53    PRIVATE
54    PUBLIC coriolis
55
56    INTERFACE coriolis
57       MODULE PROCEDURE coriolis
58       MODULE PROCEDURE coriolis_ij
59    END INTERFACE coriolis
60
61 CONTAINS
62
63
64!------------------------------------------------------------------------------!
65! Description:
66! ------------
67!> Call for all grid points
68!------------------------------------------------------------------------------!
69    SUBROUTINE coriolis( component )
70
71       USE arrays_3d,                                                          &
72           ONLY:  tend, u, ug, v, vg, w 
73
74       USE basic_constants_and_equations_mod,                                  &
75           ONLY:  pi
76
77       USE control_parameters,                                                 &
78           ONLY:  f, fs, message_string, rotation_angle
79           
80       USE indices,                                                            &
81           ONLY:  nxl, nxlu, nxr, nyn, nys, nysv, nzb, nzt, wall_flags_static_0
82                   
83       USE kinds
84
85       IMPLICIT NONE
86
87       INTEGER(iwp) ::  component      !< component of momentum equation
88       INTEGER(iwp) ::  i              !< running index x direction
89       INTEGER(iwp) ::  j              !< running index y direction
90       INTEGER(iwp) ::  k              !< running index z direction
91
92       REAL(wp)     ::  cos_rot_angle  !< cosine of model rotation angle
93       REAL(wp)     ::  flag           !< flag to mask topography
94       REAL(wp)     ::  sin_rot_angle  !< sine of model rotation angle
95
96!
97!--    Precalculate cosine and sine of rotation angle
98       cos_rot_angle = COS( rotation_angle * pi / 180.0_wp )
99       sin_rot_angle = SIN( rotation_angle * pi / 180.0_wp )
100
101!
102!--    Compute Coriolis terms for the three velocity components
103       SELECT CASE ( component )
104
105!
106!--       u-component
107          CASE ( 1 )
108             !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k, flag) &
109             !$ACC PRESENT(wall_flags_static_0) &
110             !$ACC PRESENT(v, w, vg) &
111             !$ACC PRESENT(tend)
112             DO  i = nxlu, nxr
113                DO  j = nys, nyn
114                   DO  k = nzb+1, nzt
115!
116!--                   Predetermine flag to mask topography
117                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 1 ) )
118
119                      tend(k,j,i) = tend(k,j,i) + flag *                                           &
120                            ( f                                                                    &
121                              * ( 0.25_wp * ( v(k,j,i-1) + v(k,j,i) + v(k,j+1,i-1) + v(k,j+1,i) )  &
122                                - vg(k) )                                                          &
123                            - fs * cos_rot_angle                                                   &
124                              * 0.25_wp * ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) + w(k,j,i) )    &
125                            )
126                   ENDDO
127                ENDDO
128             ENDDO
129
130!
131!--       v-component
132          CASE ( 2 )
133             !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k, flag) &
134             !$ACC PRESENT(wall_flags_static_0) &
135             !$ACC PRESENT(u, w, ug) &
136             !$ACC PRESENT(tend)
137             DO  i = nxl, nxr
138                DO  j = nysv, nyn
139                   DO  k = nzb+1, nzt
140!
141!--                   Predetermine flag to mask topography
142                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 2 ) )
143
144                      tend(k,j,i) = tend(k,j,i) - flag *                                           &
145                            ( f                                                                    &
146                              * ( 0.25_wp * ( u(k,j-1,i) + u(k,j,i) + u(k,j-1,i+1) + u(k,j,i+1) )  &
147                                - ug(k) )                                                          &
148                            + fs * sin_rot_angle                                                   &
149                              * 0.25_wp * ( w(k,j,i) + w(k-1,j,i) + w(k,j-1,i) + w(k-1,j-1,i) )    &
150                            )
151                   ENDDO
152                ENDDO
153             ENDDO
154
155!
156!--       w-component
157          CASE ( 3 )
158             !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k, flag) &
159             !$ACC PRESENT(wall_flags_static_0) &
160             !$ACC PRESENT(u, v) &
161             !$ACC PRESENT(tend)
162             DO  i = nxl, nxr
163                DO  j = nys, nyn
164                   DO  k = nzb+1, nzt
165!
166!--                   Predetermine flag to mask topography
167                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 3 ) )
168
169                      tend(k,j,i) = tend(k,j,i)                                                 &
170                                  + fs * 0.25_wp * flag                                         &
171                                    * ( cos_rot_angle                                           &
172                                        * ( u(k,j,i) + u(k+1,j,i) + u(k,j,i+1) + u(k+1,j,i+1) ) &
173                                      + sin_rot_angle                                           &
174                                        * ( v(k,j,i) + v(k+1,j,i) + v(k,j+1,i) + v(k+1,j+1,i) ) &
175                                      )
176                   ENDDO
177                ENDDO
178             ENDDO
179
180          CASE DEFAULT
181
182             WRITE( message_string, * ) ' wrong component: ', component
183             CALL message( 'coriolis', 'PA0173', 1, 2, 0, 6, 0 )
184
185       END SELECT
186
187    END SUBROUTINE coriolis
188
189
190!------------------------------------------------------------------------------!
191! Description:
192! ------------
193!> Call for grid point i,j
194!------------------------------------------------------------------------------!
195    SUBROUTINE coriolis_ij( i, j, component )
196
197       USE arrays_3d,                                                          &
198           ONLY:  tend, u, ug, v, vg, w 
199
200       USE basic_constants_and_equations_mod,                                  &
201           ONLY:  pi
202
203       USE control_parameters,                                                 &
204           ONLY:  f, fs, message_string, rotation_angle
205           
206       USE indices,                                                            &
207           ONLY:  nzb, nzt, wall_flags_static_0
208           
209       USE kinds
210
211       IMPLICIT NONE
212
213       INTEGER(iwp) ::  component  !< component of momentum equation
214       INTEGER(iwp) ::  i          !< running index x direction
215       INTEGER(iwp) ::  j          !< running index y direction
216       INTEGER(iwp) ::  k          !< running index z direction
217
218       REAL(wp)     ::  cos_rot_angle  !< cosine of model rotation angle
219       REAL(wp)     ::  flag           !< flag to mask topography
220       REAL(wp)     ::  sin_rot_angle  !< sine of model rotation angle
221
222!
223!--    Precalculate cosine and sine of rotation angle
224       cos_rot_angle = COS( rotation_angle * pi / 180.0_wp )
225       sin_rot_angle = SIN( rotation_angle * pi / 180.0_wp )
226
227!
228!--    Compute Coriolis terms for the three velocity components
229       SELECT CASE ( component )
230
231!
232!--       u-component
233          CASE ( 1 )
234             DO  k = nzb+1, nzt
235!
236!--             Predetermine flag to mask topography
237                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 1 ) )
238
239                tend(k,j,i) = tend(k,j,i) + flag *                                                 &
240                            ( f                                                                    &
241                              * ( 0.25_wp * ( v(k,j,i-1) + v(k,j,i) + v(k,j+1,i-1) + v(k,j+1,i) )  &
242                                - vg(k) )                                                          &
243                            - fs * cos_rot_angle                                                   &
244                              * 0.25_wp * ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) + w(k,j,i) )    &
245                            )
246             ENDDO
247
248!
249!--       v-component
250          CASE ( 2 )
251             DO  k = nzb+1, nzt
252!
253!--             Predetermine flag to mask topography
254                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 2 ) )
255
256                tend(k,j,i) = tend(k,j,i) - flag *                                                 &
257                            ( f                                                                    &
258                              * ( 0.25_wp * ( u(k,j-1,i) + u(k,j,i) + u(k,j-1,i+1) + u(k,j,i+1) )  &
259                                - ug(k) )                                                          &
260                            + fs * sin_rot_angle                                                   &
261                              * 0.25_wp * ( w(k,j,i) + w(k-1,j,i) + w(k,j-1,i) + w(k-1,j-1,i) )    &
262                            )
263             ENDDO
264
265!
266!--       w-component
267          CASE ( 3 )
268             DO  k = nzb+1, nzt
269!
270!--             Predetermine flag to mask topography
271                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 3 ) )
272
273                tend(k,j,i) = tend(k,j,i)                                                 &
274                            + fs * 0.25_wp * flag                                         &
275                              * ( cos_rot_angle                                           &
276                                  * ( u(k,j,i) + u(k+1,j,i) + u(k,j,i+1) + u(k+1,j,i+1) ) &
277                                + sin_rot_angle                                           &
278                                  * ( v(k,j,i) + v(k+1,j,i) + v(k,j+1,i) + v(k+1,j+1,i) ) &
279                                )
280             ENDDO
281
282          CASE DEFAULT
283
284             WRITE( message_string, * ) ' wrong component: ', component
285             CALL message( 'coriolis', 'PA0173', 1, 2, 0, 6, 0 )
286
287       END SELECT
288
289    END SUBROUTINE coriolis_ij
290
291 END MODULE coriolis_mod
Note: See TracBrowser for help on using the repository browser.