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