PIO  2.5.4
Functions
Writing Distributes Arrays

Write data from a distributed array to a netCDF file in C. More...

Functions

int PIOc_write_darray_multi (int ncid, const int *varids, int ioid, int nvars, PIO_Offset arraylen, void *array, const int *frame, void **fillvalue, bool flushtodisk)
 Write one or more arrays with the same IO decomposition to the file. More...
 
int find_var_fillvalue (file_desc_t *file, int varid, var_desc_t *vdesc)
 Find the fillvalue that should be used for a variable. More...
 
int PIOc_write_darray (int ncid, int varid, int ioid, PIO_Offset arraylen, void *array, void *fillvalue)
 Write a distributed array to the output file. More...
 
int PIOc_put_vard_text (int ncid, int varid, int decompid, const PIO_Offset recnum, const char *op)
 Put distributed array subset of a text variable. More...
 
int PIOc_put_vard_uchar (int ncid, int varid, int decompid, const PIO_Offset recnum, const unsigned char *op)
 Put distributed array subset of an unsigned char variable. More...
 
int PIOc_put_vard_schar (int ncid, int varid, int decompid, const PIO_Offset recnum, const signed char *op)
 Put distributed array subset of a signed char variable. More...
 
int PIOc_put_vard_ushort (int ncid, int varid, int decompid, const PIO_Offset recnum, const unsigned short *op)
 Put distributed array subset of an unsigned 16-bit integer variable. More...
 
int PIOc_put_vard_short (int ncid, int varid, int decompid, const PIO_Offset recnum, const short *op)
 Put distributed array subset of a 16-bit integer variable. More...
 
int PIOc_put_vard_uint (int ncid, int varid, int decompid, const PIO_Offset recnum, const unsigned int *op)
 Put distributed array subset of an unsigned integer variable. More...
 
int PIOc_put_vard_int (int ncid, int varid, int decompid, const PIO_Offset recnum, const int *op)
 Put distributed array subset of an integer variable. More...
 
int PIOc_put_vard_float (int ncid, int varid, int decompid, const PIO_Offset recnum, const float *op)
 Put distributed array subset of a floating point variable. More...
 
int PIOc_put_vard_longlong (int ncid, int varid, int decompid, const PIO_Offset recnum, const long long *op)
 Put distributed array subset of a 64-bit unsigned integer variable. More...
 
int PIOc_put_vard_double (int ncid, int varid, int decompid, const PIO_Offset recnum, const double *op)
 Put distributed array subset of a 64-bit floating point variable. More...
 
int PIOc_put_vard_ulonglong (int ncid, int varid, int decompid, const PIO_Offset recnum, const unsigned long long *op)
 Put distributed array subset of an unsigned 64-bit integer variable. More...
 
int PIOc_put_vard (int ncid, int varid, int decompid, const PIO_Offset recnum, const void *op)
 Write distributed array subset of a variable of any type. More...
 
int nc_put_vard_text (int ncid, int varid, int decompid, const size_t recnum, const char *op)
 Put distributed array subset of a text variable. More...
 
int nc_put_vard_uchar (int ncid, int varid, int decompid, const size_t recnum, const unsigned char *op)
 Put distributed array subset of an unsigned char variable. More...
 
int nc_put_vard_schar (int ncid, int varid, int decompid, const size_t recnum, const signed char *op)
 Put distributed array subset of a signed char variable. More...
 
int nc_put_vard_ushort (int ncid, int varid, int decompid, const size_t recnum, const unsigned short *op)
 Put distributed array subset of an unsigned 16-bit integer variable. More...
 
int nc_put_vard_short (int ncid, int varid, int decompid, const size_t recnum, const short *op)
 Put distributed array subset of a 16-bit integer variable. More...
 
int nc_put_vard_uint (int ncid, int varid, int decompid, const size_t recnum, const unsigned int *op)
 Put distributed array subset of an unsigned integer variable. More...
 
int nc_put_vard_int (int ncid, int varid, int decompid, const size_t recnum, const int *op)
 Put distributed array subset of an integer variable. More...
 
int nc_put_vard_float (int ncid, int varid, int decompid, const size_t recnum, const float *op)
 Put distributed array subset of a floating point variable. More...
 
int nc_put_vard_longlong (int ncid, int varid, int decompid, const size_t recnum, const long long *op)
 Put distributed array subset of a 64-bit unsigned integer variable. More...
 
int nc_put_vard_double (int ncid, int varid, int decompid, const size_t recnum, const double *op)
 Put distributed array subset of a 64-bit floating point variable. More...
 
int nc_put_vard_ulonglong (int ncid, int varid, int decompid, const size_t recnum, const unsigned long long *op)
 Put distributed array subset of an unsigned 64-bit integer variable. More...
 
int nc_put_vard (int ncid, int varid, int decompid, const size_t recnum, const void *op)
 Write distributed array subset of a variable of any type. More...
 

Detailed Description

Write data from a distributed array to a netCDF file in C.

Write distributed arrays to a Variable in C.

Function Documentation

