1 C -*- Mode: Fortran; -*-
3 C (C) 2003 by Argonne National Laboratory.
4 C See COPYRIGHT in top-level directory.
10 integer i, intsize, ans, size, rank, color, comm, newcomm
12 parameter (maxSize=32)
13 integer scounts(maxSize), sdispls(maxSize), stypes(maxSize)
14 integer rcounts(maxSize), rdispls(maxSize), rtypes(maxSize)
15 integer sbuf(maxSize), rbuf(maxSize)
18 call mtest_init( ierr )
20 call mpi_type_size( MPI_INTEGER, intsize, ierr )
23 call mpi_comm_dup( MPI_COMM_WORLD, comm, ierr )
24 call mpi_comm_size( comm, size, ierr )
25 if (size .gt. maxSize) then
26 call mpi_comm_rank( comm, rank, ierr )
28 if (rank .lt. maxSize) color = 0
29 call mpi_comm_split( comm, color, rank, newcomm, ierr )
30 call mpi_comm_free( comm, ierr )
32 call mpi_comm_size( comm, size, ierr )
34 call mpi_comm_rank( comm, rank, ierr )
36 if (size .le. maxSize) then
37 C Initialize the data. Just use this as an all to all
40 sdispls(i) = (i-1)*intsize
41 stypes(i) = MPI_INTEGER
42 sbuf(i) = rank * size + i
44 rdispls(i) = (i-1)*intsize
45 rtypes(i) = MPI_INTEGER
48 call mpi_alltoallw( sbuf, scounts, sdispls, stypes,
49 & rbuf, rcounts, rdispls, rtypes, comm, ierr )
51 C check rbuf(i) = data from the ith location of the ith send buf, or
52 C rbuf(i) = (i-1) * size + i
54 ans = (i-1) * size + rank + 1
55 if (rbuf(i) .ne. ans) then
57 print *, rank, ' rbuf(', i, ') = ', rbuf(i),
62 call mpi_comm_free( comm, ierr )
64 call mtest_finalize( errs )
65 call mpi_finalize( ierr )