From b8ad15b6aef485b3d0c6c9c0a8c4d60038e55859 Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Tue, 15 May 2018 08:09:52 -0600 Subject: [PATCH] tests for ncdump issue with irish rover --- nc_test4/tst_enums.c | 48 +++++++++++++ nc_test4/tst_parallel5.c | 122 +++++++++++++++++++++++++--------- ncdump/Makefile.am | 2 +- ncdump/ref_tst_irish_rover.nc | Bin 0 -> 8224 bytes ncdump/run_tests.sh | 2 + 5 files changed, 143 insertions(+), 31 deletions(-) create mode 100644 ncdump/ref_tst_irish_rover.nc diff --git a/nc_test4/tst_enums.c b/nc_test4/tst_enums.c index 34c2021c2..963843cba 100644 --- a/nc_test4/tst_enums.c +++ b/nc_test4/tst_enums.c @@ -309,7 +309,55 @@ main(int argc, char **argv) if (nc_insert_enum(ncid, typeid, "name", &ubyte_value)) ERR; if (nc_close(ncid)) ERR; } + SUMMARIZE_ERR; + printf("*** testing enum ncdump..."); +#define ENUM_NAME "cargo" +#define ENUM_VAR_NAME "in_the_hold_of_the_Irish_Rover" +#define NUM_ENUM_FIELDS 8 +#define DIMSIZE 4 +#define NDIMS1 1 + { + int ncid, dimid, v1id, typeid; + int f; + size_t start[NDIMS1] = {0}, count[NDIMS1] = {1}; + char field_name[NUM_ENUM_FIELDS][NC_MAX_NAME + 1] = {"bags of the best Sligo rags", "barrels of bones", + "bails of old nanny goats' tails", "barrels of stones", + "dogs", "hogs", "barrels of porter", + "sides of old blind horses hides"}; + unsigned long long field_value[NUM_ENUM_FIELDS] = {1000000, 2000000, 3000000, 4000000, + 5000000, 6000000, 7000000, 8000000}; + unsigned long long data = 1000000, data_in; + + /* Create a parallel netcdf-4 file. */ + /*nc_set_log_level(3);*/ + if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; + + /* Create a dimension. */ + if (nc_def_dim(ncid, DIM_NAME, DIMSIZE, &dimid)) ERR; + + /* Create an enum type. */ + if (nc_def_enum(ncid, NC_UINT64, ENUM_NAME, &typeid)) ERR; + for (f = 0; f < NUM_ENUM_FIELDS; f++) + if (nc_insert_enum(ncid, typeid, field_name[f], &field_value[f])) ERR; + + /* Create one var. */ + if (nc_def_var(ncid, ENUM_VAR_NAME, typeid, NDIMS1, &dimid, &v1id)) ERR; + + /* Write metadata to file. */ + if (nc_enddef(ncid)) ERR; + + /* Write phoney data. */ + if (nc_put_vara(ncid, v1id, start, count, &data)) ERR; + + if (nc_sync(ncid)) ERR; + /* Read phoney data. */ + if (nc_get_vara(ncid, v1id, start, count, &data_in)) ERR; + if (data_in != data) ERR; + + /* Close the netcdf file. */ + if (nc_close(ncid)) ERR; + } SUMMARIZE_ERR; FINAL_RESULTS; } diff --git a/nc_test4/tst_parallel5.c b/nc_test4/tst_parallel5.c index 77706e8b5..0ed869ec6 100644 --- a/nc_test4/tst_parallel5.c +++ b/nc_test4/tst_parallel5.c @@ -42,55 +42,117 @@ main(int argc, char **argv) if (mpi_size != NUM_PROC) ERR; if (!mpi_rank) + printf("\n*** Testing parallel I/O.\n"); + + if (!mpi_rank) + printf("*** testing whether we can write 0 elements from some tasks..."); { - printf("\n*** tst_parallel testing collective parallel access.\n"); - printf("*** tst_parallel testing whether we can write 0 elements from some tasks..."); - } + for (acc = 0; acc < NUM_ACCESS_TESTS; acc++) + { + /* Create a parallel netcdf-4 file. */ + /*nc_set_log_level(3);*/ + if (nc_create_par(FILE, NC_NETCDF4|NC_MPIIO, comm, info, &ncid)) ERR; - for (acc = 0; acc < NUM_ACCESS_TESTS; acc++) + /* Create a dimension. */ + if (nc_def_dim(ncid, DIM_NAME, DIMSIZE, &dimid)) ERR; + + /* Create one var. */ + if (nc_def_var(ncid, VAR_NAME, NC_INT, NDIMS1, &dimid, &v1id)) ERR; + + /* Write metadata to file. */ + if (nc_enddef(ncid)) ERR; + + /* Set up slab for this process. */ + if (!mpi_rank) + count[0] = 1; + + if (nc_var_par_access(ncid, v1id, acc ? NC_COLLECTIVE : NC_INDEPENDENT)) ERR; + + /* Write phoney data. */ + if (nc_put_vara_int(ncid, v1id, start, count, &data)) ERR; + + if (nc_sync(ncid)) ERR; + + /* Read phoney data. */ + if (nc_get_vara_int(ncid, v1id, start, count, &data_in)) ERR; + + /* Task 0 has MASTS, the others have data_in remaining, as + * initialized, at TEST_VAL_42. */ + if (data_in != (mpi_rank ? TEST_VAL_42 : MASTS)) ERR; + + /* Close the netcdf file. */ + if (nc_close(ncid)) ERR; + } + } + if (!mpi_rank) + SUMMARIZE_ERR; + + if (!mpi_rank) + printf("*** testing enum type and parallel I/O..."); { - /* Create a parallel netcdf-4 file. */ - /*nc_set_log_level(3);*/ - if (nc_create_par(FILE, NC_NETCDF4|NC_MPIIO, comm, info, &ncid)) ERR; + for (acc = 0; acc < NUM_ACCESS_TESTS; acc++) + { +#define ENUM_NAME "cargo" +#define ENUM_VAR_NAME "in_the_hold_of_the_Irish_Rover" +#define NUM_ENUM_FIELDS 8 + int typeid; + int f; + char field_name[NUM_ENUM_FIELDS][NC_MAX_NAME + 1] = {"bags of the best Sligo rags", "barrels of bones", + "bails of old nanny goats' tails", "barrels of stones", + "dogs", "hogs", "barrels of porter", + "sides of old blind horses hides"}; + unsigned long long field_value[NUM_ENUM_FIELDS] = {1000000, 2000000, 3000000, 4000000, + 5000000, 6000000, 7000000, 8000000}; + unsigned long long data = 1000000; + + /* Create a parallel netcdf-4 file. */ + /*nc_set_log_level(3);*/ + if (nc_create_par(FILE, NC_NETCDF4|NC_MPIIO, comm, info, &ncid)) ERR; - /* Create a dimension. */ - if (nc_def_dim(ncid, DIM_NAME, DIMSIZE, &dimid)) ERR; + /* Create a dimension. */ + if (nc_def_dim(ncid, DIM_NAME, DIMSIZE, &dimid)) ERR; - /* Create one var. */ - if (nc_def_var(ncid, VAR_NAME, NC_INT, NDIMS1, &dimid, &v1id)) ERR; + /* Create an enum type. */ + if (nc_def_enum(ncid, NC_UINT64, ENUM_NAME, &typeid)) ERR; + for (f = 0; f < NUM_ENUM_FIELDS; f++) + if (nc_insert_enum(ncid, typeid, field_name[f], &field_value[f])) ERR; - /* Write metadata to file. */ - if (nc_enddef(ncid)) ERR; + /* Create one var. */ + if (nc_def_var(ncid, ENUM_VAR_NAME, typeid, NDIMS1, &dimid, &v1id)) ERR; - /* Set up slab for this process. */ - if (!mpi_rank) - count[0] = 1; + /* Write metadata to file. */ + if (nc_enddef(ncid)) ERR; - if (nc_var_par_access(ncid, v1id, acc ? NC_COLLECTIVE : NC_INDEPENDENT)) ERR; + /* Set up slab for this process. */ + if (!mpi_rank) + count[0] = 1; - /* Write phoney data. */ - if (nc_put_vara_int(ncid, v1id, start, count, &data)) ERR; + if (nc_var_par_access(ncid, v1id, acc ? NC_COLLECTIVE : NC_INDEPENDENT)) ERR; - if (nc_sync(ncid)) ERR; + /* Write phoney data. */ + if (nc_put_vara(ncid, v1id, start, count, &data)) ERR; - /* Read phoney data. */ - if (nc_get_vara_int(ncid, v1id, start, count, &data_in)) ERR; + if (nc_sync(ncid)) ERR; - /* Task 0 has MASTS, the others have data_in remaining, as - * initialized, at TEST_VAL_42. */ - if (data_in != (mpi_rank ? TEST_VAL_42 : MASTS)) ERR; + /* Read phoney data. */ + /* if (nc_get_vara_int(ncid, v1id, start, count, &data_in)) ERR; */ - /* Close the netcdf file. */ - if (nc_close(ncid)) ERR; + /* /\* Task 0 has MASTS, the others have data_in remaining, as */ + /* * initialized, at TEST_VAL_42. *\/ */ + /* if (data_in != (mpi_rank ? TEST_VAL_42 : MASTS)) ERR; */ + + /* Close the netcdf file. */ + if (nc_close(ncid)) ERR; + } } + if (!mpi_rank) + SUMMARIZE_ERR; /* Shut down MPI. */ MPI_Finalize(); if (!mpi_rank) - { - SUMMARIZE_ERR; FINAL_RESULTS; - } + return 0; } diff --git a/ncdump/Makefile.am b/ncdump/Makefile.am index 3a9744244..0629c2087 100644 --- a/ncdump/Makefile.am +++ b/ncdump/Makefile.am @@ -130,7 +130,7 @@ tst_hdf5_offset.sh run_ncgen_nc4_tests.sh tst_nccopy3_subset.sh \ ref_nccopy3_subset.nc ref_test_corrupt_magic.nc tst_ncgen_shared.sh \ tst_ncgen4.sh tst_ncgen4_classic.sh tst_ncgen4_diff.sh \ tst_ncgen4_cycle.sh tst_null_byte_padding.sh \ -ref_null_byte_padding_test.nc +ref_null_byte_padding_test.nc ref_tst_irish_rover.nc # The L512.bin file is file containing exactly 512 bytes each of value 0. # It is used for creating hdf5 files with varying offsets for testing. diff --git a/ncdump/ref_tst_irish_rover.nc b/ncdump/ref_tst_irish_rover.nc new file mode 100644 index 0000000000000000000000000000000000000000..d054204e344731bf533ddd5e8f9c97cd4209c4cb GIT binary patch literal 8224 zcmeHM&1(};5T8w&5=&}h)qaT7XF)wRG*Wvjq)k#AnkFTwA}FN0-A%F@cgyZtuoM*W zP^sSa;?0ZT%}=Q4snC;GkKX(z1f6+rUrmcqZz8-&cjvt~znQ-Iy_sc09?a!tdwWjw z07*O!U6ABMdHWs;V`4?lrF~frI_UCTt`bRniHvf4G#bKWn1i|}0vbV%pTwO2L^U{w zkn_Y1!f9|A;`phRvWuR(YI%We`M7=*uPnFY4Q0*peA{)V(i@HyteEwdZOEmG)MV=X zm}#w9EqC>%b_IK*%ro>I7Oi&eK}GDmlu+pOX0 zfq#w#I$AL9o}VAIIhw8r+zfRaZq@Yy%j3}jeA~46f2H_F%XUoGbUh!}nq+~@Odm(y zy+6YB$DJ|Zd1#93%zRPUA6*spPuGRLe_d$2m$P&8g3M=OIm}2~NbbE??7@!(#aw=I0=iL}dNETg-NZ!UB|hyj{wUGn6jcv4To4(d(|TR4Rg+o|ERrq;y1uDNwS zE_k-ztW{im5MBz)YWMxqJ_;?{1sH_^ss84%yhwNr`mjBQ+S;O6s4f8vqm9~T5HETZ z%C?p%?9&7!3|?E4Tcf;$-(pMi=mAErOppcqgLC test2_ncdump.cdl echo "*** checking that test1_ncdump.cdl and test2_ncdump.cdl are the same..." diff -b -w test1_ncdump.cdl test2_ncdump.cdl +echo "*** creating tst_output_irish_rover.cdl from ref_tst_irish_rover.nc..." +#${NCDUMP} ref_tst_irish_rover.nc > tst_output_irish_rover.cdl echo "*** All tests of ncgen and ncdump using test0.cdl passed!" exit 0