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 terms of the GNU General |
---|
6 | ! Public License as published by the Free Software Foundation, either version 3 of the License, or |
---|
7 | ! (at your option) any later version. |
---|
8 | ! |
---|
9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
---|
10 | ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
11 | ! Public License for more details. |
---|
12 | ! |
---|
13 | ! You should have received a copy of the GNU General Public License along with PALM. If not, see |
---|
14 | ! <http://www.gnu.org/licenses/>. |
---|
15 | ! |
---|
16 | ! Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! Current revisions: |
---|
20 | ! ----------------- |
---|
21 | ! |
---|
22 | ! |
---|
23 | ! Former revisions: |
---|
24 | ! ----------------- |
---|
25 | ! $Id: outflow_turbulence.f90 3241 2018-09-12 15:02:00Z raasch $ |
---|
26 | ! file re-formatted to follow the PALM coding standard |
---|
27 | ! |
---|
28 | ! 3241 2018-09-12 15:02:00Z raasch |
---|
29 | ! Corrected "Former revisions" section |
---|
30 | ! |
---|
31 | ! 3241 2018-09-12 15:02:00Z raasch |
---|
32 | ! unused variables removed |
---|
33 | ! |
---|
34 | ! 2050 2016-11-08 15:00:55Z gronemeier |
---|
35 | ! Initial version |
---|
36 | ! |
---|
37 | ! |
---|
38 | ! Description: |
---|
39 | ! ------------ |
---|
40 | !> Routine based on inflow_turbulence.f90. Copies values of 3d data from a 2d vertical source plane |
---|
41 | !> (defined by outflow_source_plane) to the outflow boundary. |
---|
42 | !--------------------------------------------------------------------------------------------------! |
---|
43 | SUBROUTINE outflow_turbulence |
---|
44 | |
---|
45 | USE arrays_3d, & |
---|
46 | ONLY: e, pt, q, s, u, v, w |
---|
47 | |
---|
48 | USE control_parameters, & |
---|
49 | ONLY: humidity, passive_scalar, outflow_source_plane |
---|
50 | |
---|
51 | USE cpulog, & |
---|
52 | ONLY: cpu_log, log_point |
---|
53 | |
---|
54 | USE grid_variables, & |
---|
55 | ONLY: ddx |
---|
56 | |
---|
57 | USE indices, & |
---|
58 | ONLY: nbgp, nx, nxr, nyn, nys, nyng, nysg, nzb, nzt |
---|
59 | |
---|
60 | USE kinds |
---|
61 | |
---|
62 | USE pegrid!, & |
---|
63 | !ONLY: comm1dx, id_outflow, id_outflow_source, ierr, myidx, status |
---|
64 | |
---|
65 | IMPLICIT NONE |
---|
66 | |
---|
67 | INTEGER(iwp) :: i !< loop index |
---|
68 | INTEGER(iwp) :: j !< loop index |
---|
69 | INTEGER(iwp) :: k !< loop index |
---|
70 | INTEGER(iwp) :: l !< loop index |
---|
71 | INTEGER(iwp) :: ngp_ofv !< number of grid points stored in outflow_val |
---|
72 | |
---|
73 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,7,nbgp) :: 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, id_outflow, 1, comm1dx, ierr ) |
---|
134 | |
---|
135 | ELSEIF ( myidx /= id_outflow_source .AND. myidx == id_outflow ) THEN |
---|
136 | |
---|
137 | outflow_val = 0.0_wp |
---|
138 | CALL MPI_RECV( outflow_val(nzb,nysg,1,1), ngp_ofv, MPI_REAL, id_outflow_source, 1, comm1dx, & |
---|
139 | status, ierr ) |
---|
140 | |
---|
141 | ENDIF |
---|
142 | #endif |
---|
143 | |
---|
144 | ! |
---|
145 | !-- Copy values to the outflow |
---|
146 | IF ( nxr == nx ) THEN |
---|
147 | |
---|
148 | DO j = nysg, nyng |
---|
149 | DO k = nzb, nzt + 1 |
---|
150 | |
---|
151 | u(k,j,nx+1:nx+nbgp) = outflow_val(k,j,1,1:nbgp) |
---|
152 | v(k,j,nx+1:nx+nbgp) = outflow_val(k,j,2,1:nbgp) |
---|
153 | w(k,j,nx+1:nx+nbgp) = outflow_val(k,j,3,1:nbgp) |
---|
154 | pt(k,j,nx+1:nx+nbgp) = outflow_val(k,j,4,1:nbgp) |
---|
155 | e(k,j,nx+1:nx+nbgp) = outflow_val(k,j,5,1:nbgp) |
---|
156 | e(k,j,nx+1:nx+nbgp) = MAX( e(k,j,nx+1:nx+nbgp), 0.0_wp ) |
---|
157 | |
---|
158 | IF ( humidity ) & |
---|
159 | q(k,j,nx+1:nx+nbgp) = outflow_val(k,j,6,1:nbgp) |
---|
160 | IF ( passive_scalar ) & |
---|
161 | s(k,j,nx+1:nx+nbgp) = outflow_val(k,j,7,1:nbgp) |
---|
162 | |
---|
163 | ENDDO |
---|
164 | ENDDO |
---|
165 | |
---|
166 | |
---|
167 | ENDIF |
---|
168 | |
---|
169 | CALL cpu_log( log_point(56), 'outflow_turbulence', 'stop' ) |
---|
170 | |
---|
171 | END SUBROUTINE outflow_turbulence |
---|