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

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

r1028 documented

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