!> @file exchange_horiz_2d.f90 !--------------------------------------------------------------------------------! ! This file is part of PALM. ! ! PALM is free software: you can redistribute it and/or modify it under the terms ! of the GNU General Public License as published by the Free Software Foundation, ! either version 3 of the License, or (at your option) any later version. ! ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License along with ! PALM. If not, see . ! ! Copyright 1997-2014 Leibniz Universitaet Hannover !--------------------------------------------------------------------------------! ! ! Current revisions: ! ----------------- ! ! ! Former revisions: ! ----------------- ! $Id: exchange_horiz_2d.f90 1683 2015-10-07 23:57:51Z knoop $ ! ! 1682 2015-10-07 23:56:08Z knoop ! Code annotations made doxygen readable ! ! 1348 2014-03-27 18:01:03Z raasch ! bugfix: bc_lr_cyc and bc_ns_cyc added to ONLY-list ! ! 1320 2014-03-20 08:40:49Z raasch ! ONLY-attribute added to USE-statements, ! kind-parameters added to all INTEGER and REAL declaration statements, ! kinds are defined in new module kinds, ! revision history before 2012 removed, ! comment fields (!:) to be used for variable explanations added to ! all variable declaration statements ! ! 1092 2013-02-02 11:24:22Z raasch ! unused variables removed ! ! 1036 2012-10-22 13:43:42Z raasch ! code put under GPL (PALM 3.9) ! ! 841 2012-02-28 12:29:49Z maronga ! Excluded routine from compilation of namelist_file_check ! ! Revision 1.1 1998/01/23 09:58:21 raasch ! Initial revision ! ! ! Description: ! ------------ !> Exchange of lateral (ghost) boundaries (parallel computers) and cyclic !> boundary conditions, respectively, for 2D-arrays. !------------------------------------------------------------------------------! SUBROUTINE exchange_horiz_2d( ar ) USE control_parameters, & ONLY : bc_lr_cyc, bc_ns_cyc, inflow_l, inflow_n, inflow_r, inflow_s, & outflow_l, outflow_n, outflow_r, outflow_s USE cpulog, & ONLY : cpu_log, log_point_s USE indices, & ONLY : nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg USE kinds USE pegrid IMPLICIT NONE INTEGER(iwp) :: i !< REAL(wp) :: ar(nysg:nyng,nxlg:nxrg) !< #if ! defined( __check ) CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'start' ) #if defined( __parallel ) ! !-- Exchange of lateral boundary values for parallel computers IF ( pdims(1) == 1 ) THEN ! !-- One-dimensional decomposition along y, boundary values can be exchanged !-- within the PE memory ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) ELSE ! !-- Send left boundary, receive right one CALL MPI_SENDRECV( ar(nysg,nxl), 1, type_y, pleft, 0, & ar(nysg,nxr+1), 1, type_y, pright, 0, & comm2d, status, ierr ) ! !-- Send right boundary, receive left one CALL MPI_SENDRECV( ar(nysg,nxr+1-nbgp), 1, type_y, pright, 1, & ar(nysg,nxlg), 1, type_y, pleft, 1, & comm2d, status, ierr ) ENDIF IF ( pdims(2) == 1 ) THEN ! !-- One-dimensional decomposition along x, boundary values can be exchanged !-- within the PE memory ar(nysg:nys-1,:) = ar(nyn-nbgp+1:nyn,:) ar(nyn+1:nyng,:) = ar(nys:nys+nbgp-1,:) ELSE ! !-- Send front boundary, receive rear one CALL MPI_SENDRECV( ar(nys,nxlg), 1, type_x, psouth, 0, & ar(nyn+1,nxlg), 1, type_x, pnorth, 0, & comm2d, status, ierr ) ! !-- Send rear boundary, receive front one CALL MPI_SENDRECV( ar(nyn+1-nbgp,nxlg), 1, type_x, pnorth, 1, & ar(nysg,nxlg), 1, type_x, psouth, 1, & comm2d, status, ierr ) ENDIF #else ! !-- Lateral boundary conditions in the non-parallel case IF ( bc_lr_cyc ) THEN ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) ENDIF IF ( bc_ns_cyc ) THEN ar(nysg:nys-1,:) = ar(nyn-nbgp+1:nyn,:) ar(nyn+1:nyng,:) = ar(nys:nys+nbgp-1,:) ENDIF #endif ! !-- Neumann-conditions at inflow/outflow in case of non-cyclic boundary !-- conditions IF ( inflow_l .OR. outflow_l ) THEN DO i=nbgp, 1, -1 ar(:,nxl-i) = ar(:,nxl) END DO END IF IF ( inflow_r .OR. outflow_r ) THEN DO i=1, nbgp ar(:,nxr+i) = ar(:,nxr) END DO END IF IF ( inflow_s .OR. outflow_s ) THEN DO i=nbgp, 1, -1 ar(nys-i,:) = ar(nys,:) END DO END IF IF ( inflow_n .OR. outflow_n ) THEN DO i=1, nbgp ar(nyn+i,:) = ar(nyn,:) END DO END IF CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'stop' ) #endif END SUBROUTINE exchange_horiz_2d !------------------------------------------------------------------------------! ! Description: ! ------------ !> Exchange of lateral (ghost) boundaries (parallel computers) and cyclic !> boundary conditions, respectively, for 2D integer arrays. !------------------------------------------------------------------------------! SUBROUTINE exchange_horiz_2d_int( ar ) USE control_parameters, & ONLY: bc_lr_cyc, bc_ns_cyc USE cpulog, & ONLY: cpu_log, log_point_s USE indices, & ONLY: nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg USE kinds USE pegrid IMPLICIT NONE INTEGER(iwp) :: ar(nysg:nyng,nxlg:nxrg) !< #if ! defined( __check ) CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'start' ) #if defined( __parallel ) ! !-- Exchange of lateral boundary values for parallel computers IF ( pdims(1) == 1 ) THEN ! !-- One-dimensional decomposition along y, boundary values can be exchanged !-- within the PE memory ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) ELSE ! !-- Send left boundary, receive right one CALL MPI_SENDRECV( ar(nysg,nxl), 1, type_y_int, pleft, 0, & ar(nysg,nxr+1), 1, type_y_int, pright, 0, & comm2d, status, ierr ) ! !-- Send right boundary, receive left one CALL MPI_SENDRECV( ar(nysg,nxr+1-nbgp), 1, type_y_int, pright, 1, & ar(nysg,nxlg), 1, type_y_int, pleft, 1, & comm2d, status, ierr ) ENDIF IF ( pdims(2) == 1 ) THEN ! !-- One-dimensional decomposition along x, boundary values can be exchanged !-- within the PE memory ar(nysg:nys-1,:) = ar(nyn+1-nbgp:nyn,:) ar(nyn+1:nyng,:) = ar(nys:nys-1+nbgp,:) ELSE ! !-- Send front boundary, receive rear one CALL MPI_SENDRECV( ar(nys,nxlg), 1, type_x_int, psouth, 0, & ar(nyn+1,nxlg), 1, type_x_int, pnorth, 0, & comm2d, status, ierr ) ! !-- Send rear boundary, receive front one CALL MPI_SENDRECV( ar(nyn+1-nbgp,nxlg), 1, type_x_int, pnorth, 1, & ar(nysg,nxlg), 1, type_x_int, psouth, 1, & comm2d, status, ierr ) ENDIF #else ! !-- Lateral boundary conditions in the non-parallel case IF ( bc_lr_cyc ) THEN ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) ENDIF IF ( bc_ns_cyc ) THEN ar(nysg:nys-1,:) = ar(nyn+1-nbgp:nyn,:) ar(nyn+1:nyng,:) = ar(nys:nys-1+nbgp,:) ENDIF #endif CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'stop' ) #endif END SUBROUTINE exchange_horiz_2d_int