SUBROUTINE exchange_horiz_2d( ar ) !------------------------------------------------------------------------------! ! Current revisions: ! ----------------- ! ! ! Former revisions: ! ----------------- ! $Id: exchange_horiz_2d.f90 484 2010-02-05 07:36:54Z maronga $ ! ! 73 2007-03-20 08:33:14Z raasch ! Neumann boundary conditions at inflow/outflow in case of non-cyclic boundary ! conditions ! ! RCS Log replace by Id keyword, revision history cleaned up ! ! Revision 1.9 2006/05/12 19:15:52 letzel ! MPI_REAL replaced by MPI_INTEGER in exchange_horiz_2d_int ! ! 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. !------------------------------------------------------------------------------! USE control_parameters USE cpulog USE indices USE interfaces USE pegrid IMPLICIT NONE REAL :: ar(nys-1:nyn+1,nxl-1:nxr+1) 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(nys:nyn,nxl-1) = ar(nys:nyn,nxr) ar(nys:nyn,nxr+1) = ar(nys:nyn,nxl) ELSE ! !-- Send left boundary, receive right one CALL MPI_SENDRECV( ar(nys,nxl), ngp_y, MPI_REAL, pleft, 0, & ar(nys,nxr+1), ngp_y, MPI_REAL, pright, 0, & comm2d, status, ierr ) ! !-- Send right boundary, receive left one CALL MPI_SENDRECV( ar(nys,nxr), ngp_y, MPI_REAL, pright, 1, & ar(nys,nxl-1), ngp_y, MPI_REAL, 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(nys-1,:) = ar(nyn,:) ar(nyn+1,:) = ar(nys,:) ELSE ! !-- Send front boundary, receive rear one CALL MPI_SENDRECV( ar(nys,nxl-1), 1, type_x, psouth, 0, & ar(nyn+1,nxl-1), 1, type_x, pnorth, 0, & comm2d, status, ierr ) ! !-- Send rear boundary, receive front one CALL MPI_SENDRECV( ar(nyn,nxl-1), 1, type_x, pnorth, 1, & ar(nys-1,nxl-1), 1, type_x, psouth, 1, & comm2d, status, ierr ) ENDIF #else ! !-- Lateral boundary conditions in the non-parallel case IF ( bc_lr == 'cyclic' ) THEN ar(nys:nyn,nxl-1) = ar(nys:nyn,nxr) ar(nys:nyn,nxr+1) = ar(nys:nyn,nxl) ENDIF IF ( bc_ns == 'cyclic' ) THEN ar(nys-1,:) = ar(nyn,:) ar(nyn+1,:) = ar(nys,:) ENDIF #endif ! !-- Neumann-conditions at inflow/outflow in case of non-cyclic boundary !-- conditions IF ( inflow_l .OR. outflow_l ) ar(:,nxl-1) = ar(:,nxl) IF ( inflow_r .OR. outflow_r ) ar(:,nxr+1) = ar(:,nxr) IF ( inflow_s .OR. outflow_s ) ar(nys-1,:) = ar(nys,:) IF ( inflow_n .OR. outflow_n ) ar(nyn+1,:) = ar(nyn,:) CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'stop' ) END SUBROUTINE exchange_horiz_2d SUBROUTINE exchange_horiz_2d_int( ar ) !------------------------------------------------------------------------------! ! Description: ! ------------ ! Exchange of lateral (ghost) boundaries (parallel computers) and cyclic ! boundary conditions, respectively, for 2D integer arrays. !------------------------------------------------------------------------------! USE control_parameters USE cpulog USE indices USE interfaces USE pegrid IMPLICIT NONE INTEGER :: ar(nys-1:nyn+1,nxl-1:nxr+1) 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(nys:nyn,nxl-1) = ar(nys:nyn,nxr) ar(nys:nyn,nxr+1) = ar(nys:nyn,nxl) ELSE ! !-- Send left boundary, receive right one CALL MPI_SENDRECV( ar(nys,nxl), ngp_y, MPI_INTEGER, pleft, 0, & ar(nys,nxr+1), ngp_y, MPI_INTEGER, pright, 0, & comm2d, status, ierr ) ! !-- Send right boundary, receive left one CALL MPI_SENDRECV( ar(nys,nxr), ngp_y, MPI_INTEGER, pright, 1, & ar(nys,nxl-1), ngp_y, MPI_INTEGER, 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(nys-1,:) = ar(nyn,:) ar(nyn+1,:) = ar(nys,:) ELSE ! !-- Send front boundary, receive rear one CALL MPI_SENDRECV( ar(nys,nxl-1), 1, type_x_int, psouth, 0, & ar(nyn+1,nxl-1), 1, type_x_int, pnorth, 0, & comm2d, status, ierr ) ! !-- Send rear boundary, receive front one CALL MPI_SENDRECV( ar(nyn,nxl-1), 1, type_x_int, pnorth, 1, & ar(nys-1,nxl-1), 1, type_x_int, psouth, 1, & comm2d, status, ierr ) ENDIF #else ! !-- Lateral boundary conditions in the non-parallel case IF ( bc_lr == 'cyclic' ) THEN ar(nys:nyn,nxl-1) = ar(nys:nyn,nxr) ar(nys:nyn,nxr+1) = ar(nys:nyn,nxl) ENDIF IF ( bc_ns == 'cyclic' ) THEN ar(nys-1,:) = ar(nyn,:) ar(nyn+1,:) = ar(nys,:) ENDIF #endif CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'stop' ) END SUBROUTINE exchange_horiz_2d_int