diff --git a/src/clib/Makefile.am b/src/clib/Makefile.am index eba8240a83e..f753409e210 100644 --- a/src/clib/Makefile.am +++ b/src/clib/Makefile.am @@ -9,7 +9,7 @@ lib_LTLIBRARIES = libpio.la # for information regarding incrementing `-version-info`. libpio_la_LDFLAGS = -version-info 2:0:1 -# The header file. +# The library header file will be installed in include dir. include_HEADERS = pio.h # The library soure files. @@ -17,6 +17,6 @@ libpio_la_SOURCES = bget.c pioc_sc.c pio_darray.c pio_file.c \ pio_getput_int.c pio_msg.c pio_nc.c pio_rearrange.c pioc.c \ pioc_support.c pio_darray_int.c pio_get_nc.c pio_lists.c pio_nc4.c \ pio_put_nc.c pio_spmd.c pio_get_vard.c pio_put_vard.c pio_internal.h \ -bget.h uthash.h +bget.h uthash.h pio_error.h EXTRA_DIST = CMakeLists.txt diff --git a/src/clib/pio_error.h b/src/clib/pio_error.h new file mode 100644 index 00000000000..af4b0ed04e0 --- /dev/null +++ b/src/clib/pio_error.h @@ -0,0 +1,31 @@ +/** + * @file + * Macros to handle errors in tests or libray code. + * @author Ed Hartnett + * @date 2019 + * + * @see https://github.com/NCAR/ParallelIO + */ + +#ifndef __PIO_ERROR__ +#define __PIO_ERROR__ + +#include +#include + +/** Handle non-MPI errors by finalizing the MPI library and goto + * exit. Finalize and goto exit. */ +#define BAIL(e) do { \ + fprintf(stderr, "%d Error %d in %s, line %d\n", my_rank, e, __FILE__, __LINE__); \ + goto exit; \ + } while (0) + +/** Handle non-MPI errors by finalizing the MPI library and exiting + * with an exit code. Finalize and return. */ +#define ERR(e) do { \ + fprintf(stderr, "%d Error %d in %s, line %d\n", my_rank, e, __FILE__, __LINE__); \ + MPI_Finalize(); \ + return e; \ + } while (0) + +#endif /* __PIO_ERROR__ */ diff --git a/src/clib/pio_internal.h b/src/clib/pio_internal.h index 2f8ccf4c09c..4f3a3aebcbc 100644 --- a/src/clib/pio_internal.h +++ b/src/clib/pio_internal.h @@ -12,6 +12,7 @@ #include #include +#include #include #include #include diff --git a/tests/cunit/pio_tests.h b/tests/cunit/pio_tests.h index aa7d15e5e0e..9348254cb45 100644 --- a/tests/cunit/pio_tests.h +++ b/tests/cunit/pio_tests.h @@ -7,7 +7,7 @@ #ifndef _PIO_TESTS_H #define _PIO_TESTS_H - +#include #include /* Include this for the sleep function. */ #include @@ -99,21 +99,6 @@ void test_stop_mpe_log(int state, const char *msg); goto exit; \ } while (0) -/** Handle non-MPI errors by finalizing the MPI library and exiting - * with an exit code. Finalize and return. */ -#define ERR(e) do { \ - fprintf(stderr, "%d Error %d in %s, line %d\n", my_rank, e, __FILE__, __LINE__); \ - MPI_Finalize(); \ - return e; \ - } while (0) - -/** Handle non-MPI errors by finalizing the MPI library and goto - * exit. Finalize and goto exit. */ -#define BAIL(e) do { \ - fprintf(stderr, "%d Error %d in %s, line %d\n", my_rank, e, __FILE__, __LINE__); \ - goto exit; \ - } while (0) - /** Global err buffer for MPI. When there is an MPI error, this buffer * is used to store the error message that is associated with the MPI * error. */