source: palm/trunk/SOURCE/outflow_turbulence.f90 @ 4182

Last change on this file since 4182 was 4182, checked in by scharf, 21 months ago
  • corrected "Former revisions" section
  • minor formatting in "Former revisions" section
  • added "Author" section
File size: 5.9 KB
Line 
1!> @file outflow_turbulence.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
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.
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-2019 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: outflow_turbulence.f90 3241 2018-09-12 15:02:00Z raasch $
27! Corrected "Former revisions" section
28!
29! 3241 2018-09-12 15:02:00Z raasch
30! unused variables removed
31!
32! 2050 2016-11-08 15:00:55Z gronemeier
33! Initial version
34!
35!
36! Description:
37! ------------
38!> Routine based on inflow_turbulence.f90. Copies values of 3d data from a 2d
39!> vertical source plane (defined by outflow_source_plane) to the outflow
40!> boundary.
41!------------------------------------------------------------------------------!
42 SUBROUTINE outflow_turbulence
43
44    USE arrays_3d,                                                             &
45        ONLY:  e, pt, q, s, u, v, w
46
47    USE control_parameters,                                                    &
48        ONLY:  humidity, passive_scalar, outflow_source_plane
49
50    USE cpulog,                                                                &
51        ONLY:  cpu_log, log_point
52
53    USE grid_variables,                                                        &
54        ONLY:  ddx
55
56    USE indices,                                                               &
57        ONLY:  nbgp, nx, nxr, nyn, nys, nyng, nysg, nzb, nzt
58
59    USE kinds
60
61    USE pegrid!,                                                                &
62        !ONLY:  comm1dx, id_outflow, id_outflow_source, ierr, myidx, status
63
64    IMPLICIT NONE
65
66    INTEGER(iwp) ::  i        !< loop index
67    INTEGER(iwp) ::  j        !< loop index
68    INTEGER(iwp) ::  k        !< loop index
69    INTEGER(iwp) ::  l        !< loop index
70    INTEGER(iwp) ::  ngp_ofv  !< number of grid points stored in outflow_val
71
72    REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,7,nbgp) ::                         &
73       outflow_val            !< values to be copied to the outflow boundary
74
75
76    CALL cpu_log( log_point(56), 'outflow_turbulence', 'start' )
77!
78!-- Get number of grid points stored in outflow_val
79    ngp_ofv = ( nzt - nzb + 2 ) * ( nyn - nys + 1 + 2 * nbgp ) * 7 * nbgp
80!
81!-- Get position of the source plane inside the palm grid
82    i = outflow_source_plane * ddx
83!
84!-- Use instantaneous values instead of averaged profiles
85#if defined( __parallel )
86    IF ( myidx == id_outflow_source )  THEN
87       DO  l = 1, nbgp
88          DO  j = nysg, nyng
89             DO  k = nzb, nzt + 1
90
91                outflow_val(k,j,1,l) = u(k,j,i)
92                outflow_val(k,j,2,l) = v(k,j,i)
93                outflow_val(k,j,3,l) = w(k,j,i)
94                outflow_val(k,j,4,l) = pt(k,j,i)
95                outflow_val(k,j,5,l) = e(k,j,i)
96                IF ( humidity  )                                               &
97                   outflow_val(k,j,6,l) = q(k,j,i)
98                IF ( passive_scalar )                                          &
99                   outflow_val(k,j,7,l) = s(k,j,i)
100
101            ENDDO
102          ENDDO
103          i = i + 1
104       ENDDO
105
106    ENDIF
107#else
108    DO  l = 1, nbgp
109       DO  j = nysg, nyng
110          DO  k = nzb, nzt+1
111
112             outflow_val(k,j,1,l) = u(k,j,i)
113             outflow_val(k,j,2,l) = v(k,j,i)
114             outflow_val(k,j,3,l) = w(k,j,i)
115             outflow_val(k,j,4,l) = pt(k,j,i)
116             outflow_val(k,j,5,l) = e(k,j,i)
117             IF ( humidity  )                                                  &
118                outflow_val(k,j,6,l) = q(k,j,i)
119             IF ( passive_scalar )                                             &
120                outflow_val(k,j,7,l) = s(k,j,i)
121
122          ENDDO
123       ENDDO
124       i = i + 1
125    ENDDO
126#endif
127
128!
129!-- For parallel runs, send the values to the respective outflow PE
130#if defined( __parallel )
131    IF ( myidx == id_outflow_source  .AND.  myidx /= id_outflow )  THEN
132
133       CALL MPI_SEND( outflow_val(nzb,nysg,1,1), ngp_ofv, MPI_REAL,            &
134                      id_outflow, 1, comm1dx, ierr )
135
136    ELSEIF ( myidx /= id_outflow_source  .AND.  myidx == id_outflow )  THEN
137
138       outflow_val = 0.0_wp
139       CALL MPI_RECV( outflow_val(nzb,nysg,1,1), ngp_ofv, MPI_REAL,            &
140                      id_outflow_source, 1, comm1dx, status, ierr )
141
142    ENDIF
143#endif
144
145!
146!-- Copy values to the outflow
147    IF ( nxr == nx )  THEN
148
149       DO  j = nysg, nyng
150          DO  k = nzb, nzt + 1
151
152             u(k,j,nx+1:nx+nbgp)  = outflow_val(k,j,1,1:nbgp)
153             v(k,j,nx+1:nx+nbgp)  = outflow_val(k,j,2,1:nbgp)
154             w(k,j,nx+1:nx+nbgp)  = outflow_val(k,j,3,1:nbgp)
155             pt(k,j,nx+1:nx+nbgp) = outflow_val(k,j,4,1:nbgp)
156             e(k,j,nx+1:nx+nbgp)  = outflow_val(k,j,5,1:nbgp)
157             e(k,j,nx+1:nx+nbgp)  = MAX( e(k,j,nx+1:nx+nbgp), 0.0_wp )
158
159             IF ( humidity )                                                   &
160                q(k,j,nx+1:nx+nbgp)  = outflow_val(k,j,6,1:nbgp)
161             IF ( passive_scalar )                                             &
162                s(k,j,nx+1:nx+nbgp)  = outflow_val(k,j,7,1:nbgp)
163
164          ENDDO
165       ENDDO
166
167
168    ENDIF
169
170    CALL cpu_log( log_point(56), 'outflow_turbulence', 'stop' )
171
172 END SUBROUTINE outflow_turbulence
Note: See TracBrowser for help on using the repository browser.