Skip to content

Commit

Permalink
Merge pull request ESMCI#1470 from NCAR/ejh_vard_functions
Browse files Browse the repository at this point in the history
new vard functions
  • Loading branch information
edhartnett authored Jun 6, 2019
2 parents f96b039 + 5aeae4e commit 2d3528b
Show file tree
Hide file tree
Showing 15 changed files with 1,310 additions and 35 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ if test "x$enable_docs" = xyes; then
if test "x$enable_developer_docs" = xyes; then
AC_SUBST([C_SRC_FILES], ["../src/clib"])
else
AC_SUBST([C_SRC_FILES], ["../src/clib/pio_nc.c ../src/clib/pio_nc4.c ../src/clib/pio_darray.c ../src/clib/pio_get_nc.c ../src/clib/pio_put_nc.c ../src/clib/pioc_support.c ../src/clib/pioc.c ../src/clib/pio_file.c ../src/clib/pio.h"])
AC_SUBST([C_SRC_FILES], ["../src/clib/pio_nc.c ../src/clib/pio_nc4.c ../src/clib/pio_darray.c ../src/clib/pio_get_nc.c ../src/clib/pio_put_nc.c ../src/clib/pioc_support.c ../src/clib/pioc.c ../src/clib/pio_file.c ../src/clib/pio.h ../src/clib/pio_get_vard.c ../src/clib/pio_put_vard.c"])
fi
AC_CONFIG_FILES([doc/Doxyfile])
fi
Expand Down
2 changes: 1 addition & 1 deletion src/clib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project (PIOC C)
add_library (pioc topology.c pio_file.c pioc_support.c pio_lists.c
pioc.c pioc_sc.c pio_spmd.c pio_rearrange.c pio_nc4.c bget.c
pio_nc.c pio_put_nc.c pio_get_nc.c pio_getput_int.c pio_msg.c
pio_darray.c pio_darray_int.c)
pio_darray.c pio_darray_int.c pio_get_vard.c pio_put_vard.c)

# set up include-directories
include_directories(
Expand Down
3 changes: 2 additions & 1 deletion src/clib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ include_HEADERS = pio.h
libpio_la_SOURCES = bget.c pioc_sc.c pio_darray.c pio_file.c \
pio_getput_int.c pio_msg.c pio_nc.c pio_rearrange.c pioc.c \
pioc_support.c pio_darray_int.c pio_get_nc.c pio_lists.c pio_nc4.c \
pio_put_nc.c pio_spmd.c pio_internal.h bget.h uthash.h
pio_put_nc.c pio_spmd.c pio_get_vard.c pio_put_vard.c pio_internal.h \
bget.h uthash.h

EXTRA_DIST = CMakeLists.txt
54 changes: 54 additions & 0 deletions src/clib/pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,60 @@ extern "C" {
const PIO_Offset *count, const PIO_Offset *stride,
const unsigned long long *op);

/* Data reads - vard. */
int PIOc_get_vard(int ncid, int varid, int decompid, const PIO_Offset recnum, void *buf);
int PIOc_get_vard_text(int ncid, int varid, int decompid, const PIO_Offset recnum,
char *buf);
int PIOc_get_vard_schar(int ncid, int varid, int decompid, const PIO_Offset recnum,
signed char *buf);
int PIOc_get_vard_short(int ncid, int varid, int decompid, const PIO_Offset recnum,
short *buf);
int PIOc_get_vard_int(int ncid, int varid, int decompid, const PIO_Offset recnum,
int *buf);
int PIOc_get_vard_float(int ncid, int varid, int decompid, const PIO_Offset recnum,
float *buf);
/* int PIOc_get_vard_long(int ncid, int varid, int decompid, const PIO_Offset recnum, */
/* long *buf); */
int PIOc_get_vard_double(int ncid, int varid, int decompid, const PIO_Offset recnum,
double *buf);
int PIOc_get_vard_uchar(int ncid, int varid, int decompid, const PIO_Offset recnum,
unsigned char *buf);
int PIOc_get_vard_ushort(int ncid, int varid, int decompid, const PIO_Offset recnum,
unsigned short *buf);
int PIOc_get_vard_uint(int ncid, int varid, int decompid, const PIO_Offset recnum,
unsigned int *buf);
int PIOc_get_vard_longlong(int ncid, int varid, int decompid, const PIO_Offset recnum,
long long *buf);
int PIOc_get_vard_ulonglong(int ncid, int varid, int decompid, const PIO_Offset recnum,
unsigned long long *buf);

/* Data writes - vara. */
int PIOc_put_vard(int ncid, int varid, int decompid, const PIO_Offset recnum,
const void *buf);
int PIOc_put_vard_text(int ncid, int varid, int decompid, const PIO_Offset recnum,
const char *op);
int PIOc_put_vard_schar(int ncid, int varid, int decompid, const PIO_Offset recnum,
const signed char *op);
int PIOc_put_vard_short(int ncid, int varid, int decompid, const PIO_Offset recnum,
const short *op);
int PIOc_put_vard_int(int ncid, int varid, int decompid, const PIO_Offset recnum,
const int *op);
/* int PIOc_put_vard_long(int ncid, int varid, int decompid, const PIO_Offset recnum, */
/* const long *op); */
int PIOc_put_vard_float(int ncid, int varid, int decompid, const PIO_Offset recnum,
const float *op);
int PIOc_put_vard_double(int ncid, int varid, int decompid, const PIO_Offset recnum,
const double *op);
int PIOc_put_vard_uchar(int ncid, int varid, int decompid, const PIO_Offset recnum,
const unsigned char *op);
int PIOc_put_vard_ushort(int ncid, int varid, int decompid, const PIO_Offset recnum,
const unsigned short *op);
int PIOc_put_vard_uint(int ncid, int varid, int decompid, const PIO_Offset recnum,
const unsigned int *op);
int PIOc_put_vard_longlong(int ncid, int varid, int decompid, const PIO_Offset recnum,
const long long *op);
int PIOc_put_vard_ulonglong(int ncid, int varid, int decompid, const PIO_Offset recnum,
const unsigned long long *op);
#if defined(__cplusplus)
}
#endif
Expand Down
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
269 changes: 269 additions & 0 deletions src/clib/pio_get_vard.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
/**
* @file
* PIO functions to get data with distributed arrays.
*
* @author Ed Hartnett
* @date 2019
*
* @see https://github.com/NCAR/ParallelIO
*/
#include <config.h>
#include <pio.h>
#include <pio_internal.h>

