Skip to content

Commit

Permalink
more work on vard functions
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Jun 5, 2019
1 parent ee5c7ed commit c2a24fb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
13 changes: 8 additions & 5 deletions src/clib/pio_darray.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,12 +853,14 @@ PIOc_write_darray(int ncid, int varid, int ioid, PIO_Offset arraylen, void *arra
*
* @param ncid identifies the netCDF file
* @param varid the variable ID to be read
* @param ioid: the I/O description ID as passed back by
* @param ioid the I/O description ID as passed back by
* PIOc_InitDecomp().
* @param arraylen: the length of the array to be read. This
* is the length of the distrubited array. That is, the length of
* the portion of the data that is on the processor.
* @param array: pointer to the data to be read. This is a
* @param arraylen this parameter is ignored. Nominally it is the
* length of the array to be read. This is the length of the
* distrubited array. That is, the length of the portion of the data
* that is on the processor. This is already known because it is in
* the decomposition.
* @param array pointer to the data to be read. This is a
* pointer to the distributed portion of the array that is on this
* processor.
* @return 0 for success, error code otherwise.
Expand All @@ -876,6 +878,7 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen,
size_t rlen = 0; /* the length of data in iobuf. */
int ierr; /* Return code. */
void *tmparray; /* unsorted copy of array buf if required */

/* Get the file info. */
if ((ierr = pio_get_file(ncid, &file)))
return pio_err(NULL, NULL, PIO_EBADID, __FILE__, __LINE__);
Expand Down
32 changes: 30 additions & 2 deletions src/clib/pio_getput_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,8 @@ PIOc_put_var_tc(int ncid, int varid, nc_type xtype, const void *op)
}
/**
* Internal PIO function which provides a type-neutral interface to
* nc_get_vard.
* PIOc_get_vard() and related functions. This function gets
* distributed arrays of any type, converting them to any type.
*
* This routine is called collectively by all tasks in the
* communicator ios.union_comm.
Expand All @@ -1447,12 +1448,23 @@ int
PIOc_get_vard_tc(int ncid, int varid, int decompid, const PIO_Offset recnum,
nc_type xtype, void *buf)
{
int ret;

/* Set the value of the record dimension. */
if ((ret = PIOc_setframe(ncid, varid, recnum)))
return ret;

/* Read the distributed array. */
if ((ret = PIOc_read_darray(ncid, varid, decompid, 0, buf)))
return ret;

return PIO_NOERR;
}

/**
* Internal PIO function which provides a type-neutral interface to
* nc_put_vard.
* PIOc_get_vard() and related functions. This function puts
* distributed arrays of any type, converting them to any type.
*
* @param ncid identifies the netCDF file
* @param varid the variable ID number
Expand All @@ -1471,5 +1483,21 @@ int
PIOc_put_vard_tc(int ncid, int varid, int decompid, const PIO_Offset recnum,
nc_type xtype, const void *buf)
{
io_desc_t *iodesc; /* The IO description. */
int ret;

/* Set the value of the record dimension. */
if ((ret = PIOc_setframe(ncid, varid, recnum)))
return ret;

/* Get decomposition information. */
if (!(iodesc = pio_get_iodesc_from_id(decompid)))
return PIO_EBADID;

/* Write the distributed array. */
if ((ret = PIOc_write_darray(ncid, varid, decompid, iodesc->ndof,
(void *)buf, NULL)))
return ret;

return PIO_NOERR;
}

0 comments on commit c2a24fb

Please sign in to comment.