source: palm/trunk/SOURCE/advec_s_up.f90 @ 4009

Last change on this file since 4009 was 3927, checked in by raasch, 6 years ago

pointer attribute removed from scalar 3d-array for performance reasons

  • Property svn:keywords set to Id
File size: 8.7 KB
RevLine 
[1873]1!> @file advec_s_up.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!
[3655]17! Copyright 1997-2019 Leibniz Universitaet Hannover
[2000]18!------------------------------------------------------------------------------!
[1036]19!
[484]20! Current revisions:
[1]21! -----------------
[1354]22!
[2233]23!
[1321]24! Former revisions:
25! -----------------
26! $Id: advec_s_up.f90 3927 2019-04-23 13:24:29Z raasch $
[3927]27! pointer attribute removed from scalar 3d-array for performance reasons
28!
29! 3665 2019-01-10 08:28:24Z raasch
[3665]30! unused variables removed
31!
32! 3655 2019-01-07 16:51:22Z knoop
[3636]33! nopointer option removed
34!
35! 3547 2018-11-21 13:21:24Z suehring
[3547]36! variables documented
37!
38! 3538 2018-11-20 10:55:41Z suehring
[3538]39! Remove unnecessary double-masking of topography
40!
41! 2718 2018-01-02 08:49:38Z maronga
[2716]42! Corrected "Former revisions" section
43!
44! 2696 2017-12-14 17:12:51Z kanani
45! Change in file header (GPL part)
[1321]46!
[2716]47! 2233 2017-05-30 18:08:54Z suehring
48!
[2233]49! 2232 2017-05-30 17:47:52Z suehring
50! topography representation via flags
51!
[2001]52! 2000 2016-08-20 18:09:15Z knoop
53! Forced header and separation lines into 80 columns
54!
[1874]55! 1873 2016-04-18 14:50:06Z maronga
56! Module renamed (removed _mod)
57!
58!
[1851]59! 1850 2016-04-08 13:29:27Z maronga
60! Module renamed
61!
62!
[1683]63! 1682 2015-10-07 23:56:08Z knoop
64! Code annotations made doxygen readable
65!
[1375]66! 1374 2014-04-25 12:55:07Z raasch
67! missing variables added to ONLY list
68!
[1354]69! 1353 2014-04-08 15:21:23Z heinze
70! REAL constants provided with KIND-attribute
71!
[1321]72! 1320 2014-03-20 08:40:49Z raasch
[1320]73! ONLY-attribute added to USE-statements,
74! kind-parameters added to all INTEGER and REAL declaration statements,
75! kinds are defined in new module kinds,
76! revision history before 2012 removed,
77! comment fields (!:) to be used for variable explanations added to
78! all variable declaration statements
[1]79!
[1037]80! 1036 2012-10-22 13:43:42Z raasch
81! code put under GPL (PALM 3.9)
82!
[1011]83! 1010 2012-09-20 07:59:54Z raasch
84! cpp switch __nopointer added for pointer free version
85!
[982]86! 981 2012-08-09 14:57:44Z maronga
87! Typo removed
88!
[1]89! Revision 1.1  1997/08/29 08:54:33  raasch
90! Initial revision
91!
92!
93! Description:
94! ------------
[1682]95!> Advection term for scalar quantities using the Upstream scheme.
96!> NOTE: vertical advection at k=1 still has wrong grid spacing for w>0!
97!>       The same problem occurs for all topography boundaries!
[1]98!------------------------------------------------------------------------------!
[1682]99 MODULE advec_s_up_mod
100 
[1]101
102    PRIVATE
103    PUBLIC advec_s_up
104
105    INTERFACE advec_s_up
106       MODULE PROCEDURE advec_s_up
107       MODULE PROCEDURE advec_s_up_ij
108    END INTERFACE advec_s_up
109
110 CONTAINS
111
112
113!------------------------------------------------------------------------------!
[1682]114! Description:
115! ------------
116!> Call for all grid points
[1]117!------------------------------------------------------------------------------!
118    SUBROUTINE advec_s_up( sk )
119
[1320]120       USE arrays_3d,                                                          &
121           ONLY:  ddzu, tend, u, v, w
[1]122
[1320]123       USE control_parameters,                                                 &
124           ONLY:  u_gtrans, v_gtrans
125
126       USE grid_variables,                                                     &
127           ONLY:  ddx, ddy
128
129       USE indices,                                                            &
[3927]130           ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt
[1320]131
132       USE kinds
133
134
[1]135       IMPLICIT NONE
136
[3547]137       INTEGER(iwp) ::  i !< grid index along x-direction
138       INTEGER(iwp) ::  j !< grid index along y-direction
139       INTEGER(iwp) ::  k !< grid index along z-direction
[1]140
[3547]141       REAL(wp) ::  ukomp !< advection velocity along x-direction
142       REAL(wp) ::  vkomp !< advection velocity along y-direction
143       REAL(wp) ::  wkomp !< advection velocity along z-direction
[3636]144
[3927]145       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  sk !< treated scalar
[1]146
147
148       DO  i = nxl, nxr
149          DO  j = nys, nyn
[2232]150             DO  k = nzb+1, nzt
[1]151!
152!--             x-direction
[1353]153                ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans
154                IF ( ukomp > 0.0_wp )  THEN
[1320]155                   tend(k,j,i) = tend(k,j,i) - ukomp *                         &
[3538]156                                         ( sk(k,j,i) - sk(k,j,i-1) ) * ddx
[1]157                ELSE
[1320]158                   tend(k,j,i) = tend(k,j,i) - ukomp *                         &
[3538]159                                         ( sk(k,j,i+1) - sk(k,j,i) ) * ddx
[1]160                ENDIF
161!
162!--             y-direction
[1353]163                vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans
164                IF ( vkomp > 0.0_wp )  THEN
[1320]165                   tend(k,j,i) = tend(k,j,i) - vkomp *                         &
[3538]166                                         ( sk(k,j,i) - sk(k,j-1,i) ) * ddy
[1]167                ELSE
[1320]168                   tend(k,j,i) = tend(k,j,i) - vkomp *                         &
[3538]169                                         ( sk(k,j+1,i) - sk(k,j,i) ) * ddy
[1]170                ENDIF
171!
172!--             z-direction
[1353]173                wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) )
174                IF ( wkomp > 0.0_wp )  THEN
[1320]175                   tend(k,j,i) = tend(k,j,i) - wkomp *                         &
[3538]176                                         ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k)
[1]177                ELSE
[1320]178                   tend(k,j,i) = tend(k,j,i) - wkomp *                         &
[3538]179                                         ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1)
[1]180                ENDIF
181
182             ENDDO
183          ENDDO
184       ENDDO
185
186    END SUBROUTINE advec_s_up
187
188
189!------------------------------------------------------------------------------!
[1682]190! Description:
191! ------------
192!> Call for grid point i,j
[1]193!------------------------------------------------------------------------------!
194    SUBROUTINE advec_s_up_ij( i, j, sk )
195
[1320]196       USE arrays_3d,                                                          &
197           ONLY:  ddzu, tend, u, v, w
[1]198
[1320]199       USE control_parameters,                                                 &
200           ONLY:  u_gtrans, v_gtrans
201
202       USE grid_variables,                                                     &
203           ONLY:  ddx, ddy
204
205       USE indices,                                                            &
[3927]206           ONLY:  nxlg, nxrg, nyng, nysg, nzb, nzt
[1320]207
208       USE kinds
209
210
[1]211       IMPLICIT NONE
212
[3547]213       INTEGER(iwp) ::  i !< grid index along x-direction
214       INTEGER(iwp) ::  j !< grid index along y-direction
215       INTEGER(iwp) ::  k !< grid index along z-direction
[1]216
[3547]217       REAL(wp) ::  ukomp !< advection velocity along x-direction
218       REAL(wp) ::  vkomp !< advection velocity along y-direction
219       REAL(wp) ::  wkomp !< advection velocity along z-direction
[1320]220       
[3927]221       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  sk !< treated scalar
[1]222
223
[2232]224       DO  k = nzb+1, nzt
[1]225!
226!--       x-direction
[1353]227          ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans
228          IF ( ukomp > 0.0_wp )  THEN
[1320]229             tend(k,j,i) = tend(k,j,i) - ukomp *                               &
[3538]230                                         ( sk(k,j,i) - sk(k,j,i-1) ) * ddx
[1]231          ELSE
[1320]232             tend(k,j,i) = tend(k,j,i) - ukomp *                               &
[3538]233                                         ( sk(k,j,i+1) - sk(k,j,i) ) * ddx
[1]234          ENDIF
235!
236!--       y-direction
[1353]237          vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans
238          IF ( vkomp > 0.0_wp )  THEN
[1320]239             tend(k,j,i) = tend(k,j,i) - vkomp *                               &
[3538]240                                         ( sk(k,j,i) - sk(k,j-1,i) ) * ddy
[1]241          ELSE
[1320]242             tend(k,j,i) = tend(k,j,i) - vkomp *                               &
[3538]243                                         ( sk(k,j+1,i) - sk(k,j,i) ) * ddy
[1]244          ENDIF
245!
246!--       z-direction
[1353]247          wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) )
248          IF ( wkomp > 0.0_wp )  THEN
[1320]249             tend(k,j,i) = tend(k,j,i) - wkomp *                               &
[3538]250                                         ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k)
[1]251          ELSE
[1320]252             tend(k,j,i) = tend(k,j,i) - wkomp *                               &
[3538]253                                         ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1)
[1]254          ENDIF
255
256       ENDDO
257
258    END SUBROUTINE advec_s_up_ij
259
260 END MODULE advec_s_up_mod
Note: See TracBrowser for help on using the repository browser.