From 2715513a06829a9ba44531585f6739d8d20c470c Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Thu, 28 Apr 2022 07:39:45 -0600 Subject: [PATCH 1/4] added sequential test for enddef issue --- nc_test4/tst_vars3.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/nc_test4/tst_vars3.c b/nc_test4/tst_vars3.c index f3fc064e9a..3aa966732a 100644 --- a/nc_test4/tst_vars3.c +++ b/nc_test4/tst_vars3.c @@ -41,6 +41,30 @@ main(int argc, char **argv) { printf("\n*** Testing netcdf-4 variable functions, some more.\n"); + printf("**** testing reported enddef issue..."); + { + /* See https://github.com/Unidata/netcdf-c/issues/2165 for + * more info. */ + int ncid, varid, dimid, i; + char varname[NC_MAX_NAME + 1]; + + if (nc_create(FILE_NAME, NC_CLOBBER | NC_NETCDF4, &ncid)) ERR; + if (nc_def_dim(ncid, "time", NC_UNLIMITED, &dimid)) ERR; + if (nc_def_var(ncid, "time", NC_INT, 1, &dimid, &varid)) ERR; + if (nc_put_att_text(ncid, varid, "Att1", 4, "att1")) ERR; + if (nc_put_att_text(ncid, varid, "Att2", 4, "att2")) ERR; + if (nc_put_att_text(ncid, varid, "Att3", 4, "att3")) ERR; + if (nc_put_att_text(ncid, varid, "Att4", 4, "att4")) ERR; + for (i = 0; i < 300; i++) + { + snprintf(varname, 32, "dummy_var_%d", i); + if (nc_def_var(ncid, varname, NC_INT, 1, &dimid, &varid)) ERR; + } + + if (nc_enddef(ncid)) ERR; + if (nc_close(ncid)) ERR; + } + SUMMARIZE_ERR; printf("**** testing definition of coordinate variable after endef/redef..."); { #define NX 6 From b4d2c7d64db63c87531cf51c1ffadf8e1afd3541 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Sat, 30 Apr 2022 07:42:01 -0600 Subject: [PATCH 2/4] no longer run tst_parallel_zlib with 1 processor in testing --- nc_test4/run_par_test.sh.in | 1 - nc_test4/tst_parallel6.c | 82 ++++++++++++++++++++++++------------ nc_test4/tst_parallel_zlib.c | 4 ++ 3 files changed, 60 insertions(+), 27 deletions(-) diff --git a/nc_test4/run_par_test.sh.in b/nc_test4/run_par_test.sh.in index 00e4db3631..8ad53b2d5e 100644 --- a/nc_test4/run_par_test.sh.in +++ b/nc_test4/run_par_test.sh.in @@ -52,7 +52,6 @@ echo "Parallel I/O test for Collective I/O, contributed by HDF Group." if test "@HAS_PAR_FILTERS@" = "yes"; then echo echo "Parallel I/O test with zlib." - @MPIEXEC@ -n 1 ./tst_parallel_zlib @MPIEXEC@ -n 4 ./tst_parallel_zlib echo diff --git a/nc_test4/tst_parallel6.c b/nc_test4/tst_parallel6.c index 96eccb5bb7..09104e154b 100644 --- a/nc_test4/tst_parallel6.c +++ b/nc_test4/tst_parallel6.c @@ -23,9 +23,8 @@ int main(int argc, char** argv) { - int err = NC_NOERR, rank, nprocs; + int rank, nprocs; int ncid, varid, dimid; - size_t start[1], count[1], nrecs; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); @@ -34,37 +33,68 @@ int main(int argc, char** argv) if (!rank) printf("\n*** Testing parallel I/O.\n"); - if (!rank) - printf("*** testing record lenth with multiple processes writing records..."); - - /* nc_set_log_level(4); */ - if (nc_create_par(FILENAME, NC_CLOBBER | NC_NETCDF4, MPI_COMM_WORLD, - MPI_INFO_NULL, &ncid)) ERR; + /* if (!rank) */ + /* printf("*** testing record lenth with multiple processes writing records..."); */ + /* { */ - if (nc_def_dim(ncid, "time", NC_UNLIMITED, &dimid)) ERR; - if (nc_def_var(ncid, "var", NC_INT, 1, &dimid, &varid)) ERR; - if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR; - if (nc_enddef(ncid)) ERR; + /* size_t start[1], count[1], nrecs; */ + /* /\* nc_set_log_level(4); *\/ */ + /* if (nc_create_par(FILENAME, NC_CLOBBER | NC_NETCDF4, MPI_COMM_WORLD, */ + /* MPI_INFO_NULL, &ncid)) ERR; */ + + /* if (nc_def_dim(ncid, "time", NC_UNLIMITED, &dimid)) ERR; */ + /* if (nc_def_var(ncid, "var", NC_INT, 1, &dimid, &varid)) ERR; */ + /* if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR; */ + /* if (nc_enddef(ncid)) ERR; */ + + /* start[0] = rank; */ + /* count[0] = 1; */ + /* if (nc_put_vara_int(ncid, varid, start, count, &rank)) ERR; */ + /* if (nc_inq_dimlen(ncid, dimid, &nrecs)) ERR; */ + /* if (nc_close(ncid)) ERR; */ + /* /\* nc_set_log_level(-1); *\/ */ + + /* if (nrecs != nprocs) */ + /* { */ + /* printf("Rank %d error at line %d of file %s:\n",rank,__LINE__,__FILE__); */ + /* printf("\tafter writing start=%zd count=%zd\n", start[0], count[0]); */ + /* printf("\texpecting number of records = %d but got %ld\n", */ + /* nprocs, nrecs); */ + /* ERR; */ + /* } */ + /* } */ + /* if (!rank) */ + /* SUMMARIZE_ERR; */ - start[0] = rank; - count[0] = 1; - if (nc_put_vara_int(ncid, varid, start, count, &rank)) ERR; - if (nc_inq_dimlen(ncid, dimid, &nrecs)) ERR; - if (nc_close(ncid)) ERR; - /* nc_set_log_level(-1); */ - - if (nrecs != nprocs) + if (!rank) + printf("*** testing a reported enddef problem..."); { - printf("Rank %d error at line %d of file %s:\n",rank,__LINE__,__FILE__); - printf("\tafter writing start=%zd count=%zd\n", start[0], count[0]); - printf("\texpecting number of records = %d but got %ld\n", - nprocs, nrecs); - ERR; - } + int i; + char varname[NC_MAX_NAME + 1]; + nc_set_log_level(4); + if (nc_create_par(FILENAME, NC_CLOBBER | NC_MPIIO | NC_NETCDF4, MPI_COMM_WORLD, + MPI_INFO_NULL, &ncid)) ERR; + if (nc_def_dim(ncid, "time", NC_UNLIMITED, &dimid)) ERR; + if (nc_def_var(ncid, "time", NC_INT, 1, &dimid, &varid)) ERR; + if (nc_put_att_text(ncid, varid, "Att1", 1, "a")) ERR; + if (nc_put_att_text(ncid, varid, "Att2", 1, "a")) ERR; + if (nc_put_att_text(ncid, varid, "Att3", 1, "a")) ERR; + if (nc_put_att_text(ncid, varid, "Att4", 1, "a")) ERR; + for (i = 0; i < 253; i++) + { + snprintf(varname, 32, "dummy_var_%d", i); + if (nc_def_var(ncid, varname, NC_INT, 1, &dimid, &varid)) ERR; + } + + if (nc_enddef(ncid)) ERR; + if (nc_close(ncid)) ERR; + nc_set_log_level(-1); + } if (!rank) SUMMARIZE_ERR; + MPI_Finalize(); if (!rank) diff --git a/nc_test4/tst_parallel_zlib.c b/nc_test4/tst_parallel_zlib.c index 3a7906ef94..7c25cfee4a 100644 --- a/nc_test4/tst_parallel_zlib.c +++ b/nc_test4/tst_parallel_zlib.c @@ -60,6 +60,10 @@ main(int argc, char **argv) /*printf("mpi_name: %s size: %d rank: %d\n", mpi_name, mpi_size, mpi_rank);*/ + /* This program must have exactly 4 processors. */ + if (mpi_size != 4) + ERR; + #ifdef USE_MPE MPE_Init_log(); s_init = MPE_Log_get_event_number(); From 6945f53b984e6efca212d3d6a3d8240b9c91253e Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Sat, 30 Apr 2022 07:48:03 -0600 Subject: [PATCH 3/4] undoing unintended change --- nc_test4/tst_parallel6.c | 82 +++++++++++++--------------------------- 1 file changed, 26 insertions(+), 56 deletions(-) diff --git a/nc_test4/tst_parallel6.c b/nc_test4/tst_parallel6.c index 09104e154b..96eccb5bb7 100644 --- a/nc_test4/tst_parallel6.c +++ b/nc_test4/tst_parallel6.c @@ -23,8 +23,9 @@ int main(int argc, char** argv) { - int rank, nprocs; + int err = NC_NOERR, rank, nprocs; int ncid, varid, dimid; + size_t start[1], count[1], nrecs; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); @@ -33,68 +34,37 @@ int main(int argc, char** argv) if (!rank) printf("\n*** Testing parallel I/O.\n"); - /* if (!rank) */ - /* printf("*** testing record lenth with multiple processes writing records..."); */ - /* { */ + if (!rank) + printf("*** testing record lenth with multiple processes writing records..."); - /* size_t start[1], count[1], nrecs; */ - /* /\* nc_set_log_level(4); *\/ */ - /* if (nc_create_par(FILENAME, NC_CLOBBER | NC_NETCDF4, MPI_COMM_WORLD, */ - /* MPI_INFO_NULL, &ncid)) ERR; */ - - /* if (nc_def_dim(ncid, "time", NC_UNLIMITED, &dimid)) ERR; */ - /* if (nc_def_var(ncid, "var", NC_INT, 1, &dimid, &varid)) ERR; */ - /* if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR; */ - /* if (nc_enddef(ncid)) ERR; */ - - /* start[0] = rank; */ - /* count[0] = 1; */ - /* if (nc_put_vara_int(ncid, varid, start, count, &rank)) ERR; */ - /* if (nc_inq_dimlen(ncid, dimid, &nrecs)) ERR; */ - /* if (nc_close(ncid)) ERR; */ - /* /\* nc_set_log_level(-1); *\/ */ - - /* if (nrecs != nprocs) */ - /* { */ - /* printf("Rank %d error at line %d of file %s:\n",rank,__LINE__,__FILE__); */ - /* printf("\tafter writing start=%zd count=%zd\n", start[0], count[0]); */ - /* printf("\texpecting number of records = %d but got %ld\n", */ - /* nprocs, nrecs); */ - /* ERR; */ - /* } */ - /* } */ - /* if (!rank) */ - /* SUMMARIZE_ERR; */ + /* nc_set_log_level(4); */ + if (nc_create_par(FILENAME, NC_CLOBBER | NC_NETCDF4, MPI_COMM_WORLD, + MPI_INFO_NULL, &ncid)) ERR; - if (!rank) - printf("*** testing a reported enddef problem..."); - { - int i; - char varname[NC_MAX_NAME + 1]; - nc_set_log_level(4); - if (nc_create_par(FILENAME, NC_CLOBBER | NC_MPIIO | NC_NETCDF4, MPI_COMM_WORLD, - MPI_INFO_NULL, &ncid)) ERR; - if (nc_def_dim(ncid, "time", NC_UNLIMITED, &dimid)) ERR; - if (nc_def_var(ncid, "time", NC_INT, 1, &dimid, &varid)) ERR; - if (nc_put_att_text(ncid, varid, "Att1", 1, "a")) ERR; - if (nc_put_att_text(ncid, varid, "Att2", 1, "a")) ERR; - if (nc_put_att_text(ncid, varid, "Att3", 1, "a")) ERR; - if (nc_put_att_text(ncid, varid, "Att4", 1, "a")) ERR; - for (i = 0; i < 253; i++) - { - snprintf(varname, 32, "dummy_var_%d", i); - if (nc_def_var(ncid, varname, NC_INT, 1, &dimid, &varid)) ERR; - } - - if (nc_enddef(ncid)) ERR; - if (nc_close(ncid)) ERR; - nc_set_log_level(-1); + if (nc_def_dim(ncid, "time", NC_UNLIMITED, &dimid)) ERR; + if (nc_def_var(ncid, "var", NC_INT, 1, &dimid, &varid)) ERR; + if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR; + if (nc_enddef(ncid)) ERR; + + start[0] = rank; + count[0] = 1; + if (nc_put_vara_int(ncid, varid, start, count, &rank)) ERR; + if (nc_inq_dimlen(ncid, dimid, &nrecs)) ERR; + if (nc_close(ncid)) ERR; + /* nc_set_log_level(-1); */ + if (nrecs != nprocs) + { + printf("Rank %d error at line %d of file %s:\n",rank,__LINE__,__FILE__); + printf("\tafter writing start=%zd count=%zd\n", start[0], count[0]); + printf("\texpecting number of records = %d but got %ld\n", + nprocs, nrecs); + ERR; } + if (!rank) SUMMARIZE_ERR; - MPI_Finalize(); if (!rank) From 96743853cacb097ff145e55390d5364ee0a767bc Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Sat, 30 Apr 2022 07:49:21 -0600 Subject: [PATCH 4/4] undoing unintended change --- nc_test4/tst_vars3.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/nc_test4/tst_vars3.c b/nc_test4/tst_vars3.c index 3aa966732a..f3fc064e9a 100644 --- a/nc_test4/tst_vars3.c +++ b/nc_test4/tst_vars3.c @@ -41,30 +41,6 @@ main(int argc, char **argv) { printf("\n*** Testing netcdf-4 variable functions, some more.\n"); - printf("**** testing reported enddef issue..."); - { - /* See https://github.com/Unidata/netcdf-c/issues/2165 for - * more info. */ - int ncid, varid, dimid, i; - char varname[NC_MAX_NAME + 1]; - - if (nc_create(FILE_NAME, NC_CLOBBER | NC_NETCDF4, &ncid)) ERR; - if (nc_def_dim(ncid, "time", NC_UNLIMITED, &dimid)) ERR; - if (nc_def_var(ncid, "time", NC_INT, 1, &dimid, &varid)) ERR; - if (nc_put_att_text(ncid, varid, "Att1", 4, "att1")) ERR; - if (nc_put_att_text(ncid, varid, "Att2", 4, "att2")) ERR; - if (nc_put_att_text(ncid, varid, "Att3", 4, "att3")) ERR; - if (nc_put_att_text(ncid, varid, "Att4", 4, "att4")) ERR; - for (i = 0; i < 300; i++) - { - snprintf(varname, 32, "dummy_var_%d", i); - if (nc_def_var(ncid, varname, NC_INT, 1, &dimid, &varid)) ERR; - } - - if (nc_enddef(ncid)) ERR; - if (nc_close(ncid)) ERR; - } - SUMMARIZE_ERR; printf("**** testing definition of coordinate variable after endef/redef..."); { #define NX 6