1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2001 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
11 void MissingKeyval(int rc, const char keyname[]);
13 int main(int argc, char **argv)
22 MTest_Init(&argc, &argv);
23 MPI_Comm_size(MPI_COMM_WORLD, &size);
24 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
26 /* Set errors return so that we can provide better information
27 * should a routine reject one of the attribute values */
28 MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
30 rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_TAG_UB, &v, &flag);
32 MissingKeyval(rc, "MPI_TAG_UB");
38 fprintf(stderr, "Could not get TAG_UB\n");
44 fprintf(stderr, "Got too-small value (%d) for TAG_UB\n", vval);
49 rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_HOST, &v, &flag);
51 MissingKeyval(rc, "MPI_HOST");
57 fprintf(stderr, "Could not get HOST\n");
61 if ((vval < 0 || vval >= size) && vval != MPI_PROC_NULL) {
63 fprintf(stderr, "Got invalid value %d for HOST\n", vval);
68 rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_IO, &v, &flag);
70 MissingKeyval(rc, "MPI_IO");
76 fprintf(stderr, "Could not get IO\n");
80 if ((vval < 0 || vval >= size) && vval != MPI_ANY_SOURCE && vval != MPI_PROC_NULL) {
82 fprintf(stderr, "Got invalid value %d for IO\n", vval);
87 rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_WTIME_IS_GLOBAL, &v, &flag);
89 MissingKeyval(rc, "MPI_WTIME_IS_GLOBAL");
94 /* Wtime need not be set */
96 if (vval < 0 || vval > 1) {
98 fprintf(stderr, "Invalid value for WTIME_IS_GLOBAL (got %d)\n", vval);
103 rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_APPNUM, &v, &flag);
105 MissingKeyval(rc, "MPI_APPNUM");
109 /* appnum need not be set */
114 fprintf(stderr, "MPI_APPNUM is defined as %d but must be nonnegative\n", vval);
119 rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, &v, &flag);
121 MissingKeyval(rc, "MPI_UNIVERSE_SIZE");
125 /* MPI_UNIVERSE_SIZE need not be set */
130 fprintf(stderr, "MPI_UNIVERSE_SIZE = %d, less than comm world (%d)\n", vval, size);
135 rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_LASTUSEDCODE, &v, &flag);
137 MissingKeyval(rc, "MPI_LASTUSEDCODE");
141 /* Last used code must be defined and >= MPI_ERR_LASTCODE */
144 if (vval < MPI_ERR_LASTCODE) {
147 "MPI_LASTUSEDCODE points to an integer (%d) smaller than MPI_ERR_LASTCODE (%d)\n",
148 vval, MPI_ERR_LASTCODE);
153 fprintf(stderr, "MPI_LASTUSECODE is not defined\n");
157 MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
159 MTest_Finalize(errs);
165 void MissingKeyval(int errcode, const char keyname[])
168 char string[MPI_MAX_ERROR_STRING];
170 MPI_Error_class(errcode, &errclass);
171 MPI_Error_string(errcode, string, &slen);
172 printf("For key %s: Error class %d (%s)\n", keyname, errclass, string);