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

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

asynchronous transfer of ghost point data for acc-optimized version

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