Skip to content

Commit

Permalink
Merge pull request #2284 from edwardhartnett/ejh_pnetcdf_tests
Browse files Browse the repository at this point in the history
fixing some of the problems with nc_test when --enable-pnetcdf is used
  • Loading branch information
WardF authored Apr 11, 2022
2 parents 1cb28a9 + 0b044b1 commit cda16fd
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 36 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1976,6 +1976,7 @@ AC_CONFIG_FILES(ncdap_test/findtestserver.c:ncdap_test/findtestserver.c.in)
AC_CONFIG_FILES(dap4_test/findtestserver4.c:ncdap_test/findtestserver.c.in)
AC_CONFIG_FILES(dap4_test/pingurl4.c:ncdap_test/pingurl.c)
AC_CONFIG_FILES([h5_test/run_par_tests.sh], [chmod ugo+x h5_test/run_par_tests.sh])
AC_CONFIG_FILES([nc_test/run_pnetcdf_tests.sh], [chmod ugo+x nc_test/run_pnetcdf_tests.sh])
AC_CONFIG_FILES([nc_test4/run_par_test.sh], [chmod ugo+x nc_test4/run_par_test.sh])
AC_CONFIG_FILES([nc_perf/run_par_bm_test.sh], [chmod ugo+x nc_perf/run_par_bm_test.sh])
AC_CONFIG_FILES([nc_perf/run_gfs_test.sh], [chmod ugo+x nc_perf/run_gfs_test.sh])
Expand Down
40 changes: 22 additions & 18 deletions nc_test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,26 @@ AM_CPPFLAGS += -I$(top_builddir)/liblib -I$(top_builddir)/include -I$(top_srcdir

TEST_EXTENSIONS = .sh

check_PROGRAMS =

# These are the tests which are always run.
TESTPROGRAMS = t_nc tst_small nc_test tst_misc tst_norm tst_names \
tst_nofill tst_nofill2 tst_nofill3 tst_atts3 tst_meta tst_inq_type \
tst_utf8_validate tst_utf8_phrases tst_global_fillval \
TESTPROGRAMS = tst_names tst_nofill2 tst_nofill3 tst_meta \
tst_inq_type tst_utf8_validate tst_utf8_phrases tst_global_fillval \
tst_max_var_dims tst_formats tst_def_var_fill tst_err_enddef \
tst_default_format

# These are always built, but for parallel builds are run from a test
# script, because they are parallel-enabled tests.
check_PROGRAMS = t_nc tst_atts3 tst_nofill nc_test tst_small

# These tests are only run if pnetcdf is enabled.
if USE_PNETCDF
check_PROGRAMS += tst_parallel2 tst_pnetcdf tst_addvar
TESTPROGRAMS += tst_formatx_pnetcdf tst_default_format_pnetcdf
check_PROGRAMS += tst_parallel2 tst_pnetcdf tst_addvar \
tst_formatx_pnetcdf tst_default_format_pnetcdf
endif

if TEST_PARALLEL4
if USE_PNETCDF
if ENABLE_CDF5
TESTPROGRAMS += tst_cdf5format
check_PROGRAMS += tst_cdf5format
endif
endif
endif
Expand Down Expand Up @@ -94,21 +96,23 @@ run_mmap.log: run_diskless.log
endif
endif

# If pnetcdf is enabled, these tests are run by a test
# script. Otherwise, the are run by automake in the usual way.
if USE_PNETCDF
TESTS += run_pnetcdf_test.sh
TESTS += run_pnetcdf_tests.sh
else
TESTS += t_nc tst_atts3 tst_nofill nc_test tst_small
endif

# The .c files that are generated with m4 are already distributed, but
# we also include the original m4 files, plus test scripts data.
EXTRA_DIST = test_get.m4 test_put.m4 run_diskless.sh run_diskless2.sh \
run_diskless5.sh run_mmap.sh run_pnetcdf_test.sh test_read.m4 \
test_write.m4 ref_tst_diskless2.cdl tst_diskless5.cdl \
ref_tst_diskless3_create.cdl ref_tst_diskless3_open.cdl \
run_inmemory.sh run_mmap.sh \
f03tst_open_mem.nc \
test_byterange.sh ref_tst_http_nc3.cdl \
ref_tst_http_nc4a.cdl ref_tst_http_nc4b.cdl ref_tst_http_nc4c.cdl \
CMakeLists.txt
EXTRA_DIST = test_get.m4 test_put.m4 run_diskless.sh run_diskless2.sh \
run_diskless5.sh run_mmap.sh run_pnetcdf_test.sh test_read.m4 \
test_write.m4 ref_tst_diskless2.cdl tst_diskless5.cdl \
ref_tst_diskless3_create.cdl ref_tst_diskless3_open.cdl \
run_inmemory.sh run_mmap.sh f03tst_open_mem.nc test_byterange.sh \
ref_tst_http_nc3.cdl ref_tst_http_nc4a.cdl ref_tst_http_nc4b.cdl \
ref_tst_http_nc4c.cdl CMakeLists.txt run_pnetcdf_tests.sh.in

# These files are created by the tests.
CLEANFILES = nc_test_*.nc tst_*.nc t_nc.nc large_files.nc \
Expand Down
14 changes: 0 additions & 14 deletions nc_test/run_pnetcdf_test.sh

This file was deleted.

26 changes: 26 additions & 0 deletions nc_test/run_pnetcdf_tests.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

# This script runs some PnetCDF I/O tests

set -e
echo
echo "Testing file created with PnetCDF is modifiable with netCDF..."
./tst_pnetcdf

echo "Testing file created with PnetCDF works when adding variables..."
./tst_addvar tst_pnetcdf.nc

# We assume a min of at least 2 processors is available
@MPIEXEC@ -n 2 ./tst_parallel2

# These tests work in either serial or parallel builds.
@MPIEXEC@ -n 1 ./t_nc
@MPIEXEC@ -n 1 ./tst_atts3
@MPIEXEC@ -n 1 ./tst_nofill
@MPIEXEC@ -n 1 ./nc_test
@MPIEXEC@ -n 1 ./tst_default_format_pnetcdf
@MPIEXEC@ -n 1 ./tst_small
@MPIEXEC@ -n 1 ./tst_formatx_pnetcdf
@MPIEXEC@ -n 1 ./tst_cdf5format


3 changes: 2 additions & 1 deletion nc_test/tst_nofill.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,9 @@ main(int argc, char **argv)
if (nc_close(ncid2)) ERR;
SUMMARIZE_ERR;
}
FINAL_RESULTS;

