Skip to content

Commit

Permalink
Merge pull request ESMCI#1557 from NCAR/ejh_netcdf_2
Browse files Browse the repository at this point in the history
More netcdf integration layer functions
  • Loading branch information
edhartnett authored Jul 6, 2019
2 parents 9852c2a + 5c43ff5 commit ae66446
Show file tree
Hide file tree
Showing 10 changed files with 1,113 additions and 110 deletions.
50 changes: 49 additions & 1 deletion src/clib/pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -1259,8 +1259,56 @@ extern "C" {

int nc_free_decomp(int ioid);

/* Data reads - vard. */
int nc_get_vard(int ncid, int varid, int decompid, const size_t recnum, void *buf);
int nc_get_vard_text(int ncid, int varid, int decompid, const size_t recnum,
char *buf);
int nc_get_vard_schar(int ncid, int varid, int decompid, const size_t recnum,
signed char *buf);
int nc_get_vard_short(int ncid, int varid, int decompid, const size_t recnum,
short *buf);
int nc_get_vard_int(int ncid, int varid, int decompid, const size_t recnum,
int *buf);
int nc_get_vard_float(int ncid, int varid, int decompid, const size_t recnum,
float *buf);
int nc_get_vard_double(int ncid, int varid, int decompid, const size_t recnum,
double *buf);
int nc_get_vard_uchar(int ncid, int varid, int decompid, const size_t recnum,
unsigned char *buf);
int nc_get_vard_ushort(int ncid, int varid, int decompid, const size_t recnum,
unsigned short *buf);
int nc_get_vard_uint(int ncid, int varid, int decompid, const size_t recnum,
unsigned int *buf);
int nc_get_vard_longlong(int ncid, int varid, int decompid, const size_t recnum,
long long *buf);
int nc_get_vard_ulonglong(int ncid, int varid, int decompid, const size_t recnum,
unsigned long long *buf);

/* Data writes - vard. */
int nc_put_vard(int ncid, int varid, int decompid, const size_t recnum,
const void *buf);
int nc_put_vard_text(int ncid, int varid, int decompid, const size_t recnum,
const char *op);
int nc_put_vard_schar(int ncid, int varid, int decompid, const size_t recnum,
const signed char *op);
int nc_put_vard_short(int ncid, int varid, int decompid, const size_t recnum,
const short *op);
int nc_put_vard_int(int ncid, int varid, int decompid, const size_t recnum,
const int *op);
const int *op);
int nc_put_vard_float(int ncid, int varid, int decompid, const size_t recnum,
const float *op);
int nc_put_vard_double(int ncid, int varid, int decompid, const size_t recnum,
const double *op);
int nc_put_vard_uchar(int ncid, int varid, int decompid, const size_t recnum,
const unsigned char *op);
int nc_put_vard_ushort(int ncid, int varid, int decompid, const size_t recnum,
const unsigned short *op);
int nc_put_vard_uint(int ncid, int varid, int decompid, const size_t recnum,
const unsigned int *op);
int nc_put_vard_longlong(int ncid, int varid, int decompid, const size_t recnum,
const long long *op);
int nc_put_vard_ulonglong(int ncid, int varid, int decompid, const size_t recnum,
const unsigned long long *op);

#if defined(__cplusplus)
}
Expand Down
2 changes: 2 additions & 0 deletions src/clib/pio_darray_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,8 @@ pio_read_darray_nc_serial(file_desc_t *file, io_desc_t *iodesc, int vid,
* required for backward compatibility. */
if (fndims == ndims + 1 && vdesc->record < 0)
vdesc->record = 0;
PLOG((3, "fndims %d ndims %d vdesc->record %d", fndims, ndims,
vdesc->record));

/* Confirm that we are being called with the correct ndims. */
pioassert((fndims == ndims && vdesc->record < 0) ||
Expand Down
2 changes: 1 addition & 1 deletion src/ncint/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ noinst_LTLIBRARIES = libncint.la

# The source files.
libncint_la_SOURCES = ncintdispatch.c ncintdispatch.h ncint_pio.c \
ncint_vard.c
nc_put_vard.c nc_get_vard.c
269 changes: 269 additions & 0 deletions src/ncint/nc_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_read_darray_c
* Read distributed arrays 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 nc_get_vard_text(int ncid, int varid, int decompid,
const size_t 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 nc_get_vard_uchar(int ncid, int varid, int decompid,
const size_t 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 nc_get_vard_schar(int ncid, int varid, int decompid,
const size_t 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 nc_get_vard_ushort(int ncid, int varid, int decompid,
const size_t 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 nc_get_vard_short(int ncid, int varid, int decompid,
const size_t 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 nc_get_vard_uint(int ncid, int varid, int decompid,
const size_t 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 nc_get_vard_int(int ncid, int varid, int decompid,
const size_t 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 nc_get_vard_float(int ncid, int varid, int decompid,
const size_t 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 nc_get_vard_double(int ncid, int varid, int decompid,
const size_t 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 nc_get_vard_ulonglong(int ncid, int varid, int decompid,
const size_t 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 nc_get_vard_longlong(int ncid, int varid, int decompid,
const size_t 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 nc_get_vard(int ncid, int varid, int decompid, const size_t recnum,
void *buf)
{
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_NAT, buf);
}


/**
* @}
*/
Loading

0 comments on commit ae66446

Please sign in to comment.