◆ find_var_fillvalue()

int find_var_fillvalue ( file_desc_t file,
int  varid,
var_desc_t vdesc 
)

Find the fillvalue that should be used for a variable.

Parameters
fileInfo about file we are writing to.
varidthe variable ID.
vdescpointer to var_desc_t info for this var.
Returns
0 for success, non-zero error code for failure.
Author
Ed Hartnett

◆ nc_put_vard()

int nc_put_vard ( int  ncid,
int  varid,
int  decompid,
const size_t  recnum,
const void *  op 
)

Write distributed array subset of a variable of any type.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ nc_put_vard_double()

int nc_put_vard_double ( int  ncid,
int  varid,
int  decompid,
const size_t  recnum,
const double *  op 
)

Put distributed array subset of a 64-bit floating point variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ nc_put_vard_float()

int nc_put_vard_float ( int  ncid,
int  varid,
int  decompid,
const size_t  recnum,
const float *  op 
)

Put distributed array subset of a floating point variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ nc_put_vard_int()

int nc_put_vard_int ( int  ncid,
int  varid,
int  decompid,
const size_t  recnum,
const int *  op 
)

Put distributed array subset of an integer variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ nc_put_vard_longlong()

int nc_put_vard_longlong ( int  ncid,
int  varid,
int  decompid,
const size_t  recnum,
const long long *  op 
)

Put distributed array subset of a 64-bit unsigned integer variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ nc_put_vard_schar()

int nc_put_vard_schar ( int  ncid,
int  varid,
int  decompid,
const size_t  recnum,
const signed char *  op 
)

Put distributed array subset of a signed char variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ nc_put_vard_short()

int nc_put_vard_short ( int  ncid,
int  varid,
int  decompid,
const size_t  recnum,
const short *  op 
)

Put distributed array subset of a 16-bit integer variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ nc_put_vard_text()

int nc_put_vard_text ( int  ncid,
int  varid,
int  decompid,
const size_t  recnum,
const char *  op 
)

Put distributed array subset of a text variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ nc_put_vard_uchar()

int nc_put_vard_uchar ( int  ncid,
int  varid,
int  decompid,
const size_t  recnum,
const unsigned char *  op 
)

Put distributed array subset of an unsigned char variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ nc_put_vard_uint()

int nc_put_vard_uint ( int  ncid,
int  varid,
int  decompid,
const size_t  recnum,
const unsigned int *  op 
)

Put distributed array subset of an unsigned integer variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ nc_put_vard_ulonglong()

int nc_put_vard_ulonglong ( int  ncid,
int  varid,
int  decompid,
const size_t  recnum,
const unsigned long long *  op 
)

Put distributed array subset of an unsigned 64-bit integer variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ nc_put_vard_ushort()

int nc_put_vard_ushort ( int  ncid,
int  varid,
int  decompid,
const size_t  recnum,
const unsigned short *  op 
)

Put distributed array subset of an unsigned 16-bit integer variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ PIOc_put_vard()

int PIOc_put_vard ( int  ncid,
int  varid,
int  decompid,
const PIO_Offset  recnum,
const void *  op 
)

Write distributed array subset of a variable of any type.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ PIOc_put_vard_double()

int PIOc_put_vard_double ( int  ncid,
int  varid,
int  decompid,
const PIO_Offset  recnum,
const double *  op 
)

Put distributed array subset of a 64-bit floating point variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ PIOc_put_vard_float()

int PIOc_put_vard_float ( int  ncid,
int  varid,
int  decompid,
const PIO_Offset  recnum,
const float *  op 
)

Put distributed array subset of a floating point variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ PIOc_put_vard_int()

int PIOc_put_vard_int ( int  ncid,
int  varid,
int  decompid,
const PIO_Offset  recnum,
const int *  op 
)

Put distributed array subset of an integer variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ PIOc_put_vard_longlong()

int PIOc_put_vard_longlong ( int  ncid,
int  varid,
int  decompid,
const PIO_Offset  recnum,
const long long *  op 
)

Put distributed array subset of a 64-bit unsigned integer variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ PIOc_put_vard_schar()

int PIOc_put_vard_schar ( int  ncid,
int  varid,
int  decompid,
const PIO_Offset  recnum,
const signed char *  op 
)

Put distributed array subset of a signed char variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ PIOc_put_vard_short()

int PIOc_put_vard_short ( int  ncid,
int  varid,
int  decompid,
const PIO_Offset  recnum,
const short *  op 
)

Put distributed array subset of a 16-bit integer variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ PIOc_put_vard_text()

int PIOc_put_vard_text ( int  ncid,
int  varid,
int  decompid,
const PIO_Offset  recnum,
const char *  op 
)

Put distributed array subset of a text variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ PIOc_put_vard_uchar()

int PIOc_put_vard_uchar ( int  ncid,
int  varid,
int  decompid,
const PIO_Offset  recnum,
const unsigned char *  op 
)

Put distributed array subset of an unsigned char variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ PIOc_put_vard_uint()