#ifdef USE_PNETCDF
MPI_Finalize();
#endif
FINAL_RESULTS;
}
9 changes: 6 additions & 3 deletions nc_test/tst_pnetcdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ int main(int argc, char* argv[])
size_t start[2], count[2];
MPI_Comm comm=MPI_COMM_SELF;
MPI_Info info=MPI_INFO_NULL;

char file_name[NC_MAX_NAME + 1];

printf("\n*** Testing bug fix with changing PnetCDF variable offsets...");

MPI_Init(&argc,&argv);
Expand All @@ -63,7 +64,9 @@ int main(int argc, char* argv[])
#endif

cmode = NC_CLOBBER;
st = nc_create_par(FILENAME, cmode, comm, info, &ncid);
sprintf(file_name, "%s/%s", TEMP_LARGE, FILENAME);
st = nc_create_par(file_name, cmode, comm, info, &ncid);

#ifdef USE_PNETCDF
CHK_ERR(st)
#else
Expand Down Expand Up @@ -109,7 +112,7 @@ int main(int argc, char* argv[])
if (info != MPI_INFO_NULL) MPI_Info_free(&info);

/* re-open the file with netCDF (parallel) and enter define mode */
st = nc_open_par(FILENAME, NC_WRITE, comm, info, &ncid); CHK_ERR(st)
st = nc_open_par(file_name, NC_WRITE, comm, info, &ncid); CHK_ERR(st)

st = nc_redef(ncid); CHK_ERR(st)

Expand Down

0 comments on commit cda16fd

Please sign in to comment.