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