int PIOc_put_vard_uint ( int  ncid,
int  varid,
int  decompid,
const PIO_Offset  recnum,
const unsigned int *  op 
)

Put distributed array subset of an unsigned integer variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ PIOc_put_vard_ulonglong()

int PIOc_put_vard_ulonglong ( int  ncid,
int  varid,
int  decompid,
const PIO_Offset  recnum,
const unsigned long long *  op 
)

Put distributed array subset of an unsigned 64-bit integer variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ PIOc_put_vard_ushort()

int PIOc_put_vard_ushort ( int  ncid,
int  varid,
int  decompid,
const PIO_Offset  recnum,
const unsigned short *  op 
)

Put distributed array subset of an unsigned 16-bit integer variable.

This routine is called collectively by all tasks in the communicator ios.union_comm.

Parameters
ncididentifies the netCDF file
varidthe variable ID number
decompidthe decomposition ID.
recnumthe record number.
oppointer to the data to be written.
Returns
PIO_NOERR on success, error code otherwise.
Author
Ed Hartnett

◆ PIOc_write_darray()

int PIOc_write_darray ( int  ncid,
int  varid,
int  ioid,
PIO_Offset  arraylen,
void *  array,
void *  fillvalue 
)

Write a distributed array to the output file.

This routine aggregates output on the compute nodes and only sends it to the IO nodes when the compute buffer is full or when a flush is triggered.

Internally, this function will:

  • Locate info about this file, decomposition, and variable.
  • If we don't have a fillvalue for this variable, determine one and remember it for future calls.
  • Initialize or find the multi_buffer for this record/var.
  • Find out how much free space is available in the multi buffer and flush if needed.
  • Store the new user data in the mutli buffer.
  • If needed (only for subset rearranger), fill in gaps in data with fillvalue.
  • Remember the frame value (i.e. record number) of this data if there is one.

NOTE: The write multi buffer wmulti_buffer is the cache on compute nodes that will collect and store multiple variables before sending them to the io nodes. Aggregating variables in this way leads to a considerable savings in communication expense. Variables in the wmb array must have the same decomposition and base data size and we also need to keep track of whether each is a recordvar (has an unlimited dimension) or not.

Parameters
ncidthe ncid of the open netCDF file.
varidthe ID of the variable that these data will be written to.
ioidthe I/O description ID as passed back by PIOc_InitDecomp().
arraylenthe length of the array to be written. This should be at least the length of the local component of the distrubited array. (Any values beyond length of the local component will be ignored.)
arraypointer to an array of length arraylen with the data to be written. This is a pointer to the distributed portion of the array that is on this task.
fillvaluepointer to the fill value to be used for missing data.
Returns
0 for success, non-zero error code for failure.
Author
Jim Edwards, Ed Hartnett

◆ PIOc_write_darray_multi()

int PIOc_write_darray_multi ( int  ncid,
const int *  varids,
int  ioid,
int  nvars,
PIO_Offset  arraylen,
void *  array,
const int *  frame,
void **  fillvalue,
bool  flushtodisk 
)

Write one or more arrays with the same IO decomposition to the file.

This funciton is similar to PIOc_write_darray(), but allows the caller to use their own data buffering (instead of using the buffering implemented in PIOc_write_darray()).

When the user calls PIOc_write_darray() one or more times, then PIO_write_darray_multi() will be called when the buffer is flushed.

Internally, this function will:

  • Find info about file, decomposition, and variable.
  • Do a special flush for pnetcdf if needed.
  • Allocates a buffer big enough to hold all the data in the multi-buffer, for all tasks.
  • Calls rearrange_comp2io() to move data from compute to IO tasks.
  • For parallel iotypes (pnetcdf and netCDF-4 parallel) call pio_write_darray_multi_nc().
  • For serial iotypes (netcdf classic and netCDF-4 serial) call write_darray_multi_serial().
  • For subset rearranger, create holegrid to write missing data. Then call pio_write_darray_multi_nc() or write_darray_multi_serial() to write the holegrid.
  • Special buffer flush for pnetcdf.
Parameters
ncididentifies the netCDF file.
varidsan array of length nvars containing the variable ids to be written.
ioidthe I/O description ID as passed back by PIOc_InitDecomp().
nvarsthe number of variables to be written with this call.
arraylenthe length of the array to be written. This is the length of the distrubited array. That is, the length of the portion of the data that is on the processor. The same arraylen is used for all variables in the call.
arraypointer to the data to be written. This is a pointer to an array of arrays with the distributed portion of the array that is on this processor. There are nvars arrays of data, and each array of data contains one record worth of data for that variable.
framean array of length nvars with the frame or record dimension for each of the nvars variables in IOBUF. NULL if this iodesc contains non-record vars.
fillvaluepointer an array (of length nvars) of pointers to the fill value to be used for missing data.
flushtodisknon-zero to cause buffers to be flushed to disk.
Returns
0 for success, error code otherwise.
Author
Jim Edwards, Ed Hartnett