77 */
88
99#include <errno.h>
10+ #include <mpi.h>
11+ #include <netdb.h>
1012#include <stdio.h>
1113#include <stdlib.h>
1214#include <string.h>
13- #include <netdb.h>
1415#include <unistd.h>
15- #include <mpi.h>
1616
17- int
18- main (int argc , char * * argv )
17+ int main (int argc , char * * argv )
1918{
20- MPI_Status status ;
21- int verbose = 0 ;
22- int rank ;
23- int np ; /* number of processes in job */
24- int peer ;
25- int i ;
26- int j ;
27- int length ;
28- char name [MPI_MAX_PROCESSOR_NAME + 1 ];
19+ MPI_Status status ;
20+ int verbose = 0 ;
21+ int rank ;
22+ int np ; /* number of processes in job */
23+ int peer ;
24+ int i ;
25+ int j ;
26+ int length ;
27+ char name [MPI_MAX_PROCESSOR_NAME + 1 ];
2928
3029 MPI_Init (& argc , & argv );
3130 MPI_Comm_rank (MPI_COMM_WORLD , & rank );
@@ -38,28 +37,27 @@ main(int argc, char **argv)
3837 strcpy (name , "unknown" );
3938 }
4039
41- if (argc > 1 && strcmp (argv [1 ], "-v" )== 0 )
40+ if (argc > 1 && strcmp (argv [1 ], "-v" ) == 0 )
4241 verbose = 1 ;
4342
44- for (i = 0 ; i < np ; i ++ ) {
45- if (rank == i ) {
43+ for (i = 0 ; i < np ; i ++ ) {
44+ if (rank == i ) {
4645 /* rank i sends to and receives from each higher rank */
47- for ( j = i + 1 ; j < np ; j ++ ) {
46+ for ( j = i + 1 ; j < np ; j ++ ) {
4847 if (verbose )
49- printf ("checking connection between rank %d on %s and rank %-4d\n" ,
50- i , name , j );
48+ printf ("checking connection between rank %d on %s and rank %-4d\n" , i , name , j );
5149 MPI_Send (& rank , 1 , MPI_INT , j , rank , MPI_COMM_WORLD );
5250 MPI_Recv (& peer , 1 , MPI_INT , j , j , MPI_COMM_WORLD , & status );
5351 }
54- } else if (rank > i ) {
52+ } else if (rank > i ) {
5553 /* receive from and reply to rank i */
5654 MPI_Recv (& peer , 1 , MPI_INT , i , i , MPI_COMM_WORLD , & status );
5755 MPI_Send (& rank , 1 , MPI_INT , i , rank , MPI_COMM_WORLD );
5856 }
5957 }
6058
6159 MPI_Barrier (MPI_COMM_WORLD );
62- if (rank == 0 )
60+ if (rank == 0 )
6361 printf ("Connectivity test on %d processes PASSED.\n" , np );
6462
6563 MPI_Finalize ();
0 commit comments