1 C -*- Mode: Fortran; -*-
3 C (C) 2004 by Argonne National Laboratory.
4 C See COPYRIGHT in top-level directory.
6 C Test various combinations of periodic and non-periodic Cartesian
13 integer ndims, nperiods, i, size
14 integer comm, source, dest, newcomm
17 logical periods(maxdims), outperiods(maxdims)
18 integer dims(maxdims), outdims(maxdims)
19 integer outcoords(maxdims)
22 call mtest_init( ierr )
25 C For up to 6 dimensions, test with periodicity in 0 through all
26 C dimensions. The test is computed by both:
27 C get info about the created communicator
29 C Note that a dimension can have size one, so that these tests
30 C can work with small numbers (even 1) of processes
33 call mpi_comm_size( comm, size, ierr )
35 do nperiods = 0, ndims
44 call mpi_dims_create( size, ndims, dims, ierr )
45 call mpi_cart_create( comm, ndims, dims, periods, .false.,
48 if (newcomm .ne. MPI_COMM_NULL) then
49 call mpi_cart_get( newcomm, maxdims, outdims, outperiods,
51 C print *, 'Coords = '
53 C print *, i, '(', outcoords(i), ')'
54 if (periods(i) .neqv. outperiods(i)) then
56 print *, ' Wrong value for periods ', i
57 print *, ' ndims = ', ndims
62 call mpi_cart_shift( newcomm, i-1, 1, source, dest,
64 if (outcoords(i) .eq. outdims(i)-1) then
66 if (dest .eq. MPI_PROC_NULL) then
68 print *, 'Expected rank, got proc_null'
71 if (dest .ne. MPI_PROC_NULL) then
73 print *, 'Expected procnull, got ', dest
78 call mpi_cart_shift( newcomm, i-1, -1, source, dest,
80 if (outcoords(i) .eq. 0) then
82 if (dest .eq. MPI_PROC_NULL) then
84 print *, 'Expected rank, got proc_null'
87 if (dest .ne. MPI_PROC_NULL) then
89 print *, 'Expected procnull, got ', dest
94 call mpi_comm_free( newcomm, ierr )
100 call mtest_finalize( errs )
101 call mpi_finalize( ierr )