1 | MODULE advec_s_pw_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-2014 Leibniz Universitaet Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: advec_s_pw.f90 1321 2014-03-20 09:40:40Z kanani $ |
---|
27 | ! |
---|
28 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
29 | ! ONLY-attribute added to USE-statements, |
---|
30 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
31 | ! kinds are defined in new module kinds, |
---|
32 | ! revision history before 2012 removed, |
---|
33 | ! comment fields (!:) to be used for variable explanations added to |
---|
34 | ! all variable declaration statements |
---|
35 | ! |
---|
36 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
37 | ! code put under GPL (PALM 3.9) |
---|
38 | ! |
---|
39 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
40 | ! cpp switch __nopointer added for pointer free version |
---|
41 | ! |
---|
42 | ! Revision 1.1 1997/08/29 08:54:20 raasch |
---|
43 | ! Initial revision |
---|
44 | ! |
---|
45 | ! |
---|
46 | ! Description: |
---|
47 | ! ------------ |
---|
48 | ! Advection term for scalar variables using the Piacsek and Williams scheme |
---|
49 | ! (form C3). Contrary to PW itself, for reasons of accuracy their scheme is |
---|
50 | ! slightly modified as follows: the values of those scalars that are used for |
---|
51 | ! the computation of the flux divergence are reduced by the value of the |
---|
52 | ! relevant scalar at the location where the difference is computed (sk(k,j,i)). |
---|
53 | ! NOTE: at the first grid point above the surface computation still takes place! |
---|
54 | !------------------------------------------------------------------------------! |
---|
55 | |
---|
56 | PRIVATE |
---|
57 | PUBLIC advec_s_pw |
---|
58 | |
---|
59 | INTERFACE advec_s_pw |
---|
60 | MODULE PROCEDURE advec_s_pw |
---|
61 | MODULE PROCEDURE advec_s_pw_ij |
---|
62 | END INTERFACE |
---|
63 | |
---|
64 | CONTAINS |
---|
65 | |
---|
66 | |
---|
67 | !------------------------------------------------------------------------------! |
---|
68 | ! Call for all grid points |
---|
69 | !------------------------------------------------------------------------------! |
---|
70 | SUBROUTINE advec_s_pw( sk ) |
---|
71 | |
---|
72 | USE arrays_3d, & |
---|
73 | ONLY: dd2zu, tend, u, v, w |
---|
74 | |
---|
75 | USE control_parameters, & |
---|
76 | ONLY: u_gtrans, v_gtrans |
---|
77 | |
---|
78 | USE grid_variables, & |
---|
79 | ONLY: ddx, ddy |
---|
80 | |
---|
81 | USE indices, & |
---|
82 | ONLY: nxl, nxr, nyn, nys, nzb_s_inner, nzt |
---|
83 | |
---|
84 | USE kinds |
---|
85 | |
---|
86 | |
---|
87 | IMPLICIT NONE |
---|
88 | |
---|
89 | INTEGER(iwp) :: i !: |
---|
90 | INTEGER(iwp) :: j !: |
---|
91 | INTEGER(iwp) :: k !: |
---|
92 | |
---|
93 | #if defined( __nopointer ) |
---|
94 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !: |
---|
95 | #else |
---|
96 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
97 | #endif |
---|
98 | |
---|
99 | |
---|
100 | DO i = nxl, nxr |
---|
101 | DO j = nys, nyn |
---|
102 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
103 | tend(k,j,i) = tend(k,j,i) & |
---|
104 | -0.5 * ( ( u(k,j,i+1) - u_gtrans ) * ( sk(k,j,i+1) - sk(k,j,i) ) & |
---|
105 | - ( u(k,j,i) - u_gtrans ) * ( sk(k,j,i-1) - sk(k,j,i) ) & |
---|
106 | ) * ddx & |
---|
107 | -0.5 * ( ( v(k,j+1,i) - v_gtrans ) * ( sk(k,j+1,i) - sk(k,j,i) ) & |
---|
108 | - ( v(k,j,i) - v_gtrans ) * ( sk(k,j-1,i) - sk(k,j,i) ) & |
---|
109 | ) * ddy & |
---|
110 | - ( w(k,j,i) * ( sk(k+1,j,i) - sk(k,j,i) ) & |
---|
111 | - w(k-1,j,i) * ( sk(k-1,j,i) - sk(k,j,i) ) & |
---|
112 | ) * dd2zu(k) |
---|
113 | ENDDO |
---|
114 | ENDDO |
---|
115 | ENDDO |
---|
116 | |
---|
117 | END SUBROUTINE advec_s_pw |
---|
118 | |
---|
119 | |
---|
120 | !------------------------------------------------------------------------------! |
---|
121 | ! Call for grid point i,j |
---|
122 | !------------------------------------------------------------------------------! |
---|
123 | SUBROUTINE advec_s_pw_ij( i, j, sk ) |
---|
124 | |
---|
125 | USE arrays_3d, & |
---|
126 | ONLY: dd2zu, tend, u, v, w |
---|
127 | |
---|
128 | USE control_parameters, & |
---|
129 | ONLY: u_gtrans, v_gtrans |
---|
130 | |
---|
131 | USE grid_variables, & |
---|
132 | ONLY: ddx, ddy |
---|
133 | |
---|
134 | USE indices, & |
---|
135 | ONLY: nzb_s_inner, nzt |
---|
136 | |
---|
137 | USE kinds |
---|
138 | |
---|
139 | |
---|
140 | IMPLICIT NONE |
---|
141 | |
---|
142 | INTEGER(iwp) :: i !: |
---|
143 | INTEGER(iwp) :: j !: |
---|
144 | INTEGER(iwp) :: k !: |
---|
145 | |
---|
146 | #if defined( __nopointer ) |
---|
147 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: sk !: |
---|
148 | #else |
---|
149 | REAL(wp), DIMENSION(:,:,:), POINTER :: sk |
---|
150 | #endif |
---|
151 | |
---|
152 | |
---|
153 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
154 | tend(k,j,i) = tend(k,j,i) & |
---|
155 | -0.5 * ( ( u(k,j,i+1) - u_gtrans ) * ( sk(k,j,i+1) - sk(k,j,i) ) & |
---|
156 | - ( u(k,j,i) - u_gtrans ) * ( sk(k,j,i-1) - sk(k,j,i) ) & |
---|
157 | ) * ddx & |
---|
158 | -0.5 * ( ( v(k,j+1,i) - v_gtrans ) * ( sk(k,j+1,i) - sk(k,j,i) ) & |
---|
159 | - ( v(k,j,i) - v_gtrans ) * ( sk(k,j-1,i) - sk(k,j,i) ) & |
---|
160 | ) * ddy & |
---|
161 | - ( w(k,j,i) * ( sk(k+1,j,i) - sk(k,j,i) ) & |
---|
162 | - w(k-1,j,i) * ( sk(k-1,j,i) - sk(k,j,i) ) & |
---|
163 | ) * dd2zu(k) |
---|
164 | ENDDO |
---|
165 | |
---|
166 | END SUBROUTINE advec_s_pw_ij |
---|
167 | |
---|
168 | END MODULE advec_s_pw_mod |
---|