source: palm/trunk/SOURCE/advec_w_up.f90 @ 4743

Last change on this file since 4743 was 4509, checked in by raasch, 5 years ago

files re-formatted to follow the PALM coding standard

  • Property svn:keywords set to Id
File size: 6.2 KB
RevLine 
[1873]1!> @file advec_w_up.f90
[4509]2!--------------------------------------------------------------------------------------------------!
[2696]3! This file is part of the PALM model system.
[1036]4!
[4509]5! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General
6! Public License as published by the Free Software Foundation, either version 3 of the License, or
7! (at your option) any later version.
[1036]8!
[4509]9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11! Public License for more details.
[1036]12!
[4509]13! You should have received a copy of the GNU General Public License along with PALM. If not, see
14! <http://www.gnu.org/licenses/>.
[1036]15!
[4360]16! Copyright 1997-2020 Leibniz Universitaet Hannover
[4509]17!--------------------------------------------------------------------------------------------------!
[1036]18!
[484]19! Current revisions:
[1]20! -----------------
[1354]21!
[2233]22!
[1321]23! Former revisions:
24! -----------------
25! $Id: advec_w_up.f90 4509 2020-04-26 15:57:55Z suehring $
[4509]26! file re-formatted to follow the PALM coding standard
27!
28! 4360 2020-01-07 11:25:50Z suehring
[4182]29! Corrected "Former revisions" section
30!
31! 3655 2019-01-07 16:51:22Z knoop
[3547]32! variables documented
[1321]33!
[4182]34! Revision 1.1  1997/08/29 08:56:33  raasch
35! Initial revision
36!
37!
[1]38! Description:
39! ------------
[1682]40!> Advection term for the w velocity-component using upstream scheme.
41!> NOTE: vertical advection at k=1 still has wrong grid spacing for w>0
42!>       The same problem occurs for all topography boundaries!
[4509]43!--------------------------------------------------------------------------------------------------!
[1682]44 MODULE advec_w_up_mod
45 
[1]46
47    PRIVATE
48    PUBLIC advec_w_up
49
50    INTERFACE advec_w_up
51       MODULE PROCEDURE advec_w_up
52       MODULE PROCEDURE advec_w_up_ij
53    END INTERFACE advec_w_up
54
55 CONTAINS
56
57
[4509]58!--------------------------------------------------------------------------------------------------!
[1682]59! Description:
60! ------------
61!> Call for all grid points
[4509]62!--------------------------------------------------------------------------------------------------!
63 SUBROUTINE advec_w_up
[1]64
[4509]65    USE arrays_3d,                                                                                 &
66        ONLY:  ddzw, tend, u, v, w
[1]67
[4509]68    USE control_parameters,                                                                        &
69        ONLY:  u_gtrans, v_gtrans
[1320]70
[4509]71    USE grid_variables,                                                                            &
72        ONLY:  ddx, ddy
[1320]73
[4509]74    USE indices,                                                                                   &
75        ONLY:  nxl, nxr, nyn, nys, nzb, nzt
[1320]76
[4509]77    USE kinds
[1320]78
79
[4509]80    IMPLICIT NONE
[1]81
[4509]82    INTEGER(iwp) ::  i !< grid index along x-direction
83    INTEGER(iwp) ::  j !< grid index along y-direction
84    INTEGER(iwp) ::  k !< grid index along z-direction
[1]85
[4509]86    REAL(wp) ::  ukomp !< advection velocity along x-direction
87    REAL(wp) ::  vkomp !< advection velocity along y-direction
[1]88
[1320]89
[4509]90    DO  i = nxl, nxr
91       DO  j = nys, nyn
92          DO  k = nzb+1, nzt-1
[1]93!
[4509]94!--          x-direction
95             ukomp = 0.25_wp * ( u(k,j,i)   + u(k,j,i+1) + u(k+1,j,i) + u(k+1,j,i+1) ) - u_gtrans
96             IF ( ukomp > 0.0_wp )  THEN
97                tend(k,j,i) = tend(k,j,i) - ukomp * ( w(k,j,i) - w(k,j,i-1) ) * ddx
98             ELSE
99                tend(k,j,i) = tend(k,j,i) - ukomp * ( w(k,j,i+1) - w(k,j,i) ) * ddx
100             ENDIF
[1]101!
[4509]102!--          y-direction
103             vkomp = 0.25_wp * ( v(k,j,i) + v(k,j+1,i) + v(k+1,j,i) + v(k+1,j+1,i) ) - v_gtrans
104             IF ( vkomp > 0.0_wp )  THEN
105                tend(k,j,i) = tend(k,j,i) - vkomp * ( w(k,j,i) - w(k,j-1,i) ) * ddy
106             ELSE
107                tend(k,j,i) = tend(k,j,i) - vkomp * ( w(k,j+1,i) - w(k,j,i) ) * ddy
108             ENDIF
[1]109!
[4509]110!--          z-direction
111             IF ( w(k,j,i) > 0.0_wp )  THEN
112                tend(k,j,i) = tend(k,j,i) - w(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k)
113             ELSE
114                tend(k,j,i) = tend(k,j,i) - w(k,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1)
115             ENDIF
[1]116
117          ENDDO
118       ENDDO
[4509]119    ENDDO
[1]120
[4509]121 END SUBROUTINE advec_w_up
[1]122
123
[4509]124!--------------------------------------------------------------------------------------------------!
[1682]125! Description:
126! ------------
127!> Call for grid point i,j
[4509]128!--------------------------------------------------------------------------------------------------!
129 SUBROUTINE advec_w_up_ij( i, j )
[1]130
[4509]131    USE arrays_3d,                                                                                 &
132        ONLY:  ddzw, tend, u, v, w
[1]133
[4509]134    USE control_parameters,                                                                        &
135        ONLY:  u_gtrans, v_gtrans
[1320]136
[4509]137    USE grid_variables,                                                                            &
138        ONLY:  ddx, ddy
[1320]139
[4509]140    USE indices,                                                                                   &
141        ONLY:  nzb, nzt
[1320]142
[4509]143    USE kinds
[1320]144
145
[4509]146    IMPLICIT NONE
[1]147
[4509]148    INTEGER(iwp) ::  i !< grid index along x-direction
149    INTEGER(iwp) ::  j !< grid index along y-direction
150    INTEGER(iwp) ::  k !< grid index along z-direction
[1]151
[4509]152    REAL(wp) ::  ukomp !< advection velocity along x-direction
153    REAL(wp) ::  vkomp !< advection velocity along y-direction
[1]154
[1320]155
[4509]156    DO  k = nzb+1, nzt-1
[1]157!
[4509]158!--    x-direction
159       ukomp = 0.25_wp * ( u(k,j,i) + u(k,j,i+1) + u(k+1,j,i) + u(k+1,j,i+1) ) - u_gtrans
160       IF ( ukomp > 0.0_wp )  THEN
161          tend(k,j,i) = tend(k,j,i) - ukomp * ( w(k,j,i) - w(k,j,i-1) ) * ddx
162       ELSE
163          tend(k,j,i) = tend(k,j,i) - ukomp * ( w(k,j,i+1) - w(k,j,i) ) * ddx
164       ENDIF
[1]165!
[4509]166!--    y-direction
167       vkomp = 0.25_wp * ( v(k,j,i) + v(k,j+1,i) + v(k+1,j,i) + v(k+1,j+1,i) ) - v_gtrans
168       IF ( vkomp > 0.0_wp )  THEN
169          tend(k,j,i) = tend(k,j,i) - vkomp * ( w(k,j,i) - w(k,j-1,i) ) * ddy
170       ELSE
171          tend(k,j,i) = tend(k,j,i) - vkomp * ( w(k,j+1,i) - w(k,j,i) ) * ddy
172       ENDIF
[1]173!
[4509]174!--    z-direction
175       IF ( w(k,j,i) > 0.0_wp )  THEN
176          tend(k,j,i) = tend(k,j,i) - w(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k)
177       ELSE
178          tend(k,j,i) = tend(k,j,i) - w(k,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1)
179       ENDIF
[1]180
[4509]181    ENDDO
[1]182
[4509]183 END SUBROUTINE advec_w_up_ij
[1]184
185 END MODULE advec_w_up_mod
Note: See TracBrowser for help on using the repository browser.