1 C -*- Mode: Fortran; -*-
3 C (C) 2003 by Argonne National Laboratory.
4 C See COPYRIGHT in top-level directory.
6 subroutine MTest_Init( ierr )
7 C Place the include first so that we can automatically create a
8 C Fortran 90 version that uses the mpi module instead. If
9 C the module is in a different place, the compiler can complain
10 C about out-of-order statements
17 common /mtest/ dbgflag, wrank
19 call MPI_Initialized( flag, ierr )
25 call MPI_Comm_rank( MPI_COMM_WORLD, wrank, ierr )
28 subroutine MTest_Finalize( errs )
32 integer rank, toterrs, ierr
34 call MPI_Comm_rank( MPI_COMM_WORLD, rank, ierr )
36 call MPI_Allreduce( errs, toterrs, 1, MPI_INTEGER, MPI_SUM,
37 * MPI_COMM_WORLD, ierr )
40 if (toterrs .gt. 0) then
41 print *, " Found ", toterrs, " errors"
48 C A simple get intracomm for now
49 logical function MTestGetIntracomm( comm, min_size, qsmaller )
53 integer comm, min_size, size, rank
63 if (myindex .eq. 0) then
65 else if (myindex .eq. 1) then
66 call mpi_comm_dup( MPI_COMM_WORLD, comm, ierr )
67 else if (myindex .eq. 2) then
68 call mpi_comm_size( MPI_COMM_WORLD, size, ierr )
69 call mpi_comm_rank( MPI_COMM_WORLD, rank, ierr )
70 call mpi_comm_split( MPI_COMM_WORLD, 0, size - rank, comm,
73 if (min_size .eq. 1 .and. myindex .eq. 3) then
77 myindex = mod( myindex, 4 ) + 1
78 MTestGetIntracomm = comm .ne. MPI_COMM_NULL
81 subroutine MTestFreeComm( comm )
85 if (comm .ne. MPI_COMM_WORLD .and.
86 & comm .ne. MPI_COMM_SELF .and.
87 & comm .ne. MPI_COMM_NULL) then
88 call mpi_comm_free( comm, ierr )
92 subroutine MTestPrintError( errcode )
96 integer errclass, slen, ierr
97 character*(MPI_MAX_ERROR_STRING) string
99 call MPI_Error_class( errcode, errclass, ierr )
100 call MPI_Error_string( errcode, string, slen, ierr )
101 print *, "Error class ", errclass, "(", string(1:slen), ")"
104 subroutine MTestPrintErrorMsg( msg, errcode )
109 integer errclass, slen, ierr
110 character*(MPI_MAX_ERROR_STRING) string
112 call MPI_Error_class( errcode, errclass, ierr )
113 call MPI_Error_string( errcode, string, slen, ierr )
114 print *, msg, ": Error class ", errclass, "
115 $ (", string(1:slen), ")"