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

Last change on this file since 4180 was 4180, checked in by scharf, 5 years ago

removed comments in 'Former revisions' section that are older than 01.01.2019

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