From 218f8e27efd6cac58cc6be16c80452ff25d12d83 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Wed, 3 Jul 2019 13:30:36 -0600 Subject: [PATCH] now running tst_pio_udf with mpiexec on 4 processors --- src/clib/pio.h | 2 +- tests/ncint/Makefile.am | 10 +++-- tests/ncint/run_tests.sh | 43 +++++++++++++++++++++ tests/ncint/tst_pio_udf.c | 81 +++++++++++++++++++++++---------------- 4 files changed, 99 insertions(+), 37 deletions(-) create mode 100755 tests/ncint/run_tests.sh diff --git a/src/clib/pio.h b/src/clib/pio.h index 4d859912028..2635bcdb989 100644 --- a/src/clib/pio.h +++ b/src/clib/pio.h @@ -1246,7 +1246,7 @@ extern "C" { int PIOc_put_vard_ulonglong(int ncid, int varid, int decompid, const PIO_Offset recnum, const unsigned long long *op); - + /* These functions are for the netCDF integration layer. */ int nc_init_intracomm(MPI_Comm comp_comm, int num_iotasks, int stride, int base, int rearr, int *iosysidp); diff --git a/tests/ncint/Makefile.am b/tests/ncint/Makefile.am index b7078557882..e5d41d2f2b1 100644 --- a/tests/ncint/Makefile.am +++ b/tests/ncint/Makefile.am @@ -4,12 +4,16 @@ # Ed Hartnett 7/3/19 # Put together AM_CPPFLAGS and AM_LDFLAGS. -include $(top_srcdir)/set_flags.am +AM_CPPFLAGS = -I$(top_srcdir)/src/clib LDADD = ${top_builddir}/src/clib/libpioc.la # Build the test for make check. check_PROGRAMS = tst_pio_udf -TESTS = tst_pio_udf + +if RUN_TESTS +# Tests will run from a bash script. +TESTS = run_tests.sh +endif # RUN_TESTS # if RUN_TESTS # # Tests will run from a bash script. @@ -17,7 +21,7 @@ TESTS = tst_pio_udf # endif # RUN_TESTS # Distribute the test script. -#EXTRA_DIST = CMakeLists.txt run_tests.sh input.nl +EXTRA_DIST = run_tests.sh # Clean up files produced during testing. #CLEANFILES = *.nc *.log diff --git a/tests/ncint/run_tests.sh b/tests/ncint/run_tests.sh new file mode 100755 index 00000000000..442128fa443 --- /dev/null +++ b/tests/ncint/run_tests.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# This is a test script for PIO. +# Ed Hartnett + +# Stop execution of script if error is returned. +set -e + +# Stop loop if ctrl-c is pressed. +trap exit INT TERM + +printf 'running PIO tests...\n' + +PIO_TESTS='tst_pio_udf' + +success1=true +success2=true +for TEST in $PIO_TESTS +do + success1=false + echo "running ${TEST}" + mpiexec -n 4 ./${TEST} && success1=true + if test $success1 = false; then + break + fi +done + +# PIO_TESTS_8='test_async_multi2 test_async_manyproc' + +# for TEST in $PIO_TESTS_8 +# do +# success2=false +# echo "running ${TEST}" +# mpiexec -n 8 ./${TEST} && success2=true +# if test $success2 = false; then +# break +# fi +# done + +# Did we succeed? +if test x$success1 = xtrue -a x$success2 = xtrue; then + exit 0 +fi +exit 1 diff --git a/tests/ncint/tst_pio_udf.c b/tests/ncint/tst_pio_udf.c index 4c21bca4dd4..f0c4617c97c 100644 --- a/tests/ncint/tst_pio_udf.c +++ b/tests/ncint/tst_pio_udf.c @@ -8,6 +8,8 @@ #include "err_macros.h" #include "netcdf.h" #include "nc4dispatch.h" +#include +#include #define FILE_NAME "tst_pio_udf.nc" @@ -16,37 +18,50 @@ extern NC_Dispatch NCINT_dispatcher; int main(int argc, char **argv) { - printf("\n*** Testing netCDF integration layer.\n"); - printf("*** testing simple use of netCDF integration layer format..."); - { - int ncid; - int iosysid; - NC_Dispatch *disp_in; - - /* Create an empty file to play with. */ - if (nc_create(FILE_NAME, 0, &ncid)) ERR; - if (nc_close(ncid)) ERR; - - /* Initialize the intracomm. */ - if (nc_init_intracomm(NULL, 1, 1, 0, 0, &iosysid)) ERR; - - /* Add our user defined format. */ - if (nc_def_user_format(NC_UDF0, &NCINT_dispatcher, NULL)) ERR; - - /* Check that our user-defined format has been added. */ - if (nc_inq_user_format(NC_UDF0, &disp_in, NULL)) ERR; - if (disp_in != &NCINT_dispatcher) ERR; - - /* Open file with our defined functions. */ - if (nc_open(FILE_NAME, NC_UDF0, &ncid)) ERR; - if (nc_close(ncid)) ERR; - - /* Open file again and abort, which is the same as closing it. */ - if (nc_open(FILE_NAME, NC_UDF0, &ncid)) ERR; - if (nc_inq_format(ncid, NULL) != TEST_VAL_42) ERR; - if (nc_inq_format_extended(ncid, NULL, NULL) != TEST_VAL_42) ERR; - if (nc_abort(ncid) != TEST_VAL_42) ERR; - } - SUMMARIZE_ERR; - FINAL_RESULTS; + int my_rank; + int ntasks; + + /* Initialize MPI. */ + if (MPI_Init(&argc, &argv)) ERR; + + /* Learn my rank and the total number of processors. */ + if (MPI_Comm_rank(MPI_COMM_WORLD, &my_rank)) ERR; + if (MPI_Comm_size(MPI_COMM_WORLD, &ntasks)) ERR; + + printf("\n*** Testing netCDF integration layer.\n"); + printf("*** testing simple use of netCDF integration layer format..."); + { + int ncid; + int iosysid; + NC_Dispatch *disp_in; + + /* Create an empty file to play with. */ + if (nc_create(FILE_NAME, 0, &ncid)) ERR; + if (nc_close(ncid)) ERR; + + /* Initialize the intracomm. */ + if (nc_init_intracomm(MPI_COMM_WORLD, 1, 1, 0, 0, &iosysid)) ERR; + + /* Add our user defined format. */ + if (nc_def_user_format(NC_UDF0, &NCINT_dispatcher, NULL)) ERR; + + /* Check that our user-defined format has been added. */ + if (nc_inq_user_format(NC_UDF0, &disp_in, NULL)) ERR; + if (disp_in != &NCINT_dispatcher) ERR; + + /* Open file with our defined functions. */ + if (nc_open(FILE_NAME, NC_UDF0, &ncid)) ERR; + if (nc_close(ncid)) ERR; + + /* Open file again and abort, which is the same as closing it. */ + if (nc_open(FILE_NAME, NC_UDF0, &ncid)) ERR; + if (nc_inq_format(ncid, NULL) != TEST_VAL_42) ERR; + if (nc_inq_format_extended(ncid, NULL, NULL) != TEST_VAL_42) ERR; + if (nc_abort(ncid) != TEST_VAL_42) ERR; + } + SUMMARIZE_ERR; + + /* Finalize MPI. */ + MPI_Finalize(); + FINAL_RESULTS; }