mcDBchangeSetDimensions — Change dimensions of dataset on database
#include <memcom.h>
int mcDBchangeSetDimensions(int handle, const char* name,
int ndim, mcOff* newsize);mcDBchangeSetDimensions changes the
dimensions of an existing dataset name on the
database identified by handle. Note that the
function only changes the dimensions of a set, not the size of the
set. If the new dimension(s) specified do not match the total set
size an error is flagged. If completed successfully, the function
returns 0. Otherwise, a negative value indicating the
MemCom error number is returned.
handleDatabase handle of set to be created (input).
nameDataset name of set to be created on database (input).
ndimNumber of dimensions (input). Currently limited to 5.
newsizeArray of dimension ndim containing
the new dimensions (input). Example: For 2-dimensional sets
(i.e ndim set to 2),
newsize[0] will be the number of rows and
newsize[1] the number of columns if
ndim=2.
Change the dimensions of the one-dimensional set
COOR.1 to 2 dimensions. The second dimension
shall be 3: Thus, the total size must be modulo 3. First, the size
of the set is checked (handle is the database
handle):
mcSetAttributes att;
if (!mcDBinqSetAtt(handle, "COOR.1", &att)) {
fprintf(stderr, "COOR.1 not found\n");
return;
}Now, if ndim is 1 and size %
3 is 0, we can change the dimensions:
int ndim;
mcOff dim[2];
if (att.ndim != 1 || att.size % 3) {
fprintf(stderr, "COOR.1: ndim != 1 || size not modulo 3\n");
return;
}
ndim = 2;
dim[0] = att.size % 3;
dim[1] = 3;
return mcDBchangeSetDimensions(handle, "COOR.1", ndim, dim);