1 C -*- Mode: Fortran; -*-
4 C (C) 2011 by Argonne National Laboratory.
5 C See COPYRIGHT in top-level directory.
10 integer errs, ierr, intsize
11 integer i, displs(10), counts(10), dtype
13 parameter (bufsize=100)
14 integer inbuf(bufsize), outbuf(bufsize), packbuf(bufsize)
15 integer position, len, psize
20 call mtest_init( ierr )
22 call mpi_type_size( MPI_INTEGER, intsize, ierr )
25 displs(i) = (10-i)*intsize
28 call mpi_type_hindexed( 10, counts, displs, MPI_INTEGER, dtype,
30 call mpi_type_commit( dtype, ierr )
32 call mpi_pack_size( 1, dtype, MPI_COMM_WORLD, psize, ierr )
33 if (psize .gt. bufsize*intsize) then
41 call mpi_pack( inbuf, 1, dtype, packbuf, psize, position,
42 $ MPI_COMM_WORLD, ierr )
46 call mpi_unpack( packbuf, len, position, outbuf, 10,
47 $ MPI_INTEGER, MPI_COMM_WORLD, ierr )
50 if (outbuf(i) .ne. 11-i) then
52 print *, 'outbuf(',i,')=',outbuf(i),', expected ', 10-i
57 call mpi_type_free( dtype, ierr )
59 call mtest_finalize( errs )
60 call mpi_finalize( ierr )