Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleaned up some rearranger code #853

Merged
merged 1 commit into from
Mar 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 16 additions & 25 deletions src/clib/pio_darray.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,30 +574,24 @@ int PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen,
/* Get the iodesc. */
if (!(iodesc = pio_get_iodesc_from_id(ioid)))
return pio_err(ios, file, PIO_EBADID, __FILE__, __LINE__);
pioassert(iodesc->rearranger == PIO_REARR_BOX || iodesc->rearranger == PIO_REARR_SUBSET,
"unknown rearranger", __FILE__, __LINE__);

/* ??? */
if (ios->iomaster == MPI_ROOT)
rlen = iodesc->maxiobuflen;
else
rlen = iodesc->llen;

/* Is a rearranger in use? */
if (iodesc->rearranger > 0)
{
if (ios->ioproc && rlen > 0)
{
/* Get the MPI type size. */
if ((mpierr = MPI_Type_size(iodesc->basetype, &tsize)))
return check_mpi(file, mpierr, __FILE__, __LINE__);

/* Allocate a buffer for one record. */
if (!(iobuf = bget((size_t)tsize * rlen)))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);
}
}
else
if (ios->ioproc && rlen > 0)
{
iobuf = array;
/* Get the MPI type size. */
if ((mpierr = MPI_Type_size(iodesc->basetype, &tsize)))
return check_mpi(file, mpierr, __FILE__, __LINE__);

/* Allocate a buffer for one record. */
if (!(iobuf = bget((size_t)tsize * rlen)))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);
}

/* Call the correct darray read function based on iotype. */
Expand All @@ -617,16 +611,13 @@ int PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen,
return pio_err(NULL, NULL, PIO_EBADIOTYPE, __FILE__, __LINE__);
}

/* If a rearranger was specified, rearrange the data. */
if (iodesc->rearranger > 0)
{
if ((ierr = rearrange_io2comp(ios, iodesc, iobuf, array)))
return pio_err(ios, file, ierr, __FILE__, __LINE__);
/* Rearrange the data. */
if ((ierr = rearrange_io2comp(ios, iodesc, iobuf, array)))
return pio_err(ios, file, ierr, __FILE__, __LINE__);

/* Free the buffer. */
if (rlen > 0)
brel(iobuf);
}
/* Free the buffer. */
if (rlen > 0)
brel(iobuf);

return PIO_NOERR;
}