[2055] | 1 | !> @file outflow_turbulence.f90 |
---|
[4797] | 2 | !--------------------------------------------------------------------------------------------------! |
---|
[2828] | 3 | ! This file is part of the PALM model system. |
---|
[2055] | 4 | ! |
---|
[4797] | 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. |
---|
[2055] | 8 | ! |
---|
[4797] | 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. |
---|
[2055] | 12 | ! |
---|
[4797] | 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/>. |
---|
[2055] | 15 | ! |
---|
[4828] | 16 | ! Copyright 1997-2021 Leibniz Universitaet Hannover |
---|
[4797] | 17 | !--------------------------------------------------------------------------------------------------! |
---|
[2055] | 18 | ! |
---|
| 19 | ! Current revisions: |
---|
| 20 | ! ----------------- |
---|
[4797] | 21 | ! |
---|
| 22 | ! |
---|
[2055] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
[3298] | 25 | ! $Id: outflow_turbulence.f90 3241 2018-09-12 15:02:00Z raasch $ |
---|
[4797] | 26 | ! file re-formatted to follow the PALM coding standard |
---|
| 27 | ! |
---|
| 28 | ! 3241 2018-09-12 15:02:00Z raasch |
---|
[4182] | 29 | ! Corrected "Former revisions" section |
---|
[4797] | 30 | ! |
---|
[4182] | 31 | ! 3241 2018-09-12 15:02:00Z raasch |
---|
[3287] | 32 | ! unused variables removed |
---|
[4182] | 33 | ! |
---|
| 34 | ! 2050 2016-11-08 15:00:55Z gronemeier |
---|
| 35 | ! Initial version |
---|
[2055] | 36 | ! |
---|
[4797] | 37 | ! |
---|
[2055] | 38 | ! Description: |
---|
| 39 | ! ------------ |
---|
[4797] | 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 | !--------------------------------------------------------------------------------------------------! |
---|
[2055] | 43 | SUBROUTINE outflow_turbulence |
---|
| 44 | |
---|
[4797] | 45 | USE arrays_3d, & |
---|
[2828] | 46 | ONLY: e, pt, q, s, u, v, w |
---|
[2055] | 47 | |
---|
[4797] | 48 | USE control_parameters, & |
---|
[2828] | 49 | ONLY: humidity, passive_scalar, outflow_source_plane |
---|
[2055] | 50 | |
---|
[4797] | 51 | USE cpulog, & |
---|
[2055] | 52 | ONLY: cpu_log, log_point |
---|
| 53 | |
---|
[4797] | 54 | USE grid_variables, & |
---|
[2055] | 55 | ONLY: ddx |
---|
| 56 | |
---|
[4797] | 57 | USE indices, & |
---|
[3287] | 58 | ONLY: nbgp, nx, nxr, nyn, nys, nyng, nysg, nzb, nzt |
---|
[2055] | 59 | |
---|
| 60 | USE kinds |
---|
| 61 | |
---|
[4797] | 62 | USE pegrid!, & |
---|
[2055] | 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 | |
---|
[4797] | 73 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,7,nbgp) :: outflow_val !< values to be copied to the outflow boundary |
---|
[2055] | 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) |
---|
[4797] | 96 | IF ( humidity ) & |
---|
[2055] | 97 | outflow_val(k,j,6,l) = q(k,j,i) |
---|
[4797] | 98 | IF ( passive_scalar ) & |
---|
[2055] | 99 | outflow_val(k,j,7,l) = s(k,j,i) |
---|
[2828] | 100 | |
---|
[2055] | 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) |
---|
[4797] | 117 | IF ( humidity ) & |
---|
[2055] | 118 | outflow_val(k,j,6,l) = q(k,j,i) |
---|
[4797] | 119 | IF ( passive_scalar ) & |
---|
[2055] | 120 | outflow_val(k,j,7,l) = s(k,j,i) |
---|
[2828] | 121 | |
---|
[2055] | 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 | |
---|
[4797] | 133 | CALL MPI_SEND( outflow_val(nzb,nysg,1,1), ngp_ofv, MPI_REAL, id_outflow, 1, comm1dx, ierr ) |
---|
[2055] | 134 | |
---|
| 135 | ELSEIF ( myidx /= id_outflow_source .AND. myidx == id_outflow ) THEN |
---|
| 136 | |
---|
| 137 | outflow_val = 0.0_wp |
---|
[4797] | 138 | CALL MPI_RECV( outflow_val(nzb,nysg,1,1), ngp_ofv, MPI_REAL, id_outflow_source, 1, comm1dx, & |
---|
| 139 | status, ierr ) |
---|
[2055] | 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 | |
---|
[4797] | 158 | IF ( humidity ) & |
---|
[2055] | 159 | q(k,j,nx+1:nx+nbgp) = outflow_val(k,j,6,1:nbgp) |
---|
[4797] | 160 | IF ( passive_scalar ) & |
---|
[2055] | 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 | |
---|
[3287] | 171 | END SUBROUTINE outflow_turbulence |
---|