Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-00ddc7f
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
H5FileIOArray_source.c
Go to the documentation of this file.
1#define CONCAT2x(a,b) a##b
2#define CONCAT2(a,b) CONCAT2x(a,b)
3#define CONCAT3x(a,b,c) a##b##c
4#define CONCAT3(a,b,c) CONCAT3x(a,b,c)
5
6#define ATYPE CONCAT2(TYPE,Array)
7#define TCODE CONCAT3(LAL_,TYPECODE,_TYPE_CODE)
8
9#define ALLOCFUNC CONCAT2(XLALH5DatasetAlloc,ATYPE)
10#define READFUNC CONCAT2(XLALH5DatasetRead,ATYPE)
11
12#define CREATEFUNC CONCAT2(XLALCreate,ATYPE)
13#define DESTROYFUNC CONCAT2(XLALDestroy,ATYPE)
14
16{
17 LALH5Dataset *dataset;
18 if (!file || !name || !array)
20 if (!array->data || !array->dimLength || !array->dimLength->length || !array->dimLength->data)
22 dataset = XLALH5DatasetAlloc(file, name, TCODE, array->dimLength);
23 if (!dataset)
25 if (XLALH5DatasetWrite(dataset, array->data) < 0) {
26 XLALH5DatasetFree(dataset);
28 }
29 return dataset;
30}
31
33{
34 ATYPE *array;
35 LALTYPECODE type;
36 UINT4Vector *dimLength;
37
38 if (!dset)
40
41 type = XLALH5DatasetQueryType(dset);
42 if (type != TCODE)
44
45 dimLength = XLALH5DatasetQueryDims(dset);
46 if (!dimLength)
48
49 array = CREATEFUNC(dimLength);
50 XLALDestroyUINT4Vector(dimLength);
51 if (!array)
53
54 if (XLALH5DatasetQueryData(array->data, dset) == -1) {
55 DESTROYFUNC(array);
57 }
58
59 return array;
60}
61
62#undef CONCAT2x
63#undef CONCAT2
64#undef CONCAT3x
65#undef CONCAT3
66
67#undef ATYPE
68#undef TCODE
69
70#undef ALLOCFUNC
71#undef READFUNC
72
73#undef CREATEFUNC
74#undef DESTROYFUNC
LALH5Dataset * XLALH5DatasetAlloc(LALH5File *file, const char *name, LALTYPECODE dtype, UINT4Vector *dimLength)
struct tagLALH5File LALH5File
Incomplete type for a HDF5 file.
Definition: H5FileIO.h:93
LALTYPECODE XLALH5DatasetQueryType(LALH5Dataset *dset)
struct tagLALH5Dataset LALH5Dataset
Incomplete type for a HDF5 dataset.
Definition: H5FileIO.h:102
int XLALH5DatasetWrite(LALH5Dataset *dset, void *data)
UINT4Vector * XLALH5DatasetQueryDims(LALH5Dataset *dset)
void XLALH5DatasetFree(LALH5Dataset *dset)
int XLALH5DatasetQueryData(void *data, LALH5Dataset *dset)
#define TCODE
#define ATYPE
#define ALLOCFUNC
#define READFUNC
#define CREATEFUNC
#define DESTROYFUNC
const char *const name
type name
Definition: UserInput.c:193
LALTYPECODE
Type codes: use these type codes to identify a LAL atomic data type, see Headers LAL(Atomic)Datatypes...
Definition: LALDatatypes.h:49
void XLALDestroyUINT4Vector(UINT4Vector *vector)
#define XLAL_ERROR_NULL(...)
Macro to invoke a failure from a XLAL routine returning a pointer.
Definition: XLALError.h:713
@ XLAL_ENOMEM
Memory allocation error.
Definition: XLALError.h:407
@ XLAL_EFAULT
Invalid pointer.
Definition: XLALError.h:408
@ XLAL_EFUNC
Internal function call failed bit: "or" this with existing error number.
Definition: XLALError.h:462
@ XLAL_ETYPE
Wrong or unknown type.
Definition: XLALError.h:422
@ XLAL_EINVAL
Invalid argument.
Definition: XLALError.h:409
Vector of type UINT4, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:118