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

Last change on this file since 3768 was 3655, checked in by knoop, 3 years ago

Bugfix: made "unit" and "found" intend INOUT in module interface subroutines + automatic copyright update

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