SUBROUTINE init_pegrid !------------------------------------------------------------------------------! ! Actual revisions: ! ----------------- ! uxrp, vynp eliminated, ! dirichlet/neumann changed to dirichlet/radiation, etc. ! ! Former revisions: ! ----------------- ! $Id: init_pegrid.f90 73 2007-03-20 08:33:14Z raasch $ ! RCS Log replace by Id keyword, revision history cleaned up ! ! Revision 1.28 2006/04/26 13:23:32 raasch ! lcmuk does not understand the !$ comment so a cpp-directive is required ! ! Revision 1.1 1997/07/24 11:15:09 raasch ! Initial revision ! ! ! Description: ! ------------ ! Determination of the virtual processor topology (if not prescribed by the ! user)and computation of the grid point number and array bounds of the local ! domains. !------------------------------------------------------------------------------! USE control_parameters USE fft_xy USE indices USE pegrid USE poisfft_mod USE poisfft_hybrid_mod USE statistics USE transpose_indices IMPLICIT NONE INTEGER :: gathered_size, i, ind(5), j, k, maximum_grid_level_l, & mg_switch_to_pe0_level_l, mg_levels_x, mg_levels_y, & mg_levels_z, nnx_y, nnx_z, nny_x, nny_z, nnz_x, nnz_y, & numproc_sqr, nx_total, nxl_l, nxr_l, nyn_l, nys_l, nzb_l, & nzt_l, omp_get_num_threads, subdomain_size INTEGER, DIMENSION(:), ALLOCATABLE :: ind_all, nxlf, nxrf, nynf, nysf LOGICAL :: found ! !-- Get the number of OpenMP threads !$OMP PARALLEL #if defined( __lcmuk ) threads_per_task = omp_get_num_threads() #else !$ threads_per_task = omp_get_num_threads() #endif !$OMP END PARALLEL #if defined( __parallel ) ! !-- Determine the processor topology or check it, if prescribed by the user IF ( npex == -1 .AND. npey == -1 ) THEN ! !-- Automatic determination of the topology !-- The default on SMP- and cluster-hosts is a 1d-decomposition along x #if defined( __lcmuk ) host = 'lcmuk' #endif IF ( host(1:3) == 'ibm' .OR. host(1:3) == 'nec' .OR. & host(1:2) == 'lc' .OR. host(1:3) == 'dec' ) THEN pdims(1) = numprocs pdims(2) = 1 ELSE numproc_sqr = SQRT( REAL( numprocs ) ) pdims(1) = MAX( numproc_sqr , 1 ) DO WHILE ( MOD( numprocs , pdims(1) ) /= 0 ) pdims(1) = pdims(1) - 1 ENDDO pdims(2) = numprocs / pdims(1) ENDIF ELSEIF ( npex /= -1 .AND. npey /= -1 ) THEN ! !-- Prescribed by user. Number of processors on the prescribed topology !-- must be equal to the number of PEs available to the job IF ( ( npex * npey ) /= numprocs ) THEN PRINT*, '+++ init_pegrid:' PRINT*, ' number of PEs of the prescribed topology (', npex*npey, & ') does not match the number of PEs available to the ', & 'job (', numprocs, ')' CALL local_stop ENDIF pdims(1) = npex pdims(2) = npey ELSE ! !-- If the processor topology is prescribed by the user, the number of !-- PEs must be given in both directions PRINT*, '+++ init_pegrid:' PRINT*, ' if the processor topology is prescribed by the user, ', & 'both values of "npex" and "npey" must be given in the ', & 'NAMELIST-parameter file' CALL local_stop ENDIF ! !-- The hybrid solver can only be used in case of a 1d-decomposition along x IF ( pdims(2) /= 1 .AND. psolver == 'poisfft_hybrid' ) THEN IF ( myid == 0 ) THEN PRINT*, '*** init_pegrid: psolver = "poisfft_hybrid" can only be' PRINT*, ' used in case of a 1d-decomposition along x' ENDIF ENDIF ! !-- If necessary, set horizontal boundary conditions to non-cyclic IF ( bc_lr /= 'cyclic' ) cyclic(1) = .FALSE. IF ( bc_ns /= 'cyclic' ) cyclic(2) = .FALSE. ! !-- Create the virtual processor grid CALL MPI_CART_CREATE( comm_palm, ndim, pdims, cyclic, reorder, & comm2d, ierr ) CALL MPI_COMM_RANK( comm2d, myid, ierr ) WRITE (myid_char,'(''_'',I4.4)') myid CALL MPI_CART_COORDS( comm2d, myid, ndim, pcoord, ierr ) CALL MPI_CART_SHIFT( comm2d, 0, 1, pleft, pright, ierr ) CALL MPI_CART_SHIFT( comm2d, 1, 1, psouth, pnorth, ierr ) ! !-- Determine sub-topologies for transpositions !-- Transposition from z to x: remain_dims(1) = .TRUE. remain_dims(2) = .FALSE. CALL MPI_CART_SUB( comm2d, remain_dims, comm1dx, ierr ) CALL MPI_COMM_RANK( comm1dx, myidx, ierr ) ! !-- Transposition from x to y remain_dims(1) = .FALSE. remain_dims(2) = .TRUE. CALL MPI_CART_SUB( comm2d, remain_dims, comm1dy, ierr ) CALL MPI_COMM_RANK( comm1dy, myidy, ierr ) ! !-- Find a grid (used for array d) which will match the transposition demands IF ( grid_matching == 'strict' ) THEN nxa = nx; nya = ny; nza = nz ELSE found = .FALSE. xn: DO nxa = nx, 2*nx ! !-- Meet conditions for nx IF ( MOD( nxa+1, pdims(1) ) /= 0 .OR. & MOD( nxa+1, pdims(2) ) /= 0 ) CYCLE xn yn: DO nya = ny, 2*ny ! !-- Meet conditions for ny IF ( MOD( nya+1, pdims(2) ) /= 0 .OR. & MOD( nya+1, pdims(1) ) /= 0 ) CYCLE yn zn: DO nza = nz, 2*nz ! !-- Meet conditions for nz IF ( ( MOD( nza, pdims(1) ) /= 0 .AND. pdims(1) /= 1 .AND. & pdims(2) /= 1 ) .OR. & ( MOD( nza, pdims(2) ) /= 0 .AND. dt_dosp /= 9999999.9 & ) ) THEN CYCLE zn ELSE found = .TRUE. EXIT xn ENDIF ENDDO zn ENDDO yn ENDDO xn IF ( .NOT. found ) THEN IF ( myid == 0 ) THEN PRINT*,'+++ init_pegrid: no matching grid for transpositions found' ENDIF CALL local_stop ENDIF ENDIF ! !-- Calculate array bounds in x-direction for every PE. !-- The last PE along x may get less grid points than the others ALLOCATE( nxlf(0:pdims(1)-1), nxrf(0:pdims(1)-1), nynf(0:pdims(2)-1), & nysf(0:pdims(2)-1), nnx_pe(0:pdims(1)-1), nny_pe(0:pdims(2)-1) ) IF ( MOD( nxa+1 , pdims(1) ) /= 0 ) THEN IF ( myid == 0 ) THEN PRINT*,'+++ x-direction: gridpoint number (',nx+1,') is not an' PRINT*,' integral divisor of the number of proces', & &'sors (', pdims(1),')' ENDIF CALL local_stop ELSE nnx = ( nxa + 1 ) / pdims(1) IF ( nnx*pdims(1) - ( nx + 1) > nnx ) THEN IF ( myid == 0 ) THEN PRINT*,'+++ x-direction: nx does not match the requirements ', & 'given by the number of PEs' PRINT*,' used' PRINT*,' please use nx = ', nx - ( pdims(1) - ( nnx*pdims(1) & - ( nx + 1 ) ) ), ' instead of nx =', nx ENDIF CALL local_stop ENDIF ENDIF ! !-- Left and right array bounds, number of gridpoints DO i = 0, pdims(1)-1 nxlf(i) = i * nnx nxrf(i) = ( i + 1 ) * nnx - 1 nnx_pe(i) = MIN( nx, nxrf(i) ) - nxlf(i) + 1 ENDDO ! !-- Calculate array bounds in y-direction for every PE. IF ( MOD( nya+1 , pdims(2) ) /= 0 ) THEN IF ( myid == 0 ) THEN PRINT*,'+++ y-direction: gridpoint number (',ny+1,') is not an' PRINT*,' integral divisor of the number of proces', & &'sors (', pdims(2),')' ENDIF CALL local_stop ELSE nny = ( nya + 1 ) / pdims(2) IF ( nny*pdims(2) - ( ny + 1) > nny ) THEN IF ( myid == 0 ) THEN PRINT*,'+++ x-direction: nx does not match the requirements ', & 'given by the number of PEs' PRINT*,' used' PRINT*,' please use nx = ', nx - ( pdims(1) - ( nnx*pdims(1) & - ( nx + 1 ) ) ), ' instead of nx =', nx ENDIF CALL local_stop ENDIF ENDIF ! !-- South and north array bounds DO j = 0, pdims(2)-1 nysf(j) = j * nny nynf(j) = ( j + 1 ) * nny - 1 nny_pe(j) = MIN( ny, nynf(j) ) - nysf(j) + 1 ENDDO ! !-- Local array bounds of the respective PEs nxl = nxlf(pcoord(1)) nxra = nxrf(pcoord(1)) nxr = MIN( nx, nxra ) nys = nysf(pcoord(2)) nyna = nynf(pcoord(2)) nyn = MIN( ny, nyna ) nzb = 0 nzta = nza nzt = MIN( nz, nzta ) nnz = nza ! !-- Calculate array bounds and gridpoint numbers for the transposed arrays !-- (needed in the pressure solver) !-- For the transposed arrays, cyclic boundaries as well as top and bottom !-- boundaries are omitted, because they are obstructive to the transposition ! !-- 1. transposition z --> x !-- This transposition is not neccessary in case of a 1d-decomposition along x, !-- except that the uptream-spline method is switched on IF ( pdims(2) /= 1 .OR. momentum_advec == 'ups-scheme' .OR. & scalar_advec == 'ups-scheme' ) THEN IF ( pdims(2) == 1 .AND. ( momentum_advec == 'ups-scheme' .OR. & scalar_advec == 'ups-scheme' ) ) THEN IF ( myid == 0 ) THEN PRINT*,'+++ WARNING: init_pegrid: 1d-decomposition along x ', & &'chosen but nz restrictions may occur' PRINT*,' since ups-scheme is activated' ENDIF ENDIF nys_x = nys nyn_xa = nyna nyn_x = nyn nny_x = nny IF ( MOD( nza , pdims(1) ) /= 0 ) THEN IF ( myid == 0 ) THEN PRINT*,'+++ transposition z --> x:' PRINT*,' nz=',nz,' is not an integral divisior of pdims(1)=', & &pdims(1) ENDIF CALL local_stop ENDIF nnz_x = nza / pdims(1) nzb_x = 1 + myidx * nnz_x nzt_xa = ( myidx + 1 ) * nnz_x nzt_x = MIN( nzt, nzt_xa ) sendrecvcount_zx = nnx * nny * nnz_x ENDIF ! !-- 2. transposition x --> y nnz_y = nnz_x nzb_y = nzb_x nzt_ya = nzt_xa nzt_y = nzt_x IF ( MOD( nxa+1 , pdims(2) ) /= 0 ) THEN IF ( myid == 0 ) THEN PRINT*,'+++ transposition x --> y:' PRINT*,' nx+1=',nx+1,' is not an integral divisor of ',& &'pdims(2)=',pdims(2) ENDIF CALL local_stop ENDIF nnx_y = (nxa+1) / pdims(2) nxl_y = myidy * nnx_y nxr_ya = ( myidy + 1 ) * nnx_y - 1 nxr_y = MIN( nx, nxr_ya ) sendrecvcount_xy = nnx_y * nny_x * nnz_y ! !-- 3. transposition y --> z (ELSE: x --> y in case of 1D-decomposition !-- along x) IF ( pdims(2) /= 1 .OR. momentum_advec == 'ups-scheme' .OR. & scalar_advec == 'ups-scheme' ) THEN ! !-- y --> z !-- This transposition is not neccessary in case of a 1d-decomposition !-- along x, except that the uptream-spline method is switched on nnx_z = nnx_y nxl_z = nxl_y nxr_za = nxr_ya nxr_z = nxr_y IF ( MOD( nya+1 , pdims(1) ) /= 0 ) THEN IF ( myid == 0 ) THEN PRINT*,'+++ Transposition y --> z:' PRINT*,' ny+1=',ny+1,' is not an integral divisor of ',& &'pdims(1)=',pdims(1) ENDIF CALL local_stop ENDIF nny_z = (nya+1) / pdims(1) nys_z = myidx * nny_z nyn_za = ( myidx + 1 ) * nny_z - 1 nyn_z = MIN( ny, nyn_za ) sendrecvcount_yz = nnx_y * nny_z * nnz_y ELSE ! !-- x --> y. This condition must be fulfilled for a 1D-decomposition along x IF ( MOD( nya+1 , pdims(1) ) /= 0 ) THEN IF ( myid == 0 ) THEN PRINT*,'+++ Transposition x --> y:' PRINT*,' ny+1=',ny+1,' is not an integral divisor of ',& &'pdims(1)=',pdims(1) ENDIF CALL local_stop ENDIF ENDIF ! !-- Indices for direct transpositions z --> y (used for calculating spectra) IF ( dt_dosp /= 9999999.9 ) THEN IF ( MOD( nza, pdims(2) ) /= 0 ) THEN IF ( myid == 0 ) THEN PRINT*,'+++ Direct transposition z --> y (needed for spectra):' PRINT*,' nz=',nz,' is not an integral divisor of ',& &'pdims(2)=',pdims(2) ENDIF CALL local_stop ELSE nxl_yd = nxl nxr_yda = nxra nxr_yd = nxr nzb_yd = 1 + myidy * ( nza / pdims(2) ) nzt_yda = ( myidy + 1 ) * ( nza / pdims(2) ) nzt_yd = MIN( nzt, nzt_yda ) sendrecvcount_zyd = nnx * nny * ( nza / pdims(2) ) ENDIF ENDIF ! !-- Indices for direct transpositions y --> x (they are only possible in case !-- of a 1d-decomposition along x) IF ( pdims(2) == 1 ) THEN nny_x = nny / pdims(1) nys_x = myid * nny_x nyn_xa = ( myid + 1 ) * nny_x - 1 nyn_x = MIN( ny, nyn_xa ) nzb_x = 1 nzt_xa = nza nzt_x = nz sendrecvcount_xy = nnx * nny_x * nza ENDIF ! !-- Indices for direct transpositions x --> y (they are only possible in case !-- of a 1d-decomposition along y) IF ( pdims(1) == 1 ) THEN nnx_y = nnx / pdims(2) nxl_y = myid * nnx_y nxr_ya = ( myid + 1 ) * nnx_y - 1 nxr_y = MIN( nx, nxr_ya ) nzb_y = 1 nzt_ya = nza nzt_y = nz sendrecvcount_xy = nnx_y * nny * nza ENDIF ! !-- Arrays for storing the array bounds are needed any more DEALLOCATE( nxlf , nxrf , nynf , nysf ) #if defined( __print ) ! !-- Control output IF ( myid == 0 ) THEN PRINT*, '*** processor topology ***' PRINT*, ' ' PRINT*, 'myid pcoord left right south north idx idy nxl: nxr',& &' nys: nyn' PRINT*, '------------------------------------------------------------',& &'-----------' WRITE (*,1000) 0, pcoord(1), pcoord(2), pleft, pright, psouth, pnorth, & myidx, myidy, nxl, nxr, nys, nyn 1000 FORMAT (I4,2X,'(',I3,',',I3,')',3X,I4,2X,I4,3X,I4,2X,I4,2X,I3,1X,I3, & 2(2X,I4,':',I4)) ! !-- Recieve data from the other PEs DO i = 1,numprocs-1 CALL MPI_RECV( ibuf, 12, MPI_INTEGER, i, MPI_ANY_TAG, comm2d, status, & ierr ) WRITE (*,1000) i, ( ibuf(j) , j = 1,12 ) ENDDO ELSE ! !-- Send data to PE0 ibuf(1) = pcoord(1); ibuf(2) = pcoord(2); ibuf(3) = pleft ibuf(4) = pright; ibuf(5) = psouth; ibuf(6) = pnorth; ibuf(7) = myidx ibuf(8) = myidy; ibuf(9) = nxl; ibuf(10) = nxr; ibuf(11) = nys ibuf(12) = nyn CALL MPI_SEND( ibuf, 12, MPI_INTEGER, 0, myid, comm2d, ierr ) ENDIF #endif #else ! !-- Array bounds when running on a single PE (respectively a non-parallel !-- machine) nxl = 0 nxr = nx nxra = nx nnx = nxr - nxl + 1 nys = 0 nyn = ny nyna = ny nny = nyn - nys + 1 nzb = 0 nzt = nz nzta = nz nnz = nz ! !-- For non-cyclic boundaries extend array u (v) by one gridpoint ! IF ( bc_lr /= 'cyclic' ) uxrp = 1 ! IF ( bc_ns /= 'cyclic' ) vynp = 1 ! !-- Array bounds for the pressure solver (in the parallel code, these bounds !-- are the ones for the transposed arrays) nys_x = nys nyn_x = nyn nyn_xa = nyn nzb_x = nzb + 1 nzt_x = nzt nzt_xa = nzt nxl_y = nxl nxr_y = nxr nxr_ya = nxr nzb_y = nzb + 1 nzt_y = nzt nzt_ya = nzt nxl_z = nxl nxr_z = nxr nxr_za = nxr nys_z = nys nyn_z = nyn nyn_za = nyn #endif ! !-- Calculate number of grid levels necessary for the multigrid poisson solver !-- as well as the gridpoint indices on each level IF ( psolver == 'multigrid' ) THEN ! !-- First calculate number of possible grid levels for the subdomains mg_levels_x = 1 mg_levels_y = 1 mg_levels_z = 1 i = nnx DO WHILE ( MOD( i, 2 ) == 0 .AND. i /= 2 ) i = i / 2 mg_levels_x = mg_levels_x + 1 ENDDO j = nny DO WHILE ( MOD( j, 2 ) == 0 .AND. j /= 2 ) j = j / 2 mg_levels_y = mg_levels_y + 1 ENDDO k = nnz DO WHILE ( MOD( k, 2 ) == 0 .AND. k /= 2 ) k = k / 2 mg_levels_z = mg_levels_z + 1 ENDDO maximum_grid_level = MIN( mg_levels_x, mg_levels_y, mg_levels_z ) ! !-- Find out, if the total domain allows more levels. These additional !-- levels are processed on PE0 only. IF ( numprocs > 1 ) THEN IF ( mg_levels_z > MIN( mg_levels_x, mg_levels_y ) ) THEN mg_switch_to_pe0_level_l = maximum_grid_level mg_levels_x = 1 mg_levels_y = 1 i = nx+1 DO WHILE ( MOD( i, 2 ) == 0 .AND. i /= 2 ) i = i / 2 mg_levels_x = mg_levels_x + 1 ENDDO j = ny+1 DO WHILE ( MOD( j, 2 ) == 0 .AND. j /= 2 ) j = j / 2 mg_levels_y = mg_levels_y + 1 ENDDO maximum_grid_level_l = MIN( mg_levels_x, mg_levels_y, mg_levels_z ) IF ( maximum_grid_level_l > mg_switch_to_pe0_level_l ) THEN mg_switch_to_pe0_level_l = maximum_grid_level_l - & mg_switch_to_pe0_level_l + 1 ELSE mg_switch_to_pe0_level_l = 0 ENDIF ELSE mg_switch_to_pe0_level_l = 0 maximum_grid_level_l = maximum_grid_level ENDIF ! !-- Use switch level calculated above only if it is not pre-defined !-- by user IF ( mg_switch_to_pe0_level == 0 ) THEN IF ( mg_switch_to_pe0_level_l /= 0 ) THEN mg_switch_to_pe0_level = mg_switch_to_pe0_level_l maximum_grid_level = maximum_grid_level_l ENDIF ELSE ! !-- Check pre-defined value and reset to default, if neccessary IF ( mg_switch_to_pe0_level < mg_switch_to_pe0_level_l .OR. & mg_switch_to_pe0_level >= maximum_grid_level_l ) THEN IF ( myid == 0 ) THEN PRINT*, '+++ WARNING init_pegrid: mg_switch_to_pe0_level ', & 'out of range and reset to default (=0)' ENDIF mg_switch_to_pe0_level = 0 ELSE ! !-- Use the largest number of possible levels anyway and recalculate !-- the switch level to this largest number of possible values maximum_grid_level = maximum_grid_level_l ENDIF ENDIF ENDIF ALLOCATE( grid_level_count(maximum_grid_level), & nxl_mg(maximum_grid_level), nxr_mg(maximum_grid_level), & nyn_mg(maximum_grid_level), nys_mg(maximum_grid_level), & nzt_mg(maximum_grid_level) ) grid_level_count = 0 nxl_l = nxl; nxr_l = nxr; nys_l = nys; nyn_l = nyn; nzt_l = nzt DO i = maximum_grid_level, 1 , -1 IF ( i == mg_switch_to_pe0_level ) THEN #if defined( __parallel ) ! !-- Save the grid size of the subdomain at the switch level, because !-- it is needed in poismg. !-- Array bounds of the local subdomain grids are gathered on PE0 ind(1) = nxl_l; ind(2) = nxr_l ind(3) = nys_l; ind(4) = nyn_l ind(5) = nzt_l ALLOCATE( ind_all(5*numprocs), mg_loc_ind(5,0:numprocs-1) ) CALL MPI_ALLGATHER( ind, 5, MPI_INTEGER, ind_all, 5, & MPI_INTEGER, comm2d, ierr ) DO j = 0, numprocs-1 DO k = 1, 5 mg_loc_ind(k,j) = ind_all(k+j*5) ENDDO ENDDO DEALLOCATE( ind_all ) ! !-- Calculate the grid size of the total domain gathered on PE0 nxr_l = ( nxr_l-nxl_l+1 ) * pdims(1) - 1 nxl_l = 0 nyn_l = ( nyn_l-nys_l+1 ) * pdims(2) - 1 nys_l = 0 ! !-- The size of this gathered array must not be larger than the !-- array tend, which is used in the multigrid scheme as a temporary !-- array subdomain_size = ( nxr - nxl + 3 ) * ( nyn - nys + 3 ) * & ( nzt - nzb + 2 ) gathered_size = ( nxr_l - nxl_l + 3 ) * ( nyn_l - nys_l + 3 ) * & ( nzt_l - nzb + 2 ) IF ( gathered_size > subdomain_size ) THEN IF ( myid == 0 ) THEN PRINT*, '+++ init_pegrid: not enough memory for storing ', & 'gathered multigrid data on PE0' ENDIF CALL local_stop ENDIF #else PRINT*, '+++ init_pegrid: multigrid gather/scatter impossible ', & 'in non parallel mode' CALL local_stop #endif ENDIF nxl_mg(i) = nxl_l nxr_mg(i) = nxr_l nys_mg(i) = nys_l nyn_mg(i) = nyn_l nzt_mg(i) = nzt_l nxl_l = nxl_l / 2 nxr_l = nxr_l / 2 nys_l = nys_l / 2 nyn_l = nyn_l / 2 nzt_l = nzt_l / 2 ENDDO ELSE maximum_grid_level = 1 ENDIF grid_level = maximum_grid_level #if defined( __parallel ) ! !-- Gridpoint number for the exchange of ghost points (y-line for 2D-arrays) ngp_y = nyn - nys + 1 ! !-- Define a new MPI derived datatype for the exchange of ghost points in !-- y-direction for 2D-arrays (line) CALL MPI_TYPE_VECTOR( nxr-nxl+3, 1, ngp_y+2, MPI_REAL, type_x, ierr ) CALL MPI_TYPE_COMMIT( type_x, ierr ) CALL MPI_TYPE_VECTOR( nxr-nxl+3, 1, ngp_y+2, MPI_INTEGER, type_x_int, ierr ) CALL MPI_TYPE_COMMIT( type_x_int, ierr ) ! !-- Calculate gridpoint numbers for the exchange of ghost points along x !-- (yz-plane for 3D-arrays) and define MPI derived data type(s) for the !-- exchange of ghost points in y-direction (xz-plane). !-- Do these calculations for the model grid and (if necessary) also !-- for the coarser grid levels used in the multigrid method ALLOCATE ( ngp_yz(maximum_grid_level), type_xz(maximum_grid_level) ) nxl_l = nxl; nxr_l = nxr; nys_l = nys; nyn_l = nyn; nzb_l = nzb; nzt_l = nzt DO i = maximum_grid_level, 1 , -1 ngp_yz(i) = (nzt_l - nzb_l + 2) * (nyn_l - nys_l + 3) CALL MPI_TYPE_VECTOR( nxr_l-nxl_l+3, nzt_l-nzb_l+2, ngp_yz(i), & MPI_REAL, type_xz(i), ierr ) CALL MPI_TYPE_COMMIT( type_xz(i), ierr ) nxl_l = nxl_l / 2 nxr_l = nxr_l / 2 nys_l = nys_l / 2 nyn_l = nyn_l / 2 nzt_l = nzt_l / 2 ENDDO #endif #if defined( __parallel ) ! !-- Setting of flags for inflow/outflow conditions in case of non-cyclic !-- horizontal boundary conditions. Set variables for extending array u (v) !-- by one gridpoint on the left/rightmost (northest/southest) processor IF ( pleft == MPI_PROC_NULL ) THEN IF ( bc_lr == 'dirichlet/radiation' ) THEN inflow_l = .TRUE. ELSEIF ( bc_lr == 'radiation/dirichlet' ) THEN outflow_l = .TRUE. ENDIF ENDIF IF ( pright == MPI_PROC_NULL ) THEN IF ( bc_lr == 'dirichlet/radiation' ) THEN outflow_r = .TRUE. ELSEIF ( bc_lr == 'radiation/dirichlet' ) THEN inflow_r = .TRUE. ENDIF ! uxrp = 1 ENDIF IF ( psouth == MPI_PROC_NULL ) THEN IF ( bc_ns == 'dirichlet/radiation' ) THEN outflow_s = .TRUE. ELSEIF ( bc_ns == 'radiation/dirichlet' ) THEN inflow_s = .TRUE. ENDIF ENDIF IF ( pnorth == MPI_PROC_NULL ) THEN IF ( bc_ns == 'dirichlet/radiation' ) THEN inflow_n = .TRUE. ELSEIF ( bc_ns == 'radiation/dirichlet' ) THEN outflow_n = .TRUE. ENDIF ! vynp = 1 ENDIF ! !-- Additional MPI derived data type for the exchange of ghost points along x !-- needed in case of non-cyclic boundary conditions along y on the northmost !-- processors (for the exchange of the enlarged v array) IF ( bc_ns /= 'cyclic' .AND. pnorth == MPI_PROC_NULL ) THEN ngp_yz_p = ( nzt - nzb + 2 ) * ( nyn + vynp - nys + 3 ) CALL MPI_TYPE_VECTOR( nxr-nxl+3, nzt-nzb+2, ngp_yz_p, & MPI_REAL, type_xz_p, ierr ) CALL MPI_TYPE_COMMIT( type_xz_p, ierr ) ENDIF #else IF ( bc_lr == 'dirichlet/radiation' ) THEN inflow_l = .TRUE. outflow_r = .TRUE. ! uxrp = 1 ELSEIF ( bc_lr == 'radiation/dirichlet' ) THEN outflow_l = .TRUE. inflow_r = .TRUE. ENDIF IF ( bc_ns == 'dirichlet/radiation' ) THEN inflow_n = .TRUE. outflow_s = .TRUE. ELSEIF ( bc_ns == 'radiation/dirichlet' ) THEN outflow_n = .TRUE. inflow_s = .TRUE. ! vynp = 1 ENDIF #endif IF ( psolver == 'poisfft_hybrid' ) THEN CALL poisfft_hybrid_ini ELSE CALL poisfft_init ENDIF END SUBROUTINE init_pegrid