Skip to content

Commit

Permalink
Merge pull request #1045 from NCAR/dqwu/fix_nreqs
Browse files Browse the repository at this point in the history
Updating number of PnetCDF requests correctly
  • Loading branch information
edhartnett authored May 23, 2017
2 parents b3f5661 + bcbff1a commit a334588
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
17 changes: 5 additions & 12 deletions src/clib/pio_darray_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,34 +284,27 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *
/* Get a pointer to the data. */
bufptr = (void *)((char *)iobuf + nv * iodesc->mpitype_size * llen);

/* ??? */
int reqn = 0;
if (vdesc->nreqs % PIO_REQUEST_ALLOC_CHUNK == 0 )
if (vdesc->nreqs % PIO_REQUEST_ALLOC_CHUNK == 0)
{
if (!(vdesc->request = realloc(vdesc->request, sizeof(int) *
(vdesc->nreqs + PIO_REQUEST_ALLOC_CHUNK))))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);

for (int i = vdesc->nreqs; i < vdesc->nreqs + PIO_REQUEST_ALLOC_CHUNK; i++)
vdesc->request[i] = NC_REQ_NULL;
reqn = vdesc->nreqs;
}
else
while(vdesc->request[reqn] != NC_REQ_NULL)
reqn++;

/* Write, in non-blocking fashion, a list of subarrays. */
LOG((3, "about to call ncmpi_iput_varn() varids[%d] = %d rrcnt = %d, llen = %d",
nv, varids[nv], rrcnt, llen));
ierr = ncmpi_iput_varn(file->fh, varids[nv], rrcnt, startlist, countlist,
bufptr, llen, iodesc->mpitype, vdesc->request + reqn);
bufptr, llen, iodesc->mpitype, vdesc->request + vdesc->nreqs);

/* keeps wait calls in sync */
if (vdesc->request[reqn] == NC_REQ_NULL)
vdesc->request[reqn] = PIO_REQ_NULL;

vdesc->nreqs += reqn + 1;
if (vdesc->request[vdesc->nreqs] == NC_REQ_NULL)
vdesc->request[vdesc->nreqs] = PIO_REQ_NULL;

vdesc->nreqs++;
}

/* Free resources. */
Expand Down
10 changes: 8 additions & 2 deletions src/clib/pioc_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -1727,8 +1727,14 @@ int PIOc_createfile_int(int iosysid, int *ncidp, int *iotype, const char *filena
for (int i = 0; i < PIO_MAX_VARS; i++)
{
file->varlist[i].record = -1;
file->varlist[i].iobuf = NULL;
file->varlist[i].fillbuf = NULL;
file->varlist[i].request = NULL;
file->varlist[i].nreqs = 0;
file->varlist[i].fillvalue = NULL;
file->varlist[i].pio_type = 0;
file->varlist[i].type_size = 0;
file->varlist[i].use_fill = 0;
file->varlist[i].fillbuf = NULL;
file->varlist[i].iobuf = NULL;
}
file->mode = mode;

Expand Down
2 changes: 1 addition & 1 deletion tests/general/pio_decomp_frame_tests.F90.in
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ PIO_TF_TEMPLATE<PIO_TF_PREDEF_TYPENAME PIO_TF_DATA_TYPE, PIO_TF_PREDEF_TYPENAME
PIO_TF_AUTO_TEST_SUB_BEGIN nc_write_read_4d_col_decomp
implicit none
integer, parameter :: NDIMS = 4
integer, parameter :: NFRAMES = 3
integer, parameter :: NFRAMES = 6
type(var_desc_t) :: pio_var
type(file_desc_t) :: pio_file
character(len=PIO_TF_MAX_STR_LEN) :: filename
Expand Down

0 comments on commit a334588

Please sign in to comment.