1 | !> @file advec_s_up.f90 |
---|
2 | !--------------------------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
4 | ! |
---|
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. |
---|
8 | ! |
---|
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. |
---|
12 | ! |
---|
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/>. |
---|
15 | ! |
---|
16 | ! Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! Current revisions: |
---|
20 | ! ----------------- |
---|
21 | ! |
---|
22 | ! |
---|
23 | ! Former revisions: |
---|
24 | ! ----------------- |
---|
25 | ! $Id: advec_s_up.f90 4488 2020-04-03 11:34:29Z oliver.maas $ |
---|
26 | ! file re-formatted to follow the PALM coding standard |
---|
27 | ! |
---|
28 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
29 | ! Corrected "Former revisions" section |
---|
30 | ! |
---|
31 | ! 3927 2019-04-23 13:24:29Z raasch |
---|
32 | ! pointer attribute removed from scalar 3d-array for performance reasons |
---|
33 | ! |
---|
34 | ! 3665 2019-01-10 08:28:24Z raasch |
---|
35 | ! unused variables removed |
---|
36 | ! |
---|
37 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
38 | ! nopointer option removed |
---|
39 | ! |
---|
40 | ! Revision 1.1 1997/08/29 08:54:33 raasch |
---|
41 | ! Initial revision |
---|
42 | ! |
---|
43 | ! |
---|
44 | ! Description: |
---|
45 | ! ------------ |
---|
46 | !> Advection term for scalar quantities using the Upstream scheme. |
---|
47 | !> NOTE: vertical advection at k=1 still has wrong grid spacing for w>0! |
---|
48 | !> The same problem occurs for all topography boundaries! |
---|
49 | !--------------------------------------------------------------------------------------------------! |
---|
50 | MODULE advec_s_up_mod |
---|
51 | |
---|
52 | |
---|
53 | PRIVATE |
---|
54 | PUBLIC advec_s_up |
---|
55 | |
---|
56 | INTERFACE advec_s_up |
---|
57 | MODULE PROCEDURE advec_s_up |
---|
58 | MODULE PROCEDURE advec_s_up_ij |
---|
59 | END INTERFACE advec_s_up |
---|
60 | |
---|
61 | CONTAINS |
---|
62 | |
---|
63 | |
---|
64 | !--------------------------------------------------------------------------------------------------! |
---|
65 | ! Description: |
---|
66 | ! ------------ |
---|
67 | !> Call for all grid points |
---|
68 | !--------------------------------------------------------------------------------------------------! |
---|
69 | SUBROUTINE advec_s_up( sk ) |
---|
70 | |
---|
71 | USE arrays_3d, & |
---|
72 | ONLY: ddzu, tend, u, v, w |
---|
73 | |
---|
74 | USE control_parameters, & |
---|
75 | ONLY: u_gtrans, v_gtrans |
---|
76 | |
---|
77 | USE grid_variables, & |
---|
78 | ONLY: ddx, ddy |
---|
79 | |
---|
80 | USE indices, & |
---|
81 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt |
---|
82 | |
---|
83 | USE kinds |
---|
84 | |
---|
85 | |
---|
86 | IMPLICIT NONE |
---|
87 | |
---|
88 | INTEGER(iwp) :: i !< grid index along x-direction |
---|
89 | INTEGER(iwp) :: j !< grid index along y-direction |
---|
90 | INTEGER(iwp) :: k !< grid index along z-direction |
---|
91 | |
---|
92 | REAL(wp) :: ukomp !< advection velocity along x-direction |
---|
93 | REAL(wp) :: vkomp !< advection velocity along y-direction |
---|
94 | REAL(wp) :: wkomp !< advection velocity along z-direction |
---|
95 | |
---|
96 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< treated scalar |
---|
97 | |
---|
98 | |
---|
99 | DO i = nxl, nxr |
---|
100 | DO j = nys, nyn |
---|
101 | DO k = nzb+1, nzt |
---|
102 | ! |
---|
103 | !-- x-direction |
---|
104 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
105 | IF ( ukomp > 0.0_wp ) THEN |
---|
106 | tend(k,j,i) = tend(k,j,i) - ukomp * ( sk(k,j,i) - sk(k,j,i-1) ) * ddx |
---|
107 | ELSE |
---|
108 | tend(k,j,i) = tend(k,j,i) - ukomp * ( sk(k,j,i+1) - sk(k,j,i) ) * ddx |
---|
109 | ENDIF |
---|
110 | ! |
---|
111 | !-- y-direction |
---|
112 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
113 | IF ( vkomp > 0.0_wp ) THEN |
---|
114 | tend(k,j,i) = tend(k,j,i) - vkomp * ( sk(k,j,i) - sk(k,j-1,i) ) * ddy |
---|
115 | ELSE |
---|
116 | tend(k,j,i) = tend(k,j,i) - vkomp * ( sk(k,j+1,i) - sk(k,j,i) ) * ddy |
---|
117 | ENDIF |
---|
118 | ! |
---|
119 | !-- z-direction |
---|
120 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
121 | IF ( wkomp > 0.0_wp ) THEN |
---|
122 | tend(k,j,i) = tend(k,j,i) - wkomp * ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) |
---|
123 | ELSE |
---|
124 | tend(k,j,i) = tend(k,j,i) - wkomp * ( sk(k+1,j,i) - sk(k,j,i) ) * ddzu(k+1) |
---|
125 | ENDIF |
---|
126 | |
---|
127 | ENDDO |
---|
128 | ENDDO |
---|
129 | ENDDO |
---|
130 | |
---|
131 | END SUBROUTINE advec_s_up |
---|
132 | |
---|
133 | |
---|
134 | !--------------------------------------------------------------------------------------------------! |
---|
135 | ! Description: |
---|
136 | ! ------------ |
---|
137 | !> Call for grid point i,j |
---|
138 | !--------------------------------------------------------------------------------------------------! |
---|
139 | SUBROUTINE advec_s_up_ij( i, j, sk ) |
---|
140 | |
---|
141 | USE arrays_3d, & |
---|
142 | ONLY: ddzu, tend, u, v, w |
---|
143 | |
---|
144 | USE control_parameters, & |
---|
145 | ONLY: u_gtrans, v_gtrans |
---|
146 | |
---|
147 | USE grid_variables, & |
---|
148 | ONLY: ddx, ddy |
---|
149 | |
---|
150 | USE indices, & |
---|
151 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzt |
---|
152 | |
---|
153 | USE kinds |
---|
154 | |
---|
155 | |
---|
156 | IMPLICIT NONE |
---|
157 | |
---|
158 | INTEGER(iwp) :: i !< grid index along x-direction |
---|
159 | INTEGER(iwp) :: j !< grid index along y-direction |
---|
160 | INTEGER(iwp) :: k !< grid index along z-direction |
---|
161 | |
---|
162 | REAL(wp) :: ukomp !< advection velocity along x-direction |
---|
163 | REAL(wp) :: vkomp !< advection velocity along y-direction |
---|
164 | REAL(wp) :: wkomp !< advection velocity along z-direction |
---|
165 | |
---|
166 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !< treated scalar |
---|
167 | |
---|
168 | |
---|
169 | DO k = nzb+1, nzt |
---|
170 | ! |
---|
171 | !-- x-direction |
---|
172 | ukomp = 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
173 | IF ( ukomp > 0.0_wp ) THEN |
---|
174 | tend(k,j,i) = tend(k,j,i) - ukomp * ( sk(k,j,i) - sk(k,j,i-1) ) * ddx |
---|
175 | ELSE |
---|
176 | tend(k,j,i) = tend(k,j,i) - ukomp * ( sk(k,j,i+1) - sk(k,j,i) ) * ddx |
---|
177 | ENDIF |
---|
178 | ! |
---|
179 | !-- y-direction |
---|
180 | vkomp = 0.5_wp * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
181 | IF ( vkomp > 0.0_wp ) THEN |
---|
182 | tend(k,j,i) = tend(k,j,i) - vkomp * ( sk(k,j,i) - sk(k,j-1,i) ) * ddy |
---|
183 | ELSE |
---|
184 | tend(k,j,i) = tend(k,j,i) - vkomp * ( sk(k,j+1,i) - sk(k,j,i) ) * ddy |
---|
185 | ENDIF |
---|
186 | ! |
---|
187 | !-- z-direction |
---|
188 | wkomp = 0.5_wp * ( w(k,j,i) + w(k-1,j,i) ) |
---|
189 | IF ( wkomp > 0.0_wp ) THEN |
---|
190 | tend(k,j,i) = tend(k,j,i) - wkomp * ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) |
---|
191 | ELSE |
---|
192 | tend(k,j,i) = tend(k,j,i) - wkomp * ( sk(k+1,j,i) - sk(k,j,i) ) * ddzu(k+1) |
---|
193 | ENDIF |
---|
194 | |
---|
195 | ENDDO |
---|
196 | |
---|
197 | END SUBROUTINE advec_s_up_ij |
---|
198 | |
---|
199 | END MODULE advec_s_up_mod |
---|