1 ! -*- Mode: Fortran; -*-
3 ! (C) 2007 by Argonne National Laboratory.
4 ! See COPYRIGHT in top-level directory.
6 ! This program tests that the MPI_SIZEOF routine is implemented for the
7 ! predefined scalar Fortran types. It confirms that the size of these
8 ! types matches the size of the corresponding MPI datatypes.
13 integer rank, size, mpisize
16 double precision d1,d1v(3)
24 call mtest_init ( ierr )
25 call mpi_comm_rank( MPI_COMM_WORLD, rank, ierr )
27 ! Test of scalar types
28 call mpi_sizeof( r1, size, ierr )
29 call mpi_type_size( MPI_REAL, mpisize, ierr )
30 if (size .ne. mpisize) then
32 print *, "Size of MPI_REAL = ", mpisize, &
33 & " but MPI_SIZEOF gives ", size
36 call mpi_sizeof( d1, size, ierr )
37 call mpi_type_size( MPI_DOUBLE_PRECISION, mpisize, ierr )
38 if (size .ne. mpisize) then
40 print *, "Size of MPI_DOUBLE_PRECISION = ", mpisize, &
41 " but MPI_SIZEOF gives ", size
44 call mpi_sizeof( i1, size, ierr )
45 call mpi_type_size( MPI_INTEGER, mpisize, ierr )
46 if (size .ne. mpisize) then
48 print *, "Size of MPI_INTEGER = ", mpisize, &
49 & " but MPI_SIZEOF gives ", size
52 call mpi_sizeof( c1, size, ierr )
53 call mpi_type_size( MPI_COMPLEX, mpisize, ierr )
54 if (size .ne. mpisize) then
56 print *, "Size of MPI_COMPLEX = ", mpisize, &
57 & " but MPI_SIZEOF gives ", size
60 call mpi_sizeof( ch1, size, ierr )
61 call mpi_type_size( MPI_CHARACTER, mpisize, ierr )
62 if (size .ne. mpisize) then
64 print *, "Size of MPI_CHARACTER = ", mpisize, &
65 " but MPI_SIZEOF gives ", size
68 call mpi_sizeof( l1, size, ierr )
69 call mpi_type_size( MPI_LOGICAL, mpisize, ierr )
70 if (size .ne. mpisize) then
72 print *, "Size of MPI_LOGICAL = ", mpisize, &
73 & " but MPI_SIZEOF gives ", size
76 ! Test of vector types (1-dimensional)
77 call mpi_sizeof( r1v, size, ierr )
78 call mpi_type_size( MPI_REAL, mpisize, ierr )
79 if (size .ne. mpisize) then
81 print *, "Size of MPI_REAL = ", mpisize, &
82 & " but MPI_SIZEOF gives ", size
85 call mpi_sizeof( d1v, size, ierr )
86 call mpi_type_size( MPI_DOUBLE_PRECISION, mpisize, ierr )
87 if (size .ne. mpisize) then
89 print *, "Size of MPI_DOUBLE_PRECISION = ", mpisize, &
90 " but MPI_SIZEOF gives ", size
93 call mpi_sizeof( i1v, size, ierr )
94 call mpi_type_size( MPI_INTEGER, mpisize, ierr )
95 if (size .ne. mpisize) then
97 print *, "Size of MPI_INTEGER = ", mpisize, &
98 & " but MPI_SIZEOF gives ", size
101 call mpi_sizeof( c1v, size, ierr )
102 call mpi_type_size( MPI_COMPLEX, mpisize, ierr )
103 if (size .ne. mpisize) then
105 print *, "Size of MPI_COMPLEX = ", mpisize, &
106 & " but MPI_SIZEOF gives ", size
109 call mpi_sizeof( ch1v, size, ierr )
110 call mpi_type_size( MPI_CHARACTER, mpisize, ierr )
111 if (size .ne. mpisize) then
113 print *, "Size of MPI_CHARACTER = ", mpisize, &
114 " but MPI_SIZEOF gives ", size
117 call mpi_sizeof( l1v, size, ierr )
118 call mpi_type_size( MPI_LOGICAL, mpisize, ierr )
119 if (size .ne. mpisize) then
121 print *, "Size of MPI_LOGICAL = ", mpisize, &
122 & " but MPI_SIZEOF gives ", size
125 call mtest_finalize( errs )
126 call mpi_finalize( ierr )