/**
* @addtogroup PIO_get_var_c Read Data
* Read data from a variable in C.
* @{
*/

/**
* Get a muti-dimensional subset of a text variable.
*
* This routine is called collectively by all tasks in the
* communicator ios.union_comm.
*
* @param ncid identifies the netCDF file
* @param varid the variable ID number
* @param decompid the decomposition ID.
* @param recnum the record number.
* @param buf pointer that will get the data.
* @return PIO_NOERR on success, error code otherwise.
* @author Ed Hartnett
*/
int PIOc_get_vard_text(int ncid, int varid, int decompid,
const PIO_Offset recnum, char *buf)
{
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_CHAR, buf);
}

/**
* Get a muti-dimensional subset of an unsigned char variable.
*
* This routine is called collectively by all tasks in the
* communicator ios.union_comm.
*
* @param ncid identifies the netCDF file
* @param varid the variable ID number
* @param decompid the decomposition ID.
* @param recnum the record number.
* @param buf pointer that will get the data.
* @return PIO_NOERR on success, error code otherwise.
* @author Ed Hartnett
*/
int PIOc_get_vard_uchar(int ncid, int varid, int decompid,
const PIO_Offset recnum, unsigned char *buf)
{
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_UBYTE, buf);
}

/**
* Get a muti-dimensional subset of a signed char variable.
*
* This routine is called collectively by all tasks in the
* communicator ios.union_comm.
*
* @param ncid identifies the netCDF file
* @param varid the variable ID number
* @param decompid the decomposition ID.
* @param recnum the record number.
* @param buf pointer that will get the data.
* @return PIO_NOERR on success, error code otherwise.
* @author Ed Hartnett
*/
int PIOc_get_vard_schar(int ncid, int varid, int decompid,
const PIO_Offset recnum, signed char *buf)
{
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_BYTE, buf);
}

/**
* Get a muti-dimensional subset of an unsigned 16-bit integer
* variable.
*
* This routine is called collectively by all tasks in the
* communicator ios.union_comm.
*
* @param ncid identifies the netCDF file
* @param varid the variable ID number
* @param decompid the decomposition ID.
* @param recnum the record number.
* @param buf pointer that will get the data.
* @return PIO_NOERR on success, error code otherwise.
* @author Ed Hartnett
*/
int PIOc_get_vard_ushort(int ncid, int varid, int decompid,
const PIO_Offset recnum, unsigned short *buf)
{
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_USHORT,
buf);
}

