2 * Check that we can put names on communicators and get them back.
9 #if defined(NEEDS_STDLIB_PROTOTYPES)
13 int main( int argc, char **argv )
15 char commName [MPI_MAX_NAME_STRING+1];
18 MPI_Init( &argc, &argv );
20 if (MPI_Comm_get_name(MPI_COMM_WORLD, commName, &namelen) != MPI_SUCCESS)
22 printf("Failed to get a name from COMM_WORLD\n");
23 MPI_Abort(MPI_COMM_WORLD, -1);
26 if (strcmp("MPI_COMM_WORLD", commName))
28 printf("Name on MPI_COMM_WORLD is \"%s\" should be \"MPI_COMM_WORLD\"\n", commName);
29 MPI_Abort(MPI_COMM_WORLD, -1);
32 if (namelen != strlen (commName))
34 printf("Length of name on MPI_COMM_WORLD is %d should be %d\n",
35 namelen, (int) strlen(commName));
36 MPI_Abort(MPI_COMM_WORLD, -1);
39 /* Check that we can replace it */
40 if (MPI_Comm_set_name(MPI_COMM_WORLD,"foobar") != MPI_SUCCESS)
42 printf("Failed to put a name onto COMM_WORLD\n");
43 MPI_Abort(MPI_COMM_WORLD, -1);
46 if (MPI_Comm_get_name(MPI_COMM_WORLD, commName, &namelen) != MPI_SUCCESS)
48 printf("Failed to get a name from COMM_WORLD after changing it\n");
49 MPI_Abort(MPI_COMM_WORLD, -1);
52 if (strcmp("foobar", commName))
54 printf("Name on MPI_COMM_WORLD is \"%s\" should be \"foobar\"\n",
56 MPI_Abort(MPI_COMM_WORLD, -1);
59 printf("Name tests OK\n");