source: palm/trunk/SOURCE/advec_s_pw.f90 @ 2232

Last change on this file since 2232 was 2232, checked in by suehring, 7 years ago

Adjustments according new topography and surface-modelling concept implemented

  • Property svn:keywords set to Id
File size: 6.9 KB
RevLine 
[1873]1!> @file advec_s_pw.f90
[2000]2!------------------------------------------------------------------------------!
[1036]3! This file is part of PALM.
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!
[2101]17! Copyright 1997-2017 Leibniz Universitaet Hannover
[2000]18!------------------------------------------------------------------------------!
[1036]19!
[484]20! Current revisions:
[1]21! -----------------
[2232]22! topography representation via flags
[1354]23!
[1321]24! Former revisions:
25! -----------------
26! $Id: advec_s_pw.f90 2232 2017-05-30 17:47:52Z suehring $
27!
[2001]28! 2000 2016-08-20 18:09:15Z knoop
29! Forced header and separation lines into 80 columns
30!
[1874]31! 1873 2016-04-18 14:50:06Z maronga
32! Module renamed (removed _mod)
33!
34!
[1851]35! 1850 2016-04-08 13:29:27Z maronga
36! Module renamed
37!
38!
[1683]39! 1682 2015-10-07 23:56:08Z knoop
40! Code annotations made doxygen readable
41!
[1375]42! 1374 2014-04-25 12:55:07Z raasch
43! missing variables added to ONLY list
44!
[1354]45! 1353 2014-04-08 15:21:23Z heinze
46! REAL constants provided with KIND-attribute
47!
[1321]48! 1320 2014-03-20 08:40:49Z raasch
[1320]49! ONLY-attribute added to USE-statements,
50! kind-parameters added to all INTEGER and REAL declaration statements,
51! kinds are defined in new module kinds,
52! revision history before 2012 removed,
53! comment fields (!:) to be used for variable explanations added to
54! all variable declaration statements
[1]55!
[1037]56! 1036 2012-10-22 13:43:42Z raasch
57! code put under GPL (PALM 3.9)
58!
[1011]59! 1010 2012-09-20 07:59:54Z raasch
60! cpp switch __nopointer added for pointer free version
61!
[1]62! Revision 1.1  1997/08/29 08:54:20  raasch
63! Initial revision
64!
65!
66! Description:
67! ------------
[1682]68!> Advection term for scalar variables using the Piacsek and Williams scheme
69!> (form C3). Contrary to PW itself, for reasons of accuracy their scheme is
70!> slightly modified as follows: the values of those scalars that are used for
71!> the computation of the flux divergence are reduced by the value of the
72!> relevant scalar at the location where the difference is computed (sk(k,j,i)).
73!> NOTE: at the first grid point above the surface computation still takes place!
[1]74!------------------------------------------------------------------------------!
[1682]75 MODULE advec_s_pw_mod
76 
[1]77
78    PRIVATE
79    PUBLIC advec_s_pw
80
81    INTERFACE advec_s_pw
82       MODULE PROCEDURE advec_s_pw
83       MODULE PROCEDURE advec_s_pw_ij
84    END INTERFACE
85 
86 CONTAINS
87
88
89!------------------------------------------------------------------------------!
[1682]90! Description:
91! ------------
92!> Call for all grid points
[1]93!------------------------------------------------------------------------------!
94    SUBROUTINE advec_s_pw( sk )
95
[1320]96       USE arrays_3d,                                                          &
97           ONLY:  dd2zu, tend, u, v, w
[1]98
[1320]99       USE control_parameters,                                                 &
100           ONLY:  u_gtrans, v_gtrans
101
102       USE grid_variables,                                                     &
103           ONLY:  ddx, ddy
104
105       USE indices,                                                            &
[2232]106           ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb,             &
107                  nzt, wall_flags_0
[1320]108
109       USE kinds
110
111
[1]112       IMPLICIT NONE
113
[1682]114       INTEGER(iwp) ::  i !<
115       INTEGER(iwp) ::  j !<
116       INTEGER(iwp) ::  k !<
[1]117
[1010]118#if defined( __nopointer )
[1682]119       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  sk !<
[1010]120#else
[1320]121       REAL(wp), DIMENSION(:,:,:), POINTER ::  sk
[1010]122#endif
[1]123 
124
125       DO  i = nxl, nxr
126          DO  j = nys, nyn
[2232]127             DO  k = nzb+1, nzt
128                tend(k,j,i) = tend(k,j,i) +                                       &
129            ( -0.5_wp * ( ( u(k,j,i+1) - u_gtrans ) * ( sk(k,j,i+1) - sk(k,j,i) ) &
[1353]130                        - ( u(k,j,i)   - u_gtrans ) * ( sk(k,j,i-1) - sk(k,j,i) ) &
131                        ) * ddx                                                   &
132              -0.5_wp * ( ( v(k,j+1,i) - v_gtrans ) * ( sk(k,j+1,i) - sk(k,j,i) ) &
133                        - ( v(k,j,i)   - v_gtrans ) * ( sk(k,j-1,i) - sk(k,j,i) ) &
134                        ) * ddy                                                   &
135              -         (   w(k,j,i)                * ( sk(k+1,j,i) - sk(k,j,i) ) &
136                        -   w(k-1,j,i)              * ( sk(k-1,j,i) - sk(k,j,i) ) &
[2232]137                        ) * dd2zu(k)                                              &
138            ) * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 0 ) )
[1]139             ENDDO
140          ENDDO
141       ENDDO
142
143    END SUBROUTINE advec_s_pw
144
145
146!------------------------------------------------------------------------------!
[1682]147! Description:
148! ------------
149!> Call for grid point i,j
[1]150!------------------------------------------------------------------------------!
151    SUBROUTINE advec_s_pw_ij( i, j, sk )
152
[1320]153       USE arrays_3d,                                                          &
154           ONLY:  dd2zu, tend, u, v, w
[1]155
[1320]156       USE control_parameters,                                                 &
157           ONLY:  u_gtrans, v_gtrans
158
159       USE grid_variables,                                                     &
160           ONLY:  ddx, ddy
161
162       USE indices,                                                            &
[2232]163           ONLY:  nxlg, nxrg, nyng, nysg, nzb, nzt, wall_flags_0
[1320]164
165       USE kinds
166
167
[1]168       IMPLICIT NONE
169
[1682]170       INTEGER(iwp) ::  i !<
171       INTEGER(iwp) ::  j !<
172       INTEGER(iwp) ::  k !<
[1]173
[1010]174#if defined( __nopointer )
[1682]175       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  sk !<
[1010]176#else
[1320]177       REAL(wp), DIMENSION(:,:,:), POINTER ::  sk
[1010]178#endif
[1]179
180
[2232]181       DO  k = nzb+1, nzt
182          tend(k,j,i) = tend(k,j,i) +                                             &
183            ( -0.5_wp * ( ( u(k,j,i+1) - u_gtrans ) * ( sk(k,j,i+1) - sk(k,j,i) ) &
[1353]184                        - ( u(k,j,i)   - u_gtrans ) * ( sk(k,j,i-1) - sk(k,j,i) ) &
185                        ) * ddx                                                   &
186              -0.5_wp * ( ( v(k,j+1,i) - v_gtrans ) * ( sk(k,j+1,i) - sk(k,j,i) ) &
187                        - ( v(k,j,i)   - v_gtrans ) * ( sk(k,j-1,i) - sk(k,j,i) ) &
188                        ) * ddy                                                   &
189              -         (   w(k,j,i)                * ( sk(k+1,j,i) - sk(k,j,i) ) &
190                        -   w(k-1,j,i)              * ( sk(k-1,j,i) - sk(k,j,i) ) &
[2232]191                        ) * dd2zu(k)                                              &
192            ) * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 0 ) )
[1]193       ENDDO
194
195    END SUBROUTINE advec_s_pw_ij
196
197 END MODULE advec_s_pw_mod
Note: See TracBrowser for help on using the repository browser.