From 29aee0534f9c0135446584158f860b0d87feeafb Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 7 Dec 2017 11:30:38 -0700 Subject: [PATCH] dont use NC_MAX values --- ctest/runcdash-nwscla-intel.sh | 6 ++--- src/clib/pio_getput_int.c | 45 ++++++++++++++++++++-------------- src/clib/pio_msg.c | 33 ++++++++++++++----------- src/clib/pio_nc4.c | 2 ++ src/flib/pio_types.F90 | 10 ++++---- 5 files changed, 56 insertions(+), 40 deletions(-) diff --git a/ctest/runcdash-nwscla-intel.sh b/ctest/runcdash-nwscla-intel.sh index 630ac838085..d7a7f8c9120 100755 --- a/ctest/runcdash-nwscla-intel.sh +++ b/ctest/runcdash-nwscla-intel.sh @@ -14,14 +14,14 @@ module unload netcdf module swap intel intel/17.0.1 module load cmake/3.7.2 module load netcdf-mpi/4.4.1.1 -module load pnetcdf/1.8.0 -module switch mpt mpt/2.15 +module load pnetcdf/1.8.1 +module switch mpt mpt/2.16 echo "MODULE LIST..." module list export CC=mpicc export FC=mpif90 - +export MPI_TYPE_DEPTH=24 export PIO_DASHBOARD_ROOT=/glade/scratch/jedwards/dashboard export PIO_COMPILER_ID=Intel-`$CC --version | head -n 1 | cut -d' ' -f3` diff --git a/src/clib/pio_getput_int.c b/src/clib/pio_getput_int.c index 791cce1b1bd..6ae26141d6d 100644 --- a/src/clib/pio_getput_int.c +++ b/src/clib/pio_getput_int.c @@ -797,8 +797,6 @@ int PIOc_get_var_tc(int ncid, int varid, nc_type xtype, void *buf) PIO_Offset *startp = NULL; /* Pointer to start array. */ PIO_Offset *countp = NULL; /* Pointer to count array. */ int ndims; /* The number of dimensions in the variable. */ - PIO_Offset my_start[PIO_MAX_DIMS]; - PIO_Offset dimlen[PIO_MAX_DIMS]; int ierr; /* Return code from function calls. */ LOG((1, "PIOc_get_var_tc ncid = %d varid = %d xtype = %d", ncid, varid, @@ -821,26 +819,33 @@ int PIOc_get_var_tc(int ncid, int varid, nc_type xtype, void *buf) int dimids[ndims]; if ((ierr = PIOc_inq_vardimid(ncid, varid, dimids))) return pio_err(ios, file, ierr, __FILE__, __LINE__); + if (!(startp = malloc(ndims * sizeof(PIO_Offset)))) + return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); + if (!(countp = malloc(ndims * sizeof(PIO_Offset)))) + return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); /* Find the dimension lengths. */ for (int d = 0; d < ndims; d++) - if ((ierr = PIOc_inq_dimlen(ncid, dimids[d], &dimlen[d]))) + if ((ierr = PIOc_inq_dimlen(ncid, dimids[d], &countp[d]))) return pio_err(ios, file, ierr, __FILE__, __LINE__); /* Set up start array. */ for (int d = 0; d < ndims; d++) { - my_start[d] = 0; - LOG((3, "my_start[%d] = %d dimlen[%d] = %d", d, my_start[d], d, - dimlen[d])); + startp[d] = 0; + LOG((3, "startp[%d] = %d countp[%d] = %d", d, startp[d], d, + countp[d])); } - /* Set the start/count arrays. */ - startp = my_start; - countp = dimlen; } - return PIOc_get_vars_tc(ncid, varid, startp, countp, NULL, xtype, buf); + ierr = PIOc_get_vars_tc(ncid, varid, startp, countp, NULL, xtype, buf); + if(startp != NULL) + free(startp); + if(countp != NULL) + free(countp); + return ierr; + } /** @@ -1294,8 +1299,6 @@ int PIOc_put_var_tc(int ncid, int varid, nc_type xtype, const void *op) file_desc_t *file; /* Pointer to file information. */ PIO_Offset *startp = NULL; /* Pointer to start array. */ PIO_Offset *countp = NULL; /* Pointer to count array. */ - PIO_Offset start[PIO_MAX_DIMS]; - PIO_Offset count[PIO_MAX_DIMS]; int ndims; /* The number of dimensions in the variable. */ int ierr; /* Return code from function calls. */ @@ -1316,10 +1319,14 @@ int PIOc_put_var_tc(int ncid, int varid, nc_type xtype, const void *op) if (ndims) { int dimid[ndims]; + if (!(startp = malloc(ndims * sizeof(PIO_Offset)))) + return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); + if (!(countp = malloc(ndims * sizeof(PIO_Offset)))) + return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__); /* Set up start array. */ for (int d = 0; d < ndims; d++) - start[d] = 0; + startp[d] = 0; /* Get the dimids for this var. */ if ((ierr = PIOc_inq_vardimid(ncid, varid, dimid))) @@ -1327,13 +1334,15 @@ int PIOc_put_var_tc(int ncid, int varid, nc_type xtype, const void *op) /* Count array are the dimlens. */ for (int d = 0; d < ndims; d++) - if ((ierr = PIOc_inq_dimlen(ncid, dimid[d], &count[d]))) + if ((ierr = PIOc_inq_dimlen(ncid, dimid[d], &countp[d]))) return pio_err(ios, file, ierr, __FILE__, __LINE__); - /* Set the array pointers. */ - startp = start; - countp = count; } - return PIOc_put_vars_tc(ncid, varid, startp, countp, NULL, xtype, op); + ierr = PIOc_put_vars_tc(ncid, varid, startp, countp, NULL, xtype, op); + if (startp != NULL) + free(startp); + if (countp != NULL) + free(countp); + return ierr; } diff --git a/src/clib/pio_msg.c b/src/clib/pio_msg.c index c5b10244511..9cef2008afa 100644 --- a/src/clib/pio_msg.c +++ b/src/clib/pio_msg.c @@ -190,7 +190,8 @@ int create_file_handler(iosystem_desc_t *ios) /* Call the create file function. */ PIOc_createfile(ios->iosysid, &ncid, &iotype, filename, mode); - + + LOG((1, "create_file_handler succeeded!")); return PIO_NOERR; } @@ -276,7 +277,7 @@ int inq_handler(iosystem_desc_t *ios) /* Call the inq function to get the values. */ PIOc_inq(ncid, ndimsp, nvarsp, ngattsp, unlimdimidp); - + return PIO_NOERR; } @@ -1006,7 +1007,7 @@ int inq_var_handler(iosystem_desc_t *ios) char name[NC_MAX_NAME + 1], *namep = NULL; nc_type xtype, *xtypep = NULL; int *ndimsp = NULL, *dimidsp = NULL, *nattsp = NULL; - int ndims, dimids[NC_MAX_DIMS], natts; + int ndims, natts; int mpierr; LOG((1, "inq_var_handler")); @@ -1040,7 +1041,8 @@ int inq_var_handler(iosystem_desc_t *ios) if (ndims_present) ndimsp = &ndims; if (dimids_present) - dimidsp = dimids; + if (!(dimidsp = malloc(ndims))) + return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__); if (natts_present) nattsp = &natts; @@ -1064,9 +1066,10 @@ int inq_var_chunking_handler(iosystem_desc_t *ios) { int ncid; int varid; + int ndims; char storage_present, chunksizes_present; int storage, *storagep = NULL; - PIO_Offset chunksizes[NC_MAX_DIMS], *chunksizesp = NULL; + PIO_Offset *chunksizesp = NULL; int mpierr; assert(ios); @@ -1080,6 +1083,8 @@ int inq_var_chunking_handler(iosystem_desc_t *ios) return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__); if ((mpierr = MPI_Bcast(&storage_present, 1, MPI_CHAR, 0, ios->intercomm))) return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__); + if ((mpierr = MPI_Bcast(&ndims, 1, MPI_INT, 0, ios->intercomm))) + return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__); if ((mpierr = MPI_Bcast(&chunksizes_present, 1, MPI_CHAR, 0, ios->intercomm))) return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__); LOG((2,"inq_var_handler ncid = %d varid = %d storage_present = %d chunksizes_present = %d", @@ -1089,7 +1094,8 @@ int inq_var_chunking_handler(iosystem_desc_t *ios) if (storage_present) storagep = &storage; if (chunksizes_present) - chunksizesp = chunksizes; + if (!(chunksizesp = malloc(ndims))) + return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__); /* Call the inq function to get the values. */ PIOc_inq_var_chunking(ncid, varid, storagep, chunksizesp); @@ -1492,7 +1498,7 @@ int def_var_chunking_handler(iosystem_desc_t *ios) int ndims; int storage; char chunksizes_present; - PIO_Offset chunksizes[NC_MAX_DIMS], *chunksizesp = NULL; + PIO_Offset *chunksizesp = NULL; int mpierr; assert(ios); @@ -1510,16 +1516,15 @@ int def_var_chunking_handler(iosystem_desc_t *ios) return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__); if ((mpierr = MPI_Bcast(&chunksizes_present, 1, MPI_CHAR, 0, ios->intercomm))) return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__); - if (chunksizes_present) - if ((mpierr = MPI_Bcast(chunksizes, ndims, MPI_OFFSET, 0, ios->intercomm))) + if (chunksizes_present){ + if (!(chunksizesp = malloc(ndims))) + return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__); + if ((mpierr = MPI_Bcast(chunksizesp, ndims, MPI_OFFSET, 0, ios->intercomm))) return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__); + } LOG((1, "def_var_chunking_handler got parameters ncid = %d varid = %d storage = %d " "ndims = %d chunksizes_present = %d", ncid, varid, storage, ndims, chunksizes_present)); - /* Set the non-NULL pointers. */ - if (chunksizes_present) - chunksizesp = chunksizes; - /* Call the function. */ PIOc_def_var_chunking(ncid, varid, storage, chunksizesp); @@ -2703,7 +2708,7 @@ int pio_msg_handler2(int io_rank, int component_count, iosystem_desc_t **iosys, /* If an error was returned by the handler, exit. */ LOG((3, "pio_msg_handler2 ret %d msg %d index %d io_rank %d", ret, msg, index, io_rank)); if (ret) - return pio_err(my_iosys, NULL, ret, __FILE__, __LINE__); + return pio_err(my_iosys, NULL, ret, __FILE__, __LINE__); /* Listen for another msg from the component whose message we * just handled. */ diff --git a/src/clib/pio_nc4.c b/src/clib/pio_nc4.c index 086bbf699f8..62ceb080c43 100644 --- a/src/clib/pio_nc4.c +++ b/src/clib/pio_nc4.c @@ -400,6 +400,8 @@ int PIOc_inq_var_chunking(int ncid, int varid, int *storagep, PIO_Offset *chunks mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) mpierr = MPI_Bcast(&storage_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); + if (!mpierr) + mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmaster, ios->intercomm); if (!mpierr) mpierr = MPI_Bcast(&chunksizes_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm); LOG((2, "PIOc_inq_var_chunking ncid = %d varid = %d storage_present = %d chunksizes_present = %d", diff --git a/src/flib/pio_types.F90 b/src/flib/pio_types.F90 index d8bb4a3f019..1e8fb9532e4 100644 --- a/src/flib/pio_types.F90 +++ b/src/flib/pio_types.F90 @@ -186,7 +186,7 @@ module pio_types integer, public, parameter :: PIO_NOCLOBBER = nf_NOclobber integer, public, parameter :: PIO_NOFILL = nf_nofill integer, public, parameter :: PIO_MAX_NAME = nf_max_name - integer, public, parameter :: PIO_MAX_VAR_DIMS = nf_max_var_dims + integer, public, parameter :: PIO_MAX_VAR_DIMS = min(6,nf_max_var_dims) integer, public, parameter :: PIO_64BIT_OFFSET = nf_64bit_offset integer, public, parameter :: PIO_64BIT_DATA = nf_64bit_data integer, public, parameter :: PIO_FILL_INT = nf_fill_int; @@ -209,7 +209,7 @@ module pio_types integer, public, parameter :: PIO_NOCLOBBER = nf_NOclobber integer, public, parameter :: PIO_NOFILL = nf_nofill integer, public, parameter :: PIO_MAX_NAME = nf_max_name - integer, public, parameter :: PIO_MAX_VAR_DIMS = nf_max_var_dims + integer, public, parameter :: PIO_MAX_VAR_DIMS = min(6,nf_max_var_dims) integer, public, parameter :: PIO_64BIT_OFFSET = nf_64bit_offset integer, public, parameter :: PIO_64BIT_DATA = 0 integer, public, parameter :: PIO_FILL_INT = nf_fill_int; @@ -239,7 +239,7 @@ module pio_types !> !! @defgroup PIO_rearr_comm_t PIO_rearr_comm_t -!! @public +!! @public !! @brief The two choices for rearranger communication !! @details !! - PIO_rearr_comm_p2p : Point to point @@ -252,7 +252,7 @@ module pio_types !> !! @defgroup PIO_rearr_comm_dir PIO_rearr_comm_dir -!! @public +!! @public !! @brief The four choices for rearranger communication direction !! @details !! - PIO_rearr_comm_fc_2d_enable : COMM procs to IO procs and vice versa @@ -271,7 +271,7 @@ module pio_types !! @defgroup PIO_rearr_comm_fc_options PIO_rearr_comm_fc_options !! @brief Type that defines the PIO rearranger options !! @details -!! - enable_hs : Enable handshake (true/false) +!! - enable_hs : Enable handshake (true/false) !! - enable_isend : Enable Isends (true/false) !! - max_pend_req : Maximum pending requests (To indicated unlimited !! number of requests use PIO_REARR_COMM_UNLIMITED_PEND_REQ)