From f07cbeca30b9193f987e65af6689e9fee7644f18 Mon Sep 17 00:00:00 2001 From: edwardhartnett Date: Fri, 6 Sep 2019 05:48:17 -0600 Subject: [PATCH] now store ndims in var_desc_t and no longer need to look it up in read_darray() --- src/clib/pio_darray_int.c | 16 ++++++++++------ src/clib/pio_lists.c | 4 ++++ src/clib/pioc_support.c | 29 +++++++++++++++-------------- tests/cunit/test_async_1d.c | 5 +++-- tests/cunit/test_darray.c | 1 - tests/ncint/tst_pio_async.c | 6 +++--- tests/ncint/tst_pio_udf.c | 2 +- 7 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/clib/pio_darray_int.c b/src/clib/pio_darray_int.c index e39816bd216..288a23259b3 100644 --- a/src/clib/pio_darray_int.c +++ b/src/clib/pio_darray_int.c @@ -1189,8 +1189,10 @@ pio_read_darray_nc(file_desc_t *file, io_desc_t *iodesc, int vid, void *iobuf) ndims = iodesc->ndims; /* Get the number of dims for this var in the file. */ - if ((ierr = PIOc_inq_varndims(file->pio_ncid, vid, &fndims))) - return pio_err(ios, file, ierr, __FILE__, __LINE__); + /* if ((ierr = PIOc_inq_varndims(file->pio_ncid, vid, &fndims))) */ + /* return pio_err(ios, file, ierr, __FILE__, __LINE__); */ + fndims = vdesc->ndims; + PLOG((3, "fndims %d vdesc->ndims %d", fndims, vdesc->ndims)); #if USE_VARD_READ if(!ios->async || !ios->ioproc) ierr = get_gdim0(file, iodesc, vid, fndims, &gdim0); @@ -1461,15 +1463,17 @@ pio_read_darray_nc_serial(file_desc_t *file, io_desc_t *iodesc, int vid, ndims = iodesc->ndims; /* Get number of dims for this var. */ - if ((ierr = PIOc_inq_varndims(file->pio_ncid, vid, &fndims))) - return pio_err(ios, file, ierr, __FILE__, __LINE__); + fndims = vdesc->ndims; + /* if ((ierr = PIOc_inq_varndims(file->pio_ncid, vid, &fndims))) */ + /* return pio_err(ios, file, ierr, __FILE__, __LINE__); */ /* If setframe was not called, use a default value of 0. This is * required for backward compatibility. */ if (fndims == ndims + 1 && vdesc->record < 0) vdesc->record = 0; - PLOG((3, "fndims %d ndims %d vdesc->record %d", fndims, ndims, - vdesc->record)); + PLOG((3, "fndims %d ndims %d vdesc->record %d vdesc->ndims %d", fndims, + ndims, vdesc->record, vdesc->ndims)); + /* pioassert(fndims == vdesc->ndims, "bad ndims", __FILE__, __LINE__); */ /* Confirm that we are being called with the correct ndims. */ pioassert((fndims == ndims && vdesc->record < 0) || diff --git a/src/clib/pio_lists.c b/src/clib/pio_lists.c index ab09c73a7a7..9340fe60086 100644 --- a/src/clib/pio_lists.c +++ b/src/clib/pio_lists.c @@ -318,6 +318,10 @@ add_to_varlist(int varid, int rec_var, int pio_type, int pio_type_size, /* Check inputs. */ pioassert(varid >= 0 && varlist, "invalid input", __FILE__, __LINE__); + PLOG((4, "add_to_varlist varid %d rec_var %d pio_type %d pio_type_size %d " + "mpi_type %d mpi_type_size %d ndims %d", varid, rec_var, pio_type, + pio_type_size, mpi_type, mpi_type_size, ndims)); + /* Allocate storage. */ if (!(var_desc = calloc(1, sizeof(var_desc_t)))) return PIO_ENOMEM; diff --git a/src/clib/pioc_support.c b/src/clib/pioc_support.c index 9e031bfaadf..4c1be3655e1 100644 --- a/src/clib/pioc_support.c +++ b/src/clib/pioc_support.c @@ -2235,7 +2235,7 @@ check_unlim_use(int ncid) static int inq_file_metadata(file_desc_t *file, int ncid, int iotype, int *nvars, int **rec_var, int **pio_type, int **pio_type_size, - MPI_Datatype **mpi_type, int **mpi_type_size, int **ndim) + MPI_Datatype **mpi_type, int **mpi_type_size, int **ndims) { int nunlimdims = 0; /* The number of unlimited dimensions. */ int unlimdimid; @@ -2274,7 +2274,7 @@ inq_file_metadata(file_desc_t *file, int ncid, int iotype, int *nvars, return PIO_ENOMEM; if (!(*mpi_type_size = malloc(*nvars * sizeof(int)))) return PIO_ENOMEM; - if (!(*ndim = malloc(*nvars * sizeof(int)))) + if (!(*ndims = malloc(*nvars * sizeof(int)))) return PIO_ENOMEM; } @@ -2335,6 +2335,7 @@ inq_file_metadata(file_desc_t *file, int ncid, int iotype, int *nvars, if ((ret = ncmpi_inq_var(ncid, v, NULL, &my_type, &var_ndims, NULL, NULL))) return pio_err(NULL, file, ret, __FILE__, __LINE__); (*pio_type)[v] = (int)my_type; + (*ndims)[v] = var_ndims; if ((ret = pioc_pnetcdf_inq_type(ncid, (*pio_type)[v], NULL, &type_size))) return check_netcdf(file, ret, __FILE__, __LINE__); (*pio_type_size)[v] = type_size; @@ -2347,7 +2348,7 @@ inq_file_metadata(file_desc_t *file, int ncid, int iotype, int *nvars, if ((ret = nc_inq_var(ncid, v, NULL, &my_type, &var_ndims, NULL, NULL))) return pio_err(NULL, file, ret, __FILE__, __LINE__); (*pio_type)[v] = (int)my_type; - (*ndim)[v] = var_ndims; + (*ndims)[v] = var_ndims; if ((ret = nc_inq_type(ncid, (*pio_type)[v], NULL, &type_size))) return check_netcdf(file, ret, __FILE__, __LINE__); (*pio_type_size)[v] = type_size; @@ -2529,7 +2530,7 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, int *pio_type_size = NULL; MPI_Datatype *mpi_type = NULL; int *mpi_type_size = NULL; - int *ndim = NULL; + int *ndims = NULL; int mpierr = MPI_SUCCESS, mpierr2; /** Return code from MPI function codes. */ int ierr = PIO_NOERR; /* Return code from function calls. */ @@ -2621,7 +2622,7 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, if ((ierr = inq_file_metadata(file, file->fh, PIO_IOTYPE_NETCDF4P, &nvars, &rec_var, &pio_type, &pio_type_size, &mpi_type, - &mpi_type_size, &ndim))) + &mpi_type_size, &ndims))) break; PLOG((2, "PIOc_openfile_retry:nc_open_par filename = %s mode = %d " "imode = %d ierr = %d", filename, mode, imode, ierr)); @@ -2639,7 +2640,7 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, ierr = inq_file_metadata(file, file->fh, PIO_IOTYPE_NETCDF4C, &nvars, &rec_var, &pio_type, &pio_type_size, &mpi_type, - &mpi_type_size, &ndim); + &mpi_type_size, &ndims); } break; #endif /* _NETCDF4 */ @@ -2652,7 +2653,7 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, ierr = inq_file_metadata(file, file->fh, PIO_IOTYPE_NETCDF, &nvars, &rec_var, &pio_type, &pio_type_size, &mpi_type, - &mpi_type_size, &ndim); + &mpi_type_size, &ndims); } break; @@ -2674,7 +2675,7 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, ierr = inq_file_metadata(file, file->fh, PIO_IOTYPE_PNETCDF, &nvars, &rec_var, &pio_type, &pio_type_size, &mpi_type, - &mpi_type_size, &ndim); + &mpi_type_size, &ndims); break; #endif @@ -2707,7 +2708,7 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, ierr = inq_file_metadata(file, file->fh, PIO_IOTYPE_NETCDF, &nvars, &rec_var, &pio_type, &pio_type_size, &mpi_type, - &mpi_type_size, &ndim); + &mpi_type_size, &ndims); } else file->do_io = 0; @@ -2760,7 +2761,7 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); if (!(mpi_type_size = malloc(nvars * sizeof(int)))) return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); - if (!(ndim = malloc(nvars * sizeof(int)))) + if (!(ndims = malloc(nvars * sizeof(int)))) return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); } if (nvars) @@ -2775,7 +2776,7 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); if ((mpierr = MPI_Bcast(mpi_type_size, nvars, MPI_INT, ios->ioroot, ios->my_comm))) return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); - if ((mpierr = MPI_Bcast(ndim, nvars, MPI_INT, ios->ioroot, ios->my_comm))) + if ((mpierr = MPI_Bcast(ndims, nvars, MPI_INT, ios->ioroot, ios->my_comm))) return check_mpi(NULL, file, mpierr, __FILE__, __LINE__); } @@ -2811,7 +2812,7 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, /* Add info about the variables to the file_desc_t struct. */ for (int v = 0; v < nvars; v++) if ((ierr = add_to_varlist(v, rec_var[v], pio_type[v], pio_type_size[v], - mpi_type[v], mpi_type_size[v], ndim[v], + mpi_type[v], mpi_type_size[v], ndims[v], &file->varlist))) return pio_err(ios, NULL, ierr, __FILE__, __LINE__); file->nvars = nvars; @@ -2829,8 +2830,8 @@ PIOc_openfile_retry(int iosysid, int *ncidp, int *iotype, const char *filename, free(mpi_type); if (mpi_type_size) free(mpi_type_size); - if (ndim) - free(ndim); + if (ndims) + free(ndims); } #ifdef USE_MPE diff --git a/tests/cunit/test_async_1d.c b/tests/cunit/test_async_1d.c index 212def42ab5..6fbc596c144 100644 --- a/tests/cunit/test_async_1d.c +++ b/tests/cunit/test_async_1d.c @@ -64,7 +64,7 @@ int main(int argc, char **argv) /* Make sure we have 4 tasks. */ if (ntasks != TARGET_NTASKS) ERR(ERR_WRONG); - PIOc_set_log_level(4); + /* PIOc_set_log_level(4); */ /* Change error handling so we can test inval parameters. */ if ((ret = PIOc_set_iosystem_error_handling(PIO_DEFAULT, PIO_RETURN_ERROR, NULL))) @@ -87,7 +87,8 @@ int main(int argc, char **argv) int gdimlen[NDIM1] = {DIM_LEN_1}; PIO_Offset compmap[MAPLEN]; int varid; - int data, data_in; + int data; + /* int data_in; */ int ioid; /* Create a file. */ diff --git a/tests/cunit/test_darray.c b/tests/cunit/test_darray.c index 3c5317ff73b..ee16c525dc5 100644 --- a/tests/cunit/test_darray.c +++ b/tests/cunit/test_darray.c @@ -230,7 +230,6 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank if (PIOc_write_darray_multi(ncid, &varid_big, ioid, 1, arraylen, test_data, &frame, fillvalue, flushtodisk) != PIO_ENOTVAR) ERR(ERR_WRONG); -// pio_setloglevel(3); if (PIOc_write_darray_multi(ncid, &wrong_varid, ioid, 1, arraylen, test_data, &frame, fillvalue, flushtodisk) != PIO_ENOTVAR) ERR(ERR_WRONG); diff --git a/tests/ncint/tst_pio_async.c b/tests/ncint/tst_pio_async.c index 17c72cf202c..3201493c29d 100644 --- a/tests/ncint/tst_pio_async.c +++ b/tests/ncint/tst_pio_async.c @@ -76,13 +76,13 @@ main(int argc, char **argv) /* Calculate a decomposition for distributed arrays. */ elements_per_pe = DIM_LEN_X * DIM_LEN_Y / (ntasks - num_io_procs); - printf("my_rank %d elements_per_pe %ld\n", my_rank, elements_per_pe); + /* printf("my_rank %d elements_per_pe %ld\n", my_rank, elements_per_pe); */ if (!(compdof = malloc(elements_per_pe * sizeof(size_t)))) PERR; for (i = 0; i < elements_per_pe; i++) { compdof[i] = (my_rank - num_io_procs) * elements_per_pe + i; - printf("my_rank %d compdof[%d]=%ld\n", my_rank, i, compdof[i]); + /* printf("my_rank %d compdof[%d]=%ld\n", my_rank, i, compdof[i]); */ } /* Create the PIO decomposition for this test. */ @@ -121,7 +121,7 @@ main(int argc, char **argv) for (i = 0; i < elements_per_pe; i++) { compdof2[i] = (my_rank - num_io_procs) * elements_per_pe + i; - printf("my_rank %d compdof2[%d]=%lld\n", my_rank, i, compdof2[i]); + /* printf("my_rank %d compdof2[%d]=%lld\n", my_rank, i, compdof2[i]); */ } if (PIOc_init_decomp(iosysid, PIO_INT, NDIM2, &dimlen[1], elements_per_pe, compdof2, diff --git a/tests/ncint/tst_pio_udf.c b/tests/ncint/tst_pio_udf.c index 1a25df9dacf..dedcd536ee2 100644 --- a/tests/ncint/tst_pio_udf.c +++ b/tests/ncint/tst_pio_udf.c @@ -61,7 +61,7 @@ main(int argc, char **argv) int i; /* Turn on logging for PIO library. */ - PIOc_set_log_level(3); + /* PIOc_set_log_level(3); */ /* Initialize the intracomm. */ if (nc_def_iosystemm(MPI_COMM_WORLD, 1, 1, 0, 0, &iosysid)) PERR;