From c2a24fb5abc829d7742c2a6c71eab7e87b5c136e Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Wed, 5 Jun 2019 06:24:50 -0600 Subject: [PATCH] more work on vard functions --- src/clib/pio_darray.c | 13 ++++++++----- src/clib/pio_getput_int.c | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/clib/pio_darray.c b/src/clib/pio_darray.c index 0689634bd1f..c8e0f91ec64 100644 --- a/src/clib/pio_darray.c +++ b/src/clib/pio_darray.c @@ -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. @@ -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__); diff --git a/src/clib/pio_getput_int.c b/src/clib/pio_getput_int.c index eafde624226..5159790ad00 100644 --- a/src/clib/pio_getput_int.c +++ b/src/clib/pio_getput_int.c @@ -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. @@ -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 @@ -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; }