1 | MODULE advec_s_up_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: advec_s_up.f90 1037 2012-10-22 14:10:22Z heinze $ |
---|
27 | ! |
---|
28 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
29 | ! code put under GPL (PALM 3.9) |
---|
30 | ! |
---|
31 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
32 | ! cpp switch __nopointer added for pointer free version |
---|
33 | ! |
---|
34 | ! 981 2012-08-09 14:57:44Z maronga |
---|
35 | ! Typo removed |
---|
36 | ! |
---|
37 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
38 | ! |
---|
39 | ! Revision 1.11 2006/02/23 09:43:44 raasch |
---|
40 | ! nzb_2d replaced by nzb_s_inner |
---|
41 | ! |
---|
42 | ! Revision 1.1 1997/08/29 08:54:33 raasch |
---|
43 | ! Initial revision |
---|
44 | ! |
---|
45 | ! |
---|
46 | ! Description: |
---|
47 | ! ------------ |
---|
48 | ! Advection term for scalar quantities using the Upstream scheme. |
---|
49 | ! NOTE: vertical advection at k=1 still has wrong grid spacing for w>0! |
---|
50 | ! The same problem occurs for all topography boundaries! |
---|
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 | ! Call for all grid points |
---|
66 | !------------------------------------------------------------------------------! |
---|
67 | SUBROUTINE advec_s_up( sk ) |
---|
68 | |
---|
69 | USE arrays_3d |
---|
70 | USE control_parameters |
---|
71 | USE grid_variables |
---|
72 | USE indices |
---|
73 | |
---|
74 | IMPLICIT NONE |
---|
75 | |
---|
76 | INTEGER :: i, j, k |
---|
77 | |
---|
78 | REAL :: ukomp, vkomp, wkomp |
---|
79 | #if defined( __nopointer ) |
---|
80 | REAL, DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk |
---|
81 | #else |
---|
82 | REAL, DIMENSION(:,:,:), POINTER :: sk |
---|
83 | #endif |
---|
84 | |
---|
85 | |
---|
86 | DO i = nxl, nxr |
---|
87 | DO j = nys, nyn |
---|
88 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
89 | ! |
---|
90 | !-- x-direction |
---|
91 | ukomp = 0.5 * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
92 | IF ( ukomp > 0.0 ) THEN |
---|
93 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
94 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx |
---|
95 | ELSE |
---|
96 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
97 | ( sk(k,j,i+1) - sk(k,j,i) ) * ddx |
---|
98 | ENDIF |
---|
99 | ! |
---|
100 | !-- y-direction |
---|
101 | vkomp = 0.5 * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
102 | IF ( vkomp > 0.0 ) THEN |
---|
103 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
104 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy |
---|
105 | ELSE |
---|
106 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
107 | ( sk(k,j+1,i) - sk(k,j,i) ) * ddy |
---|
108 | ENDIF |
---|
109 | ! |
---|
110 | !-- z-direction |
---|
111 | wkomp = 0.5 * ( w(k,j,i) + w(k-1,j,i) ) |
---|
112 | IF ( wkomp > 0.0 ) THEN |
---|
113 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
114 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) |
---|
115 | ELSE |
---|
116 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
117 | ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) |
---|
118 | ENDIF |
---|
119 | |
---|
120 | ENDDO |
---|
121 | ENDDO |
---|
122 | ENDDO |
---|
123 | |
---|
124 | END SUBROUTINE advec_s_up |
---|
125 | |
---|
126 | |
---|
127 | !------------------------------------------------------------------------------! |
---|
128 | ! Call for grid point i,j |
---|
129 | !------------------------------------------------------------------------------! |
---|
130 | SUBROUTINE advec_s_up_ij( i, j, sk ) |
---|
131 | |
---|
132 | USE arrays_3d |
---|
133 | USE control_parameters |
---|
134 | USE grid_variables |
---|
135 | USE indices |
---|
136 | |
---|
137 | IMPLICIT NONE |
---|
138 | |
---|
139 | INTEGER :: i, j, k |
---|
140 | |
---|
141 | REAL :: ukomp, vkomp, wkomp |
---|
142 | #if defined( __nopointer ) |
---|
143 | REAL, DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk |
---|
144 | #else |
---|
145 | REAL, DIMENSION(:,:,:), POINTER :: sk |
---|
146 | #endif |
---|
147 | |
---|
148 | |
---|
149 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
150 | ! |
---|
151 | !-- x-direction |
---|
152 | ukomp = 0.5 * ( u(k,j,i) + u(k,j,i+1) ) - u_gtrans |
---|
153 | IF ( ukomp > 0.0 ) THEN |
---|
154 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
155 | ( sk(k,j,i) - sk(k,j,i-1) ) * ddx |
---|
156 | ELSE |
---|
157 | tend(k,j,i) = tend(k,j,i) - ukomp * & |
---|
158 | ( sk(k,j,i+1) - sk(k,j,i) ) * ddx |
---|
159 | ENDIF |
---|
160 | ! |
---|
161 | !-- y-direction |
---|
162 | vkomp = 0.5 * ( v(k,j,i) + v(k,j+1,i) ) - v_gtrans |
---|
163 | IF ( vkomp > 0.0 ) THEN |
---|
164 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
165 | ( sk(k,j,i) - sk(k,j-1,i) ) * ddy |
---|
166 | ELSE |
---|
167 | tend(k,j,i) = tend(k,j,i) - vkomp * & |
---|
168 | ( sk(k,j+1,i) - sk(k,j,i) ) * ddy |
---|
169 | ENDIF |
---|
170 | ! |
---|
171 | !-- z-direction |
---|
172 | wkomp = 0.5 * ( w(k,j,i) + w(k-1,j,i) ) |
---|
173 | IF ( wkomp > 0.0 ) THEN |
---|
174 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
175 | ( sk(k,j,i) - sk(k-1,j,i) ) * ddzu(k) |
---|
176 | ELSE |
---|
177 | tend(k,j,i) = tend(k,j,i) - wkomp * & |
---|
178 | ( sk(k+1,j,i)-sk(k,j,i) ) * ddzu(k+1) |
---|
179 | ENDIF |
---|
180 | |
---|
181 | ENDDO |
---|
182 | |
---|
183 | END SUBROUTINE advec_s_up_ij |
---|
184 | |
---|
185 | END MODULE advec_s_up_mod |
---|