Skip to content

Commit

Permalink
further 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 c2a24fb commit f33f309
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 66 deletions.
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
8 changes: 4 additions & 4 deletions src/clib/pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -1207,8 +1207,8 @@ extern "C" {
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_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,
Expand All @@ -1233,8 +1233,8 @@ extern "C" {
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_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,
Expand Down
49 changes: 14 additions & 35 deletions src/clib/pio_get_vard.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
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, NULL, NC_CHAR, buf);
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_CHAR, buf);
}

/**
Expand All @@ -54,7 +54,7 @@ int PIOc_get_vard_text(int ncid, int varid, int decompid,
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, NULL, NC_UBYTE, buf);
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_UBYTE, buf);
}

/**
Expand All @@ -74,7 +74,7 @@ int PIOc_get_vard_uchar(int ncid, int varid, int decompid,
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, NULL, NC_BYTE, buf);
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_BYTE, buf);
}

/**
Expand All @@ -95,7 +95,7 @@ int PIOc_get_vard_schar(int ncid, int varid, int decompid,
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, NULL, NC_USHORT,
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_USHORT,
buf);
}

Expand All @@ -116,28 +116,7 @@ int PIOc_get_vard_ushort(int ncid, int varid, int decompid,
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, NULL, NC_SHORT, 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_long(int ncid, int varid, int decompid,
const PIO_Offset recnum, long *buf)
{
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NULL,
PIO_LONG_INTERNAL, buf);
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_SHORT, buf);
}

/**
Expand All @@ -157,7 +136,7 @@ int PIOc_get_vard_long(int ncid, int varid, int decompid,
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, NULL, NC_UINT, buf);
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_UINT, buf);
}

/**
Expand All @@ -177,7 +156,7 @@ int PIOc_get_vard_uint(int ncid, int varid, int decompid,
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, NULL, NC_INT, buf);
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_INT, buf);
}

/**
Expand All @@ -197,7 +176,7 @@ int PIOc_get_vard_int(int ncid, int varid, int decompid,
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, NULL, NC_FLOAT, buf);
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_FLOAT, buf);
}

/**
Expand All @@ -217,7 +196,7 @@ int PIOc_get_vard_float(int ncid, int varid, int decompid,
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, NULL, NC_DOUBLE,
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_DOUBLE,
buf);
}

Expand All @@ -239,7 +218,7 @@ int PIOc_get_vard_double(int ncid, int varid, int decompid,
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, NULL, NC_UINT64,
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_UINT64,
buf);
}

Expand All @@ -260,7 +239,7 @@ int PIOc_get_vard_ulonglong(int ncid, int varid, int decompid,
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, NULL, NC_INT64, buf);
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_INT64, buf);
}

/**
Expand All @@ -278,10 +257,10 @@ int PIOc_get_vard_longlong(int ncid, int varid, int decompid,
* @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)
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, NULL, NC_NAT, buf);
return PIOc_get_vard_tc(ncid, varid, decompid, recnum, NC_NAT, buf);
}


Expand Down
4 changes: 4 additions & 0 deletions src/clib/pio_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,17 @@ extern "C" {
int PIOc_get_var1_tc(int ncid, int varid, const PIO_Offset *index, nc_type xtype,
void *buf);
int PIOc_get_var_tc(int ncid, int varid, nc_type xtype, void *buf);
int PIOc_get_vard_tc(int ncid, int varid, int decompid, const PIO_Offset recnum,
nc_type xtype, void *buf);

/* Generalized put functions. */
int PIOc_put_vars_tc(int ncid, int varid, const PIO_Offset *start, const PIO_Offset *count,
const PIO_Offset *stride, nc_type xtype, const void *buf);
int PIOc_put_var1_tc(int ncid, int varid, const PIO_Offset *index, nc_type xtype,
const void *op);
int PIOc_put_var_tc(int ncid, int varid, nc_type xtype, const void *op);
int PIOc_put_vard_tc(int ncid, int varid, int decompid, const PIO_Offset recnum,
nc_type xtype, const void *buf);

/* An internal replacement for a function pnetcdf does not
* have. */
Expand Down
44 changes: 22 additions & 22 deletions src/clib/pio_put_vard.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,26 +165,26 @@ PIOc_put_vard_int(int ncid, int varid, int decompid, const PIO_Offset recnum,
return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_INT, op);
}

/**
* Get strided, 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 op pointer to the data to be written.
* @return PIO_NOERR on success, error code otherwise.
* @author Ed Hartnett
*/
int
PIOc_put_vard_long(int ncid, int varid, int decompid, const PIO_Offset recnum,
const long *op)
{
return PIOc_put_vard_tc(ncid, varid, decompid, recnum, PIO_LONG_INTERNAL, op);
}
/* /\** */
/* * Get strided, 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 op pointer to the data to be written. */
/* * @return PIO_NOERR on success, error code otherwise. */
/* * @author Ed Hartnett */
/* *\/ */
/* int */
/* PIOc_put_vard_long(int ncid, int varid, int decompid, const PIO_Offset recnum, */
/* const long *op) */
/* { */
/* return PIOc_put_vard_tc(ncid, varid, decompid, recnum, PIO_LONG_INTERNAL, op); */
/* } */

/**
* Get strided, muti-dimensional subset of a floating point variable.
Expand Down Expand Up @@ -248,7 +248,7 @@ int
PIOc_put_vard_double(int ncid, int varid, int decompid, const PIO_Offset recnum,
const double *op)
{
return PIOc_put_vars_tc(ncid, varid, decompid, recnum, NC_DOUBLE, op);
return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_DOUBLE, op);
}

/**
Expand All @@ -270,7 +270,7 @@ int
PIOc_put_vard_ulonglong(int ncid, int varid, int decompid, const PIO_Offset recnum,
const unsigned long long *op)
{
return PIOc_put_vars_tc(ncid, varid, decompid, recnum, NC_UINT64, op);
return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_UINT64, op);
}

/**
Expand Down
12 changes: 8 additions & 4 deletions tests/cunit/test_darray.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,16 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank
test_data_in) != PIO_EBADID)
ERR(ERR_WRONG);

/* Set the record number. */
if ((ret = PIOc_setframe(ncid2, varid, 0)))
ERR(ret);
/* /\* Set the record number. *\/ */
/* if ((ret = PIOc_setframe(ncid2, varid, 0))) */
/* ERR(ret); */

/* /\* Read the data. *\/ */
/* if ((ret = PIOc_read_darray(ncid2, varid, ioid, arraylen, test_data_in))) */
/* ERR(ret); */

/* Read the data. */
if ((ret = PIOc_read_darray(ncid2, varid, ioid, arraylen, test_data_in)))
if ((ret = PIOc_get_vard(ncid2, varid, ioid, 0, (void *)test_data_in)))
ERR(ret);

/* Check the results. */
Expand Down

0 comments on commit f33f309

Please sign in to comment.