Skip to content

Commit

Permalink
now running tst_pio_udf with mpiexec on 4 processors
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Jul 3, 2019
1 parent 0734bad commit 218f8e2
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/clib/pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
10 changes: 7 additions & 3 deletions tests/ncint/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@
# 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.
# TESTS = run_tests.sh
# 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
43 changes: 43 additions & 0 deletions tests/ncint/run_tests.sh
Original file line number Diff line number Diff line change
@@ -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
81 changes: 48 additions & 33 deletions tests/ncint/tst_pio_udf.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "err_macros.h"
#include "netcdf.h"
#include "nc4dispatch.h"
#include <pio.h>
#include <mpi.h>

#define FILE_NAME "tst_pio_udf.nc"

Expand All @@ -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;
}

0 comments on commit 218f8e2

Please sign in to comment.