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

Last change on this file since 2701 was 2696, checked in by kanani, 6 years ago

Merge of branch palm4u into trunk

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