/**
* Get a muti-dimensional subset of a 16-bit integer variable.
*
* This routine is called collectively by all tasks in the
* communicator ios.union_comm.
*
* @param ncid identifies the netCDF file
* @param varid the variable ID number
* @param decompid the decomposition ID.
* @param recnum the record number.
* @param buf pointer that will get the data.
* @return PIO_NOERR on success, error code otherwise.
* @author Ed Hartnett
*/
int PIOc_get_vard_short(int ncid, int varid, int decompid,
const PIO_Offset recnum, short *buf)
{
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_SHORT, buf);
}

/**
* Get a muti-dimensional subset of an unsigned integer variable.
*
* This routine is called collectively by all tasks in the
* communicator ios.union_comm.
*
* @param ncid identifies the netCDF file
* @param varid the variable ID number
* @param decompid the decomposition ID.
* @param recnum the record number.
* @param buf pointer that will get the data.
* @return PIO_NOERR on success, error code otherwise.
* @author Ed Hartnett
*/
int PIOc_get_vard_uint(int ncid, int varid, int decompid,
const PIO_Offset recnum, unsigned int *buf)
{
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_UINT, buf);
}

/**
* Get a muti-dimensional subset of an integer variable.
*
* This routine is called collectively by all tasks in the
* communicator ios.union_comm.
*
* @param ncid identifies the netCDF file
* @param varid the variable ID number
* @param decompid the decomposition ID.
* @param recnum the record number.
* @param buf pointer that will get the data.
* @return PIO_NOERR on success, error code otherwise.
* @author Ed Hartnett
*/
int PIOc_get_vard_int(int ncid, int varid, int decompid,
const PIO_Offset recnum, int *buf)
{
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_INT, buf);
}

/**
* Get a muti-dimensional subset of a floating point variable.
*
* This routine is called collectively by all tasks in the
* communicator ios.union_comm.
*
* @param ncid identifies the netCDF file
* @param varid the variable ID number
* @param decompid the decomposition ID.
* @param recnum the record number.
* @param buf pointer that will get the data.
* @return PIO_NOERR on success, error code otherwise.
* @author Ed Hartnett
*/
int PIOc_get_vard_float(int ncid, int varid, int decompid,
const PIO_Offset recnum, float *buf)
{
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_FLOAT, buf);
}

/**
* Get a muti-dimensional subset of a 64-bit floating point variable.
*
* This routine is called collectively by all tasks in the
* communicator ios.union_comm.
*
* @param ncid identifies the netCDF file
* @param varid the variable ID number
* @param decompid the decomposition ID.
* @param recnum the record number.
* @param buf pointer that will get the data.
* @return PIO_NOERR on success, error code otherwise.
* @author Ed Hartnett
*/
int PIOc_get_vard_double(int ncid, int varid, int decompid,
const PIO_Offset recnum, double *buf)
{
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_DOUBLE,
buf);
}

/**
* Get a muti-dimensional subset of an unsigned 64-bit integer
* variable.
*
* This routine is called collectively by all tasks in the
* communicator ios.union_comm.
*
* @param ncid identifies the netCDF file
* @param varid the variable ID number
* @param decompid the decomposition ID.
* @param recnum the record number.
* @param buf pointer that will get the data.
* @return PIO_NOERR on success, error code otherwise.
* @author Ed Hartnett
*/
int PIOc_get_vard_ulonglong(int ncid, int varid, int decompid,
const PIO_Offset recnum, unsigned long long *buf)
{
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_UINT64,
buf);
}

/**
* Get a muti-dimensional subset of a 64-bit integer variable.
*
* This routine is called collectively by all tasks in the
* communicator ios.union_comm.
*
* @param ncid identifies the netCDF file
* @param varid the variable ID number
* @param decompid the decomposition ID.
* @param recnum the record number.
* @param buf pointer that will get the data.
* @return PIO_NOERR on success, error code otherwise.
* @author Ed Hartnett
*/
int PIOc_get_vard_longlong(int ncid, int varid, int decompid,
const PIO_Offset recnum, long long *buf)
{
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_INT64, buf);
}

/**
* Get a muti-dimensional subset of a variable the same type
* as the variable in the file.
*
* This routine is called collectively by all tasks in the
* communicator ios.union_comm.
*
* @param ncid identifies the netCDF file
* @param varid the variable ID number
* @param decompid the decomposition ID.
* @param recnum the record number.
* @param buf pointer that will get the data.
* @return PIO_NOERR on success, error code otherwise.
* @author Ed Hartnett
*/
int PIOc_get_vard(int ncid, int varid, int decompid, const PIO_Offset recnum,
void *buf)
{
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_NAT, buf);
}


/**
* @}
*/
Loading

0 comments on commit 2d3528b

Please sign in to comment.