diff --git a/src/clib/pio_darray_int.c b/src/clib/pio_darray_int.c index cf5b43f737a..ea4c23b2de9 100644 --- a/src/clib/pio_darray_int.c +++ b/src/clib/pio_darray_int.c @@ -163,6 +163,7 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int * { iosystem_desc_t *ios; /* Pointer to io system information. */ var_desc_t *vdesc; /* Pointer to var info struct. */ + int dsize; /* Data size (for one region). */ int ierr = PIO_NOERR; /* Check inputs. */ @@ -194,10 +195,13 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int * /* If this is an IO task write the data. */ if (ios->ioproc) { + int rrcnt = 0; /* Number of subarray requests (pnetcdf only). */ void *bufptr; size_t start[fndims]; size_t count[fndims]; int ndims = iodesc->ndims; + PIO_Offset *startlist[num_regions]; /* Array of start arrays for ncmpi_iput_varn(). */ + PIO_Offset *countlist[num_regions]; /* Array of count arrays for ncmpi_iput_varn(). */ LOG((3, "num_regions = %d", num_regions)); @@ -237,12 +241,6 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int * #endif #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: - { - int dsize; /* Data size (for one region). */ - int rrcnt = 0; /* Number of subarray requests (pnetcdf only). */ - PIO_Offset *startlist[num_regions]; /* Array of start arrays for ncmpi_iput_varn(). */ - PIO_Offset *countlist[num_regions]; /* Array of count arrays for ncmpi_iput_varn(). */ - /* Get the total number of data elements we are * writing for this region. */ dsize = 1; @@ -322,7 +320,6 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int * } } break; - } #endif default: return pio_err(ios, file, PIO_EBADIOTYPE, __FILE__, __LINE__); @@ -797,7 +794,11 @@ int pio_read_darray_nc(file_desc_t *file, io_desc_t *iodesc, int vid, void *iobu io_region *region; size_t start[fndims]; size_t count[fndims]; + size_t tmp_bufsize = 1; void *bufptr; + int rrlen = 0; + PIO_Offset *startlist[iodesc->maxregions]; + PIO_Offset *countlist[iodesc->maxregions]; /* buffer is incremented by byte and loffset is in terms of the iodessc->mpitype so we need to multiply by the size of @@ -813,6 +814,7 @@ int pio_read_darray_nc(file_desc_t *file, io_desc_t *iodesc, int vid, void *iobu /* For each regions, read the data. */ for (int regioncnt = 0; regioncnt < iodesc->maxregions; regioncnt++) { + tmp_bufsize = 1; if (region == NULL || iodesc->llen == 0) { /* No data for this region. */ @@ -912,11 +914,7 @@ int pio_read_darray_nc(file_desc_t *file, io_desc_t *iodesc, int vid, void *iobu #ifdef _PNETCDF case PIO_IOTYPE_PNETCDF: { - int rrlen = 0; - PIO_Offset *startlist[iodesc->maxregions]; - PIO_Offset *countlist[iodesc->maxregions]; - size_t tmp_bufsize = 1; - + tmp_bufsize = 1; for (int j = 0; j < fndims; j++) tmp_bufsize *= count[j]; @@ -1279,12 +1277,12 @@ int pio_read_darray_nc_serial(file_desc_t *file, io_desc_t *iodesc, int vid, */ int flush_output_buffer(file_desc_t *file, bool force, PIO_Offset addsize) { + int mpierr; /* Return code from MPI functions. */ int ierr = PIO_NOERR; #ifdef _PNETCDF var_desc_t *vdesc; PIO_Offset usage = 0; - int mpierr; /* Return code from MPI functions. */ /* Check inputs. */ pioassert(file, "invalid input", __FILE__, __LINE__);