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
18 call MPI_Initialized( flag, ierr )
24 call MPI_Comm_rank( MPI_COMM_WORLD, wrank, ierr )
27 subroutine MTest_Finalize( errs )
31 integer rank, toterrs, ierr
33 call MPI_Comm_rank( MPI_COMM_WORLD, rank, ierr )
35 call MPI_Allreduce( errs, toterrs, 1, MPI_INTEGER, MPI_SUM,
36 * MPI_COMM_WORLD, ierr )
39 if (toterrs .gt. 0) then
40 print *, " Found ", toterrs, " errors"
47 C A simple get intracomm for now
48 logical function MTestGetIntracomm( comm, min_size, qsmaller )
52 integer comm, min_size, size, rank
62 if (myindex .eq. 0) then
64 else if (myindex .eq. 1) then
65 call mpi_comm_dup( MPI_COMM_WORLD, comm, ierr )
66 else if (myindex .eq. 2) then
67 call mpi_comm_size( MPI_COMM_WORLD, size, ierr )
68 call mpi_comm_rank( MPI_COMM_WORLD, rank, ierr )
69 call mpi_comm_split( MPI_COMM_WORLD, 0, size - rank, comm,
72 if (min_size .eq. 1 .and. myindex .eq. 3) then
76 myindex = mod( myindex, 4 ) + 1
77 MTestGetIntracomm = comm .ne. MPI_COMM_NULL
80 subroutine MTestFreeComm( comm )
84 if (comm .ne. MPI_COMM_WORLD .and.
85 & comm .ne. MPI_COMM_SELF .and.
86 & comm .ne. MPI_COMM_NULL) then
87 call mpi_comm_free( comm, ierr )
91 subroutine MTestPrintError( errcode )
95 integer errclass, slen, ierr
96 character*(MPI_MAX_ERROR_STRING) string
98 call MPI_Error_class( errcode, errclass, ierr )
99 call MPI_Error_string( errcode, string, slen, ierr )
100 print *, "Error class ", errclass, "(", string(1:slen), ")"
103 subroutine MTestPrintErrorMsg( msg, errcode )
108 integer errclass, slen, ierr
109 character*(MPI_MAX_ERROR_STRING) string
111 call MPI_Error_class( errcode, errclass, ierr )
112 call MPI_Error_string( errcode, string, slen, ierr )
113 print *, msg, ": Error class ", errclass, "
114 $ (", string(1:slen), ")"