1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2013 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
12 int key = MPI_KEYVAL_INVALID;
15 int delete_fn(MPI_Comm, int, void *, void *);
17 int main(int argc, char **argv)
22 MTest_Init(&argc, &argv);
23 MPI_Comm_split(MPI_COMM_WORLD, 1, 0, &scomm);
24 MPI_Comm_create_keyval(MPI_NULL_COPY_FN, delete_fn, &key, &errs);
25 MPI_Comm_set_attr(scomm, key, a);
26 MPI_Comm_free(&scomm);
27 MPI_Comm_free_keyval(&key);
33 int delete_fn(MPI_Comm comm, int keyval, void *attr_val, void *extra_state)
35 /* The standard is not explicit that the 'comm' argument of
36 * delete_fn must be valid, so this test is only in effect when
38 #ifndef USE_STRICT_MPI
39 int err, flg, *errs = extra_state;
42 if (comm == MPI_COMM_NULL) {
43 printf("MPI_COMM_NULL passed to delete_fn\n");
46 err = MPI_Comm_get_attr(comm, key, &ptr, &flg);
47 if (err != MPI_SUCCESS) {
48 printf("MPI_Comm_get_attr returned error %d, presumably due to invalid communicator\n",