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

Last change on this file since 1036 was 1036, checked in by raasch, 11 years ago

code has been put under the GNU General Public License (v3)

  • Property svn:keywords set to Id
File size: 9.1 KB
Line 
1 MODULE coriolis_mod
2
3!--------------------------------------------------------------------------------!
4! This file is part of PALM.
5!
6! PALM is free software: you can redistribute it and/or modify it under the terms
7! of the GNU General Public License as published by the Free Software Foundation,
8! either version 3 of the License, or (at your option) any later 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-2012  Leibniz University Hannover
18!--------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: coriolis.f90 1036 2012-10-22 13:43:42Z raasch $
27!
28! 1015 2012-09-27 09:23:24Z raasch
29! accelerator version (*_acc) added
30!
31! 254 2009-03-05 15:33:42Z heinze
32! Output of messages replaced by message handling routine.
33!
34! 106 2007-08-16 14:30:26Z raasch
35! loops for u and v are starting from index nxlu, nysv, respectively (needed
36! for non-cyclic boundary conditions)
37!
38! 75 2007-03-22 09:54:05Z raasch
39! uxrp, vynp eliminated
40!
41! RCS Log replace by Id keyword, revision history cleaned up
42!
43! Revision 1.12  2006/02/23 10:08:57  raasch
44! nzb_2d replaced by nzb_u/v/w_inner
45!
46! Revision 1.1  1997/08/29 08:57:38  raasch
47! Initial revision
48!
49!
50! Description:
51! ------------
52! Computation of all Coriolis terms in the equations of motion.
53!------------------------------------------------------------------------------!
54
55    PRIVATE
56    PUBLIC coriolis, coriolis_acc
57
58    INTERFACE coriolis
59       MODULE PROCEDURE coriolis
60       MODULE PROCEDURE coriolis_ij
61    END INTERFACE coriolis
62
63    INTERFACE coriolis_acc
64       MODULE PROCEDURE coriolis_acc
65    END INTERFACE coriolis_acc
66
67 CONTAINS
68
69
70!------------------------------------------------------------------------------!
71! Call for all grid points
72!------------------------------------------------------------------------------!
73    SUBROUTINE coriolis( component )
74
75       USE arrays_3d
76       USE control_parameters
77       USE indices
78       USE pegrid
79
80       IMPLICIT NONE
81
82       INTEGER ::  component, i, j, k
83
84
85!
86!--    Compute Coriolis terms for the three velocity components
87       SELECT CASE ( component )
88
89!
90!--       u-component
91          CASE ( 1 )
92             DO  i = nxlu, nxr
93                DO  j = nys, nyn
94                   DO  k = nzb_u_inner(j,i)+1, nzt
95                      tend(k,j,i) = tend(k,j,i) + f  *    ( 0.25 *            &
96                                   ( v(k,j,i-1) + v(k,j,i) + v(k,j+1,i-1) +   &
97                                     v(k,j+1,i) ) - vg(k) )                   &
98                                             - fs *    ( 0.25 *               &
99                                   ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) + &
100                                     w(k,j,i)   ) &
101                                                          )
102                   ENDDO
103                ENDDO
104             ENDDO
105
106!
107!--       v-component
108          CASE ( 2 )
109             DO  i = nxl, nxr
110                DO  j = nysv, nyn
111                   DO  k = nzb_v_inner(j,i)+1, nzt
112                      tend(k,j,i) = tend(k,j,i) - f *     ( 0.25 *          &
113                                   ( u(k,j-1,i) + u(k,j,i) + u(k,j-1,i+1) + &
114                                     u(k,j,i+1) ) - ug(k) )
115                   ENDDO
116                ENDDO
117             ENDDO
118
119!
120!--       w-component
121          CASE ( 3 )
122             DO  i = nxl, nxr
123                DO  j = nys, nyn
124                   DO  k = nzb_w_inner(j,i)+1, nzt
125                      tend(k,j,i) = tend(k,j,i) + fs * 0.25 *             &
126                                   ( u(k,j,i) + u(k+1,j,i) + u(k,j,i+1) + &
127                                     u(k+1,j,i+1) )
128                   ENDDO
129                ENDDO
130             ENDDO
131
132          CASE DEFAULT
133
134             WRITE( message_string, * ) ' wrong component: ', component
135             CALL message( 'coriolis', 'PA0173', 1, 2, 0, 6, 0 )
136
137       END SELECT
138
139    END SUBROUTINE coriolis
140
141
142!------------------------------------------------------------------------------!
143! Call for all grid points - accelerator version
144!------------------------------------------------------------------------------!
145    SUBROUTINE coriolis_acc( component )
146
147       USE arrays_3d
148       USE control_parameters
149       USE indices
150       USE pegrid
151
152       IMPLICIT NONE
153
154       INTEGER ::  component, i, j, k
155
156
157!
158!--    Compute Coriolis terms for the three velocity components
159       SELECT CASE ( component )
160
161!
162!--       u-component
163          CASE ( 1 )
164             !$acc  kernels present( nzb_u_inner, tend, v, vg, w )
165             !$acc  loop
166             DO  i = nxlu, nxr
167                DO  j = nys, nyn
168                   !$acc loop vector( 32 )
169                   DO  k = 1, nzt
170                      IF  ( k > nzb_u_inner(j,i) )  THEN
171                         tend(k,j,i) = tend(k,j,i) + f  *    ( 0.25 *          &
172                                      ( v(k,j,i-1) + v(k,j,i) + v(k,j+1,i-1) + &
173                                        v(k,j+1,i) ) - vg(k) )                 &
174                                                - fs *    ( 0.25 *             &
175                                      ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) &
176                                        + w(k,j,i)   )                         &
177                                                             )
178                      ENDIF
179                   ENDDO
180                ENDDO
181             ENDDO
182             !$acc end kernels
183
184!
185!--       v-component
186          CASE ( 2 )
187             !$acc  kernels present( nzb_v_inner, tend, u, ug )
188             !$acc  loop
189             DO  i = nxl, nxr
190                DO  j = nysv, nyn
191                   !$acc loop vector( 32 )
192                   DO  k = 1, nzt
193                      IF  ( k > nzb_v_inner(j,i) )  THEN
194                         tend(k,j,i) = tend(k,j,i) - f *     ( 0.25 *          &
195                                      ( u(k,j-1,i) + u(k,j,i) + u(k,j-1,i+1) + &
196                                        u(k,j,i+1) ) - ug(k) )
197                      ENDIF
198                   ENDDO
199                ENDDO
200             ENDDO
201             !$acc end kernels
202
203!
204!--       w-component
205          CASE ( 3 )
206             !$acc  kernels present( nzb_w_inner, tend, u )
207             !$acc  loop
208             DO  i = nxl, nxr
209                DO  j = nys, nyn
210                   !$acc loop vector( 32 )
211                   DO  k = 1, nzt
212                      IF  ( k > nzb_w_inner(j,i) )  THEN
213                         tend(k,j,i) = tend(k,j,i) + fs * 0.25 *             &
214                                      ( u(k,j,i) + u(k+1,j,i) + u(k,j,i+1) + &
215                                        u(k+1,j,i+1) )
216                      ENDIF
217                   ENDDO
218                ENDDO
219             ENDDO
220             !$acc end kernels
221
222          CASE DEFAULT
223
224             WRITE( message_string, * ) ' wrong component: ', component
225             CALL message( 'coriolis', 'PA0173', 1, 2, 0, 6, 0 )
226
227       END SELECT
228
229    END SUBROUTINE coriolis_acc
230
231
232!------------------------------------------------------------------------------!
233! Call for grid point i,j
234!------------------------------------------------------------------------------!
235    SUBROUTINE coriolis_ij( i, j, component )
236
237       USE arrays_3d
238       USE control_parameters
239       USE indices
240       USE pegrid
241
242       IMPLICIT NONE
243
244       INTEGER ::  component, i, j, k
245
246!
247!--    Compute Coriolis terms for the three velocity components
248       SELECT CASE ( component )
249
250!
251!--       u-component
252          CASE ( 1 )
253             DO  k = nzb_u_inner(j,i)+1, nzt
254                tend(k,j,i) = tend(k,j,i) + f  *    ( 0.25 *               &
255                                ( v(k,j,i-1) + v(k,j,i) + v(k,j+1,i-1) +   &
256                                  v(k,j+1,i) ) - vg(k) )                   &
257                                          - fs *    ( 0.25 *               &
258                                ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) + &
259                                  w(k,j,i)   ) &
260                                                    )
261             ENDDO
262
263!
264!--       v-component
265          CASE ( 2 )
266             DO  k = nzb_v_inner(j,i)+1, nzt
267                tend(k,j,i) = tend(k,j,i) - f *     ( 0.25 *             &
268                                ( u(k,j-1,i) + u(k,j,i) + u(k,j-1,i+1) + &
269                                  u(k,j,i+1) ) - ug(k) )
270             ENDDO
271
272!
273!--       w-component
274          CASE ( 3 )
275             DO  k = nzb_w_inner(j,i)+1, nzt
276                tend(k,j,i) = tend(k,j,i) + fs * 0.25 * &
277                                ( u(k,j,i) + u(k+1,j,i) + u(k,j,i+1) + &
278                                  u(k+1,j,i+1) )
279             ENDDO
280
281          CASE DEFAULT
282
283             WRITE( message_string, * ) ' wrong component: ', component
284             CALL message( 'coriolis', 'PA0173', 1, 2, 0, 6, 0 )
285
286       END SELECT
287
288    END SUBROUTINE coriolis_ij
289
290 END MODULE coriolis_mod
Note: See TracBrowser for help on using the repository browser.