testpar.h

00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00002  * Copyright by The HDF Group.                                               *
00003  * Copyright by the Board of Trustees of the University of Illinois.         *
00004  * All rights reserved.                                                      *
00005  *                                                                           *
00006  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00007  * terms governing use, modification, and redistribution, is contained in    *
00008  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00009  * of the source code distribution tree; Copyright.html can be found at the  *
00010  * root level of an installed copy of the electronic HDF5 document set and   *
00011  * is linked from the top-level documents page.  It can also be found at     *
00012  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00013  * access to either file, you may request a copy from help@hdfgroup.org.     *
00014  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00015 
00016 /* common definitions used by all parallel test programs. */
00017 
00018 #ifndef TESTPAR_H
00019 #define TESTPAR_H
00020 
00021 #include "h5test.h"
00022 
00023 /* Constants definitions */
00024 #define MAX_ERR_REPORT  10      /* Maximum number of errors reported */
00025 
00026 /* Define some handy debugging shorthands, routines, ... */
00027 /* debugging tools */
00028 
00029 #define MESG(x)                                                         \
00030         if (VERBOSE_MED) printf("%s\n", x);                                 \
00031 
00032 #define VRFY(val, mesg) do {                                            \
00033     if (val) {                                                          \
00034         if (*mesg != '\0') {                                            \
00035             MESG(mesg);                                                 \
00036         }                                                               \
00037     } else {                                                            \
00038         printf("Proc %d: ", mpi_rank);                                  \
00039         printf("*** PHDF5 ERROR ***\n");                                \
00040         printf("        Assertion (%s) failed at line %4d in %s\n",     \
00041                mesg, (int)__LINE__, __FILE__);                          \
00042         ++nerrors;                                                      \
00043         fflush(stdout);                                                 \
00044         if (!VERBOSE_MED) {                                                 \
00045             printf("aborting MPI process\n");                           \
00046             MPI_Finalize();                                             \
00047             exit(nerrors);                                              \
00048         }                                                               \
00049     }                                                                   \
00050 } while(0)
00051 
00052 /*
00053  * Checking for information purpose.
00054  * If val is false, print mesg; else nothing.
00055  * Either case, no error setting.
00056  */
00057 #define INFO(val, mesg) do {                                            \
00058     if (val) {                                                          \
00059         if (*mesg != '\0') {                                            \
00060             MESG(mesg);                                                 \
00061         }                                                               \
00062     } else {                                                            \
00063         printf("Proc %d: ", mpi_rank);                                  \
00064         printf("*** PHDF5 REMARK (not an error) ***\n");                \
00065         printf("        Condition (%s) failed at line %4d in %s\n",     \
00066                mesg, (int)__LINE__, __FILE__);                          \
00067         fflush(stdout);                                                 \
00068     }                                                                   \
00069 } while(0)
00070 
00071 #define MPI_BANNER(mesg) do {                                           \
00072     if (VERBOSE_MED || MAINPROCESS){                                    \
00073         printf("--------------------------------\n");                   \
00074         printf("Proc %d: ", mpi_rank);                                  \
00075         printf("*** %s\n", mesg);                                       \
00076         printf("--------------------------------\n");                   \
00077     }                                                                   \
00078 } while(0)
00079 
00080 #define MAINPROCESS     (!mpi_rank) /* define process 0 as main process */
00081 
00082 #define SYNC(comm) do {                                                 \
00083     MPI_BANNER("doing a SYNC");                                         \
00084     MPI_Barrier(comm);                                                  \
00085     MPI_BANNER("SYNC DONE");                                            \
00086 } while(0)
00087 
00088 /* End of Define some handy debugging shorthands, routines, ... */
00089 
00090 #endif /* TESTPAR_H */