FiberBundleHDF5  FiberHDF5 Documentation, Revision 2026
High-Performance Fiber Bundle Data Model for Scientific Visualization
Loading...
Searching...
No Matches
Field Operations

Functions

F5_API int F5Fopen (F5Path *f, const char *fieldname)
F5_API F5PathF5FopenMostRecentSlice (hid_t File_id, double *t, const char *gridname, const char *fieldname, const char *coordinate_system)
F5_API void F5Fclose (F5Path *f)
F5_API hid_t F5Fgrab (F5Path *f)
F5_API hid_t F5Fget_type2 (F5Path *f, hid_t elink_fapl_id)
F5_API hid_t F5Tget_space (F5Path *f)
F5_API int F5Fcreate (F5Path *fpath, const char *fieldname, int dimension, hsize_t *dims, hid_t fieldtype, hid_t property_id)
F5_API const char * F5Fwhatsup (F5ErrorCode)
F5_API F5ErrorCode F5Fwrite (F5Path *fpath, const char *fieldname, int dimension, hsize_t *dims, hid_t fieldtype, hid_t memtype, const void *dataPtr, hid_t property_id)
F5_API F5ErrorCode F5FwriteHyperDimensional (F5Path *fpath, const char *fieldname, int rank, hsize_t *dims, hid_t fieldtype, hid_t memtype, const void *dataPtr, hid_t property_id)
F5_API F5ErrorCode F5FwriteIMAGE (F5Path *fpath, const char *fieldname, int dimension, hsize_t *dims, hid_t fieldtype, hid_t memtype, const void *dataPtr, hid_t property_id)
F5_API F5ErrorCode F5FwriteX (F5Path *fpath, const char *fieldname, int rank, const hsize_t dims[], hid_t fieldtype, hid_t memtype, const void *const dataPtr[], const int polynom_order[], const int component_map[], hid_t property_id)
F5_API int F5Fwrite_linear (F5Path *fpath, const char *fieldname, int rank, hsize_t *dims, hid_t fieldtype, const void *base, const void *delta)
F5_API F5ErrorCode F5Fwrite_fraction (F5Path *fpath, const char *fieldname, int rank, const hsize_t *full_dims, const hsize_t *fragment_dims, hid_t fieldtype, hid_t memtype, const void *dataPtr, const hsize_t *datastart, const hsize_t *start_border, const hsize_t *end_border, const char *fraction_name, hid_t property_id)
F5_API F5ErrorCode F5Fwrite_fractionS (F5Path *fpath, const char *fieldname, int rank, const hsize_t *full_dims, const hsize_t *fragment_dims, hid_t fieldtype, hid_t memtype, const void *dataPtr, const hsize_t *datastart, const hsize_t *start_border, const hsize_t *end_border, const char *fraction_name, hid_t property_id)
F5_API int F5FSwrite_fraction (F5Path *fpath, const char *fieldname, int rank, const hsize_t *full_dims, const hsize_t *fragment_dims, hid_t fieldtype, hid_t memtype, const void *const *dataPtr, const hsize_t *datastart, const hsize_t *start_border, const hsize_t *end_border, const char *fraction_name, hid_t property_id, int AllowFullCoverage)
F5_API int F5Fwrite_linear_fraction (F5Path *fpath, const char *fieldname, int rank, const hsize_t *full_dims, const hsize_t *fragment_dims, hid_t fieldtype, const void *base, const void *delta, const hsize_t *datastart, const char *fraction_name)
F5_API int F5Fis_linear (F5Path *fpath, const char *fieldname)

Detailed Description

Interfacing data set creation/write routines using the F5Path structure. Calls the low-level Field operation functions, but is designed for the end-user.

Function Documentation

◆ F5Fclose()

F5_API void F5Fclose ( F5Path * f)

Close a field entry within an F5Path object and leave all other entries intact.

Definition at line 92 of file F5F.c.

93{
94 if (!f) return;
95
96 if (f->Field_hid>0)
97 {
98 if (F5Fis_group(f) )
99 H5Gclose( f->Field_hid );
100 else
101 H5Dclose( f->Field_hid );
102
103 f->Field_hid = 0;
104 }
105}
int F5Fis_group(const F5Path *fpath)
Definition F5F.c:126
#define H5Gclose(x)
Definition F5X.h:144
hid_t Field_hid
Definition F5Path.h:59

References F5Fis_group(), F5Path::Field_hid, and H5Gclose.

Referenced by F5closeVC(), F5Cwrite_triangular_surface(), F5Fcreate(), F5Flink_triangular_surface(), F5Fopen(), F5FSwrite_fraction(), F5Fwrite_1D(), F5Fwrite_flexible(), F5Fwrite_fraction(), F5Fwrite_fraction_external(), F5Fwrite_fractionS(), F5Fwrite_linear(), F5Fwrite_linear_fraction(), F5FwriteIMAGE(), F5Fwrites(), F5FwriteX(), F5Rcreate_curvilinear_cartesian3D(), F5Rcreate_rectilinear(), F5Rcreate_uniform_cartesian3D(), F5Rcreate_uniform_cartesian3Dbbox(), F5Rcreate_uniformd(), and F5Rcreate_uniformf().

◆ F5Fcreate()

F5_API int F5Fcreate ( F5Path * fpath,
const char * fieldname,
int dimension,
hsize_t * dims,
hid_t fieldtype,
hid_t property_id )

Create an HDF5 dataset for further treatment with raw HDF5 functions, e.g. to write an hyperslab instead of the full dataset at once.

Parameters
property_idAn HDF5 dataset property ID. If it is negative, then a default property will be created locally via
H5Pcreate(H5P_DATASET_CREATE)
.
dataspace_idPointer to an HDF5 identifier, that will be used to store a shared dataspace. It may be NULL, in which case a local dataspace is created. Until shared dataspaces are implemented in HDF5, this will make no difference in the actual HDF5 file.
fpathAn F5 Path object that has been created by a F5Rcreate() or related calls from the F5R group. Any previous field ID contained there will be closed and overwritten.
fieldnameThe name of the field. It may be chosen arbitrarily, but must not contain slashes "/". It is furthermore recommended to avoid special characters - even if they work - and to keep the name short and concise).
dimensionThe dimensionality of the data set.
dimsThe extension of the data set.
fieldtypeAn HDF5 type identifier.
See also
F5Lcreate()
Todo
Add consistency check of sustained dataspace properties across multiple fields per representation.
Returns
zero if the entry could not be opened, non-zero otherwise.

Definition at line 328 of file F5F.c.

330{
331hsize_t save_dims[FIBER_MAX_RANK];
332
333 F5printf(40,"F5Fcreate()");
334
335 if (!fpath) return 0;
336
337 F5Fclose(fpath);
338
340 F5B_permute_dimensions(save_dims, rank, dims, fpath->myChart->perm_vector, F5Bget_chart_dims(fpath->myChart));
342
343 if (!F5LTset_dataspace(fpath, rank, save_dims))
344 {
345 F5printf(-1, "F5Fcreate(%s): cannot create, inconsistent dataspace!", fieldname);
346 return 0;
347 }
348
349 fpath->Field_hid = F5Lcreate(fpath->Representation_hid, fieldname,
350 rank, save_dims,
351 F5file_type(fpath, fieldtype), property_id);
352
353 if (fpath->Field_hid<0)
354 {
355 F5printf(0,"F5Fcreate -> F5Lcreate() FAILED!");
356 return 0;
357 }
358 else
360
361 F5I_add_field(fpath, fieldname);
362
363 F5printf(40,"~F5Fcreate() ok");
364 return 1;
365}
int F5Bget_chart_dims(const ChartDomain_IDs *IDs)
Definition F5Bchart.c:899
hsize_t * F5B_permute_dimensions(hsize_t *target_dims, int rank, const hsize_t *source_dims, int perm_vector[FIBER_MAX_RANK], int perm_vector_size)
Definition F5Bchart.c:72
hid_t F5file_type(F5Path *fpath, hid_t fieldtype)
Definition F5Bchart.c:941
F5_API int F5LTset_dataspace(F5Path *f, int rank, hsize_t *dims)
Definition F5LT.c:43
hid_t F5LTmake_enum_type(F5Path *fpath)
Definition F5LT.c:179
#define FIBER_MAX_RANK
Definition F5defs.h:105
@ Contiguous
Definition F5defs.h:269
void F5I_add_field(F5Path *fpath, const char *fieldname)
Definition F5private.c:178
int F5printf_indent
Definition F5private.c:349
#define F5printf(verbosity,...)
Definition F5private.h:60
herr_t F5Tset_field_enum(hid_t loc_id, hid_t enum_type_id, ArrayType what)
Definition F5types.c:268
void F5Fclose(F5Path *f)
Definition F5F.c:92
hid_t F5Lcreate(hid_t R_id, const char *fieldname, int dimension, const hsize_t *dims, hid_t fieldtype, hid_t dataset_creation_property_id)
Definition F5L.c:60
int perm_vector[FIBER_MAX_RANK]
Definition F5Bchart.h:141
hid_t Representation_hid
Definition F5Path.h:58
ChartDomain_IDs * myChart
Definition F5Path.h:33

References Contiguous, F5B_permute_dimensions(), F5Bget_chart_dims(), F5Fclose(), F5file_type(), F5I_add_field(), F5Lcreate(), F5LTmake_enum_type(), F5LTset_dataspace(), F5printf, F5printf_indent, F5Tset_field_enum(), FIBER_MAX_RANK, F5Path::Field_hid, F5Path::myChart, ChartDomain_IDs::perm_vector, and F5Path::Representation_hid.

◆ F5Fget_type2()

F5_API hid_t F5Fget_type2 ( F5Path * f,
hid_t elink_fapl_id )

Get the data type of an field, given an F5 path.

Returns
An HDF5 datatype, caller must call H5Tclose().

Definition at line 161 of file F5F.c.

162{
163 return F5Lget_type(f->Field_hid, F5Fis_group(f),
164 elink_fapl_id);
165}
hid_t F5Lget_type(hid_t Field_hid, int FieldIDisGroup, hid_t fapl_id)
Definition F5L.c:173

References F5Fis_group(), F5Lget_type(), and F5Path::Field_hid.

Referenced by F5Fget_type().

◆ F5Fgrab()

F5_API hid_t F5Fgrab ( F5Path * f)

Take an HDF5 field identifier out of control of the F5Path. The path identifier is no longer pointing to a field after this operations, it is just a truncated path up to the representation group. It is the responsibility of the caller to close the returned HDF5 identifier, which can either be a group or dataset. This can be determined either by inspecting f->FieldIDisGroup or by H5Gget_objinfo() . Note that using this function allows to keep a field ID open for later use, but undermines the transparency of fields as beeing stored as either datasets or a group with multiple datasets.

Definition at line 107 of file F5F.c.

108{
109 if (!f) return -1;
110
111 if (f->Field_hid>0)
112 {
113 hid_t id = f->Field_hid;
114 /*
115 if (F5Fis_group(f) )
116 H5Gclose( f->Field_hid );
117 else
118 H5Dclose( f->Field_hid );
119 */
120 f->Field_hid = 0;
121 return id;
122 }
123 return -1;
124}

References F5Path::Field_hid.

◆ F5Fis_linear()

F5_API int F5Fis_linear ( F5Path * fpath,
const char * fieldname )

Check if a field within an F5 path is a linear mapping of points to values.

Todo
Implement. Similar to F5Lread_linear().

Definition at line 1512 of file F5F.c.

1513{
1514 return F5Lis_linear(fpath->Representation_hid, fieldname);
1515}
int F5Lis_linear(hid_t Rep_id, const char *fieldname)
Definition F5L.c:985

References F5Lis_linear(), and F5Path::Representation_hid.

◆ F5Fopen()

F5_API int F5Fopen ( F5Path * f,
const char * fieldname )

Open a field entry within an F5Path object and leave all other entries intact. An previously opened field entry is closed before the new one is opened.

Returns
zero if the entry could not be opened, non-zero otherwise.
Note
F5 does no HDF5 error management by itself. If any error messages from HDF5 when trying to open a non-existing field shall be emitted, the application code has to set the HDF5 error handler. F5 guarantees to leave these error handlers intact, even if they are locally disabled during some operations.

Definition at line 66 of file F5F.c.

67{
68 F5Fclose(f);
69
70 H5E_BEGIN_TRY
71 f->Field_hid = H5Dopen2(f->Representation_hid, fieldname, H5P_DEFAULT);
72 H5E_END_TRY
73
74 if (f->Field_hid<0)
75 {
76 H5E_BEGIN_TRY
77 f->Field_hid = H5Gopen2(f->Representation_hid, fieldname, H5P_DEFAULT);
78 H5E_END_TRY
79 if (f->Field_hid<0)
80 {
81 F5printf(10,"F5Fopen(,%s) Path entry is neither a group nor a data set (could be a named data type)\n", fieldname);
82 return 0;
83 }
84 }
85
86 if (f->Field_hid<0)
87 return 0;
88
89 return 1;
90}

References F5Fclose(), F5printf, F5Path::Field_hid, and F5Path::Representation_hid.

◆ F5FopenMostRecentSlice()

F5_API F5Path * F5FopenMostRecentSlice ( hid_t File_id,
double * t,
const char * gridname,
const char * fieldname,
const char * coordinate_system )

References F5_API.

◆ F5FSwrite_fraction()

F5_API int F5FSwrite_fraction ( F5Path * fpath,
const char * fieldname,
int rank,
const hsize_t * full_dims,
const hsize_t * fragment_dims,
hid_t fieldtype,
hid_t memtype,
const void *const * dataPtr,
const hsize_t * datastart,
const hsize_t * start_border,
const hsize_t * end_border,
const char * fraction_name,
hid_t property_id,
int AllowFullCoverage )

Write a dataset given as separate components which only covers a fraction of the entire representation's domain.

Parameters
dimensionThe dimension of the data set.
full_dimsThe extension of the full (virtual) data set in each dimension, i.e. the size of the entire field when reconstructed from all fragments covering this field.
datastartThe (multidimensional) start index of the saved data set.
fragment_dimsThe number of elements of this fraction.
fraction_nameAn optional string to name this fraction. It may be NULL to use an internal default.
AllowFullCoverageIf non-zero, then the data set is not written as a fragment in case its dimensions cover the entire data space. Use this reduction option with care. This automatism might lead to bad effects, especcially it eliminates the capability to add fragments later. By default, leave this parameter at 0.
Note
Subsampling can not be specified here. Subsampled data need to go into another Topology group.
Returns
true

Definition at line 1157 of file F5F.c.

1164{
1165hid_t field_id;
1166hsize_t full_dims[FIBER_MAX_RANK], start_dims[FIBER_MAX_RANK], ldims[FIBER_MAX_RANK],
1167 sborder[FIBER_MAX_RANK], eborder[FIBER_MAX_RANK];
1168
1169 F5printf(40, "F5FSwrite_fraction()");
1171 F5Tpermute_dimensions(fpath, rank, full_dims , dims );
1172 F5Tpermute_dimensions(fpath, rank, start_dims, datastart );
1173 F5Tpermute_dimensions(fpath, rank, ldims , frag_dims );
1174 F5Tpermute_dimensions(fpath, rank, sborder , start_border );
1175 F5Tpermute_dimensions(fpath, rank, eborder , end_border );
1176
1177 if (rank==3)
1178 {
1179#ifdef DO_DATASPACE_CONSISTENCY_CHECK
1180 if (dims)
1181 {
1182 F5printf(60, "F5FSwrite_fraction() : "
1183 "global dims=[%d,%d,%d] datastart=[%d,%d,%d] ldims=[%d,%d,%d]",
1184 (int)dims[0], (int)dims[1], (int)dims[2],
1185 (int)datastart[0], (int)datastart[1], (int)datastart[2],
1186 (int)ldims[0], (int)ldims[1] , (int)ldims[2]
1187 );
1188
1189 F5printf(60, "F5FSwrite_fraction()->"
1190 "full dataset=[%d,%d,%d] start=[%d,%d,%d] ldims=[%d,%d,%d]",
1191 (int)full_dims[0], (int)full_dims[1], (int)full_dims[2],
1192 (int)start_dims[0],(int)start_dims[1],(int)start_dims[2],
1193 (int)ldims[0], (int)ldims[1] , (int)ldims[2]
1194 );
1195 }
1196 else
1197 {
1198 F5printf(60, "F5FSwrite_fraction() : "
1199 "(no global dims) datastart=[%d,%d,%d] ldims=[%d,%d,%d]",
1200 (int)datastart[0], (int)datastart[1], (int)datastart[2],
1201 (int)ldims[0], (int)ldims[1] , (int)ldims[2]
1202 );
1203
1204 F5printf(60, "F5FSwrite_fraction()->"
1205 "(no full data dimensions) start=[%d,%d,%d] ldims=[%d,%d,%d]",
1206 (int)start_dims[0],(int)start_dims[1],(int)start_dims[2],
1207 (int)ldims[0], (int)ldims[1] , (int)ldims[2]
1208 );
1209 }
1210#endif
1211 }
1213 F5Fclose( fpath );
1214
1215#ifdef DO_DATASPACE_CONSISTENCY_CHECK
1216 if (dims)
1217 {
1218 if (!F5LTset_dataspace(fpath, rank, full_dims))
1219 {
1220 F5printf(-1, "F5FSwrite_fraction(%s): cannot create, inconsistent dataspace!", fieldname);
1221 return 0;
1222 }
1223 }
1224#endif
1225
1226#if 0
1227 if (F5B_identical_dims(rank, full_dims, end_dims) )
1228 F5printf(80, "F5FSwrite_fraction(%s) dimensions cover full dataset", fieldname);
1229 else
1230 F5printf(80, "F5FSwrite_fraction(%s) dimensions do not cover full dataset", fieldname);
1231
1232 if (F5B_iszero_dims(rank, start_dims) )
1233 F5printf(80, "F5FSwrite_fraction(%s) fragment starts at zero", fieldname);
1234 else
1235 F5printf(80, "F5FSwrite_fraction(%s) fragment starts at some offset", fieldname);
1236#endif
1237
1238 if (AllowFullCoverage && F5B_identical_dims(rank, full_dims, ldims) && F5B_iszero_dims(rank, start_dims) )
1239 {
1240 F5printf(8, "F5FSwrite_fraction(%s) writing full dataset", fieldname);
1241
1242 fpath->Field_hid = F5Lwrites(fpath->Representation_hid, fieldname,
1243 rank, full_dims,
1244 F5file_type(fpath, fieldtype), memtype, dataPtr,
1245 F5LTmake_enum_type(fpath), property_id);
1246
1247 if (fpath->Field_hid<=0)
1248 return -1;
1249
1251 F5I_add_field(fpath, fieldname);
1252 F5printf(9, "~F5FSwrite_fraction(%s) writing full dataset\n", fieldname);
1253
1254 return 1;
1255 }
1256 F5printf(8, "F5FSwrite_fraction(%s) writing dataset fragment\n", fieldname);
1257
1258 field_id = F5LSwrite_fraction(fpath->Representation_hid, fieldname, rank, full_dims, ldims,
1259 F5file_type(fpath, fieldtype), memtype, dataPtr,
1260 datastart?start_dims:NULL,
1261 start_border?sborder:NULL, end_border?eborder:NULL,
1262 fraction_name, F5LTmake_enum_type(fpath), property_id);
1263
1264 fpath->Field_hid = field_id;
1265
1266 if (fpath->Field_hid<=0)
1267 return -1;
1268
1269/*
1270 F5printf(10,"~F5FSwrite_fraction(%s) temporarily set type attribute...", fieldname);
1271 F5Dset_type_attribute(fpath->Field_hid, F5file_type(fpath, fieldtype) );
1272*/
1273
1275
1276 F5I_add_field(fpath, fieldname);
1277
1278 F5printf(9, "F5FSwrite_fraction(%s) writing dataset fragment\n", fieldname);
1279 return 1;
1280}
int F5B_iszero_dims(int rank, hsize_t *dims)
Definition F5F.c:1148
F5_API hsize_t * F5Tpermute_dimensions(F5Path *fpath, int rank, hsize_t *target_dims, const hsize_t *source_dims)
Definition F5F.c:277
@ SeparatedCompound
Definition F5defs.h:270
@ FragmentedSeparatedCompound
Definition F5defs.h:273
hid_t F5Lwrites(hid_t R_id, const char *fieldname, int dimension, const hsize_t *dims, hid_t fieldtype, hid_t memtype, const void *const *dataPtr, hid_t enum_type, hid_t property_id)
Definition F5L.c:1096
hid_t F5LSwrite_fraction(hid_t R_id, const char *fieldname, int rank, const hsize_t *full_dims, const hsize_t *datasize, hid_t fieldtype, hid_t memtype, const void *const *dataPtr, const hsize_t *datastart, const hsize_t *start_border, const hsize_t *end_border, const char *fraction_name, hid_t enum_type, hid_t property_id)
Definition F5L.c:793

References F5B_iszero_dims(), F5Fclose(), F5file_type(), F5I_add_field(), F5LSwrite_fraction(), F5LTmake_enum_type(), F5LTset_dataspace(), F5Lwrites(), F5printf, F5printf_indent, F5Tpermute_dimensions(), F5Tset_field_enum(), FIBER_MAX_RANK, F5Path::Field_hid, FragmentedSeparatedCompound, F5Path::Representation_hid, and SeparatedCompound.

◆ F5Fwhatsup()

F5_API const char * F5Fwhatsup ( F5ErrorCode EC)

Return a string explaining the meaning of a certain error code.

Definition at line 367 of file F5F.c.

368{
369 switch(EC)
370 {
371 case F5_SUCCESS: return "OK";
372 case F5ERROR_INVALID_FPATH: return "Invalid Path";
373 case F5ERROR_INCONSISTENT_DATASPACE: return "Inconsistent Dataspace";
374 case F5ERROR_INVALID_FRAGMENT_START: return "Fragment starts beyond dataspace";
375 case F5ERROR_INVALID_FRAGMENT_END: return "Fragment extends beyond dataspace";
376 case F5ERROR_ALREADY_EXISTS: return "Object already exists";
377 case F5ERROR_COMPOUND_EXPECTED: return "Compound type expected";
378 case F5ERROR_COMPONENTMAP_EXPECTED: return "Component map expected";
379 case F5ERROR_COMPONENTMAP_INVALID: return "Component map invalid";
380
381 case F5ERROR_NONSPECIFIED: return "Unspecified error";
382
383 default: return "Invalid error code (compile-time bug)";
384 }
385}
@ F5ERROR_COMPONENTMAP_INVALID
Definition F5F.h:262
@ F5ERROR_INVALID_FRAGMENT_START
Definition F5F.h:236
@ F5ERROR_INVALID_FRAGMENT_END
Definition F5F.h:239
@ F5ERROR_ALREADY_EXISTS
Definition F5F.h:253
@ F5_SUCCESS
Definition F5F.h:226
@ F5ERROR_INVALID_FPATH
Definition F5F.h:229
@ F5ERROR_NONSPECIFIED
Definition F5F.h:264
@ F5ERROR_INCONSISTENT_DATASPACE
Definition F5F.h:233
@ F5ERROR_COMPOUND_EXPECTED
Definition F5F.h:256
@ F5ERROR_COMPONENTMAP_EXPECTED
Definition F5F.h:259

References F5_SUCCESS, F5ERROR_ALREADY_EXISTS, F5ERROR_COMPONENTMAP_EXPECTED, F5ERROR_COMPONENTMAP_INVALID, F5ERROR_COMPOUND_EXPECTED, F5ERROR_INCONSISTENT_DATASPACE, F5ERROR_INVALID_FPATH, F5ERROR_INVALID_FRAGMENT_END, F5ERROR_INVALID_FRAGMENT_START, and F5ERROR_NONSPECIFIED.

◆ F5Fwrite()

F5_API F5ErrorCode F5Fwrite ( F5Path * fpath,
const char * fieldname,
int dimension,
hsize_t * dims,
hid_t fieldtype,
hid_t memtype,
const void * dataPtr,
hid_t property_id )

Write some data as a contiguous field under the given F5Path location with the given name.

The dimensions of the data must match exactly the dataspace of the containing Skeleton. Use F5FwriteHyperDimensional() to store a dataset that is higher-dimensional than the containing Skeleton.

Parameters
fpathThe F5Path pointing to the location of the Field. The field ID filled in. Any previous field ID contained there will be closed and overwritten.
property_idAn HDF5 dataset property ID. If it is negative, then a default property will be created locally via
H5Pcreate(H5P_DATASET_CREATE)
.
dimensionThe dimensionality of the data set. You may use F5Lwrite1D() as a convenience shortcut for one-dimensional data sets.
dimsThe extension of the data set.
Note
Fields are always associated to certain coordinates system. The field type must be consistent with its coordinate system, e.g. one may not store a vector field in polar coordinates in a cartesian chart. Formally, this can be done because not all API functions have the ability to check for this consistency. However, a field type which is not part of a certain coordinate system will be treated as non-existent when reading the file later.
If a field is a structure made by separate data arrays, e.g. a vector field with components x,y,z stored as three arrays of floats, then use function F5Lwrites().
Todo
Implement, and add consistency check of sustained dataspace properties across multiple fields per representation.
Returns
error code telling the success of the write:

Definition at line 467 of file F5F.c.

471{
472 return F5Fwrite_flexible( fpath, fieldname, rank, dims, fieldtype, memtype, dataPtr, property_id, 1 );
473}
F5ErrorCode F5Fwrite_flexible(F5Path *fpath, const char *fieldname, int rank, hsize_t *dims, hid_t fieldtype, hid_t memtype, const void *dataPtr, hid_t property_id, int do_check)
Definition F5F.c:389

References F5Fwrite_flexible().

Referenced by F5Fwrite_uniform_cartesian3D(), F5Rcreate_curvilinear_cartesian3D(), F5Rcreate_uniform_sparse2(), F5write_uniform_cartesian3Dv(), and saveF5image().

◆ F5Fwrite_fraction()

F5_API F5ErrorCode F5Fwrite_fraction ( F5Path * fpath,
const char * fieldname,
int rank,
const hsize_t * full_dims,
const hsize_t * fragment_dims,
hid_t fieldtype,
hid_t memtype,
const void * dataPtr,
const hsize_t * datastart,
const hsize_t * start_border,
const hsize_t * end_border,
const char * fraction_name,
hid_t property_id )

Write a dataset which only covers a fraction of the entire representation's domain. Such datasets are called "fragmented".

Parameters
fpathAn F5 Path object that has been created by a F5Rcreate() or related calls from the F5R group. Any previous field ID contained there will be closed and overwritten.
rankThe rank (dimensionality) of the data set. Maximum value 8 is set by HDF5.
full_dimsThe extension of the full (virtual) data set in each dimension, i.e. the size of the entire field when reconstructed from all fragments covering this field.
datastartThe (multidimensional) start index of the saved data set. Also known as the minimum integer coordinates of this fragment in the coarse grid.
fragment_dimsThe number of elements of this fraction.
fraction_nameA string to name this fraction. It may be an arbitrary name, but should be consistently used among all fragmented fields. It may be NULL to use an internal default (this feauture is not implemented yet, so please DO specify a valid name here).
property_idAn HDF5 dataset property ID. If it is negative, then a default property will be created locally via H5Pcreate(H5P_DATASET_CREATE).
start_borderThe number of overlapping elements at the lower border (also known as ghost zones). It may be NULL if the fragments do no overlap.
end_borderThe number of overlapping elements at the upper border (also known as ghost zones). It may be NULL if the fragments do no overlap.
fieldtypeThe data type of the field as it should appear in the file.
memtypeThe data type of the field as it exists in memory. It may be negative if it is identical to the field type. For instance, if an array of doubles should be written into a file in single precision, specify fieldtype=H5T_NATIVE_DOUBLE and memtype=H5T_NATIVE_FLOAT .
Note
Subsampling can not be specified here. Subsampled data need to go into another Topology group.
Returns
An error code telling why the function failed.

Definition at line 778 of file F5F.c.

784{
785hid_t field_id;
786int i;
787hsize_t full_dims[FIBER_MAX_RANK], start_dims[FIBER_MAX_RANK], ldims[FIBER_MAX_RANK],
788 sborder[FIBER_MAX_RANK], eborder[FIBER_MAX_RANK];
789
790 if (!fpath)
792
793 if (!fieldname)
794 {
795 F5printf(0, "F5Fwrite_fraction() invalid field name!");
797 }
798 if (!datastart)
799 {
800 F5printf(0, "F5Fwrite_fraction() for field %s has no datastart given for fragment %s",
801 fieldname, fraction_name);
803 }
804 if (!fraction_dims)
805 {
806 F5printf(0, "F5Fwrite_fraction() for field %s has no fragment dimensions given for fragment %s",
807 fieldname, fraction_name);
809 }
810
811 F5print_dimensions(20, "F5Fwrite_fraction", rank, fraction_dims);
812
814 F5Tpermute_dimensions(fpath, rank, full_dims , Dims );
815 F5Tpermute_dimensions(fpath, rank, start_dims, datastart );
816 F5Tpermute_dimensions(fpath, rank, ldims , fraction_dims);
817 F5Tpermute_dimensions(fpath, rank, sborder , start_border );
818 F5Tpermute_dimensions(fpath, rank, eborder , end_border );
820
821 if (Dims) for(i=0; i<rank; i++)
822 {
823 if (datastart[i] >= Dims[i])
824 {
825 F5printf(-1, "F5Fwrite_fraction(%s): fragment starts beyond dataspace in dimension %d: %d (max %d allowed)!",
826 fieldname, i, (int)datastart[i], (int)Dims[i] );
828 }
829 if (datastart[i]+fraction_dims[i] > Dims[i])
830 {
831 F5printf(-1, "F5Fwrite_fraction(%s): fragment extends beyond dataspace in dimension %d: %d (max %d allowed)!",
832 fieldname, i, (int)(datastart[i]+fraction_dims[i]), (int)Dims[i] );
834 }
835 }
836 //
837 // closing the field in the FPath here
838 // because it will be overwritten with a new field ID soon
839 //
840 F5Fclose( fpath );
841
842#ifdef DO_DATASPACE_CONSISTENCY_CHECK
843 if (Dims)
844 {
845 if (!F5LTset_dataspace(fpath, rank, full_dims))
846 {
847 F5printf(-1, "F5Fwrite_fraction(%s): cannot create, inconsistent dataspace!", fieldname);
848 return F5_SUCCESS; /* ??? */
849 }
850 }
851#endif
852
853#if 0
854 hm, we better drop this idea of automatically writing a contiguous field
855 if a field covers the full dimension, because then the topology is
856 no longer expandable...
857
858 if (F5B_identical_dims(rank, full_dims, ldims) && F5B_identical_dims(rank, start_dims, 0) )
859 {
860 fpath->Field_hid = F5Lwrite(fpath->Representation_hid, fieldname,
861 rank, full_dims,
862 F5file_type(fpath, fieldtype), memtype, dataPtr,
863 F5LTmake_enum_type(fpath), property_id);
864
865 F5Tset_field_enum(fpath->Field_hid, F5LTmake_enum_type(fpath), Contigous);
866 F5I_add_field(fpath, fieldname, FIBER_HDF5_REGULAR_FIELD);
867
868 F5printf(30, "~F5Fwrite_fraction(%s) wrote contigous field", fieldname);
869 return F5_SUCCESS;
870 }
871#endif
872 field_id = F5Lwrite_fraction(fpath->Representation_hid, fieldname, rank, Dims ? full_dims : NULL, ldims,
873 F5file_type(fpath, fieldtype), memtype, dataPtr,
874 start_dims,
875 start_border?sborder:NULL, end_border?eborder:NULL,
876 fraction_name, F5LTmake_enum_type(fpath), property_id);
877
878 if (field_id<=0)
879 {
880 F5printf(0, "F5Fwrite_fraction(%s) error in writing field, illegal ID returned from low-level function.", fieldname);
882 }
883 assert( field_id );
884
885 fpath->Field_hid = field_id;
886
887 assert( fpath->Field_hid );
888
889#if 1
890/*
891 there must be a reason why the type attribute writing was not enabled, but forgot why...
892 It should be set because type identification should be faster on reading as no iteration
893 over the group is required then.
894 WB 2.SEP.16 */
895
896/* F5printf(10,"~F5Fwrite_fraction(%s) temporarily set type attribute...", fieldname); */
897 F5Dset_type_attribute(fpath->Field_hid, F5file_type(fpath, fieldtype) );
898#endif
899
901
902 assert( fpath->Field_hid );
903 F5I_add_field(fpath, fieldname);
904
905 F5printf(30, "~F5Fwrite_fraction(%s) wrote fragmented contigous field", fieldname);
906 return F5_SUCCESS;
907}
@ F5ERROR_INVALID_FIELDNAME
Definition F5F.h:242
@ F5ERROR_INVALID_PARAMETERS
Definition F5F.h:251
int F5Dset_type_attribute(hid_t F_id, hid_t fieldtype)
Definition F5L.c:1052
@ FragmentedContiguous
Definition F5defs.h:272
void F5print_dimensions(int verbosity, const char *prefix, int rank, const hsize_t dims[])
Definition F5private.c:394
hid_t F5Lwrite(hid_t R_id, const char *fieldname, int dimension, const hsize_t *dims, hid_t fieldtype, hid_t memtype, const void *dataPtr, hid_t enum_type, hid_t dcpl_id)
Definition F5L.c:357
hid_t F5Lwrite_fraction(hid_t R_id, const char *fieldname, int rank, const hsize_t *full_dims, const hsize_t *datasize, hid_t fieldtype, hid_t memtype, const void *dataPtr, const hsize_t *datastart, const hsize_t *start_border, const hsize_t *end_border, const char *fraction_name, hid_t enum_type, hid_t property_id)
Definition F5L.c:631

References F5_SUCCESS, F5Dset_type_attribute(), F5ERROR_INVALID_FIELDNAME, F5ERROR_INVALID_FPATH, F5ERROR_INVALID_FRAGMENT_END, F5ERROR_INVALID_FRAGMENT_START, F5ERROR_INVALID_PARAMETERS, F5ERROR_NONSPECIFIED, F5Fclose(), F5file_type(), F5I_add_field(), F5LTmake_enum_type(), F5LTset_dataspace(), F5Lwrite(), F5Lwrite_fraction(), F5print_dimensions(), F5printf, F5printf_indent, F5Tpermute_dimensions(), F5Tset_field_enum(), FIBER_MAX_RANK, F5Path::Field_hid, FragmentedContiguous, and F5Path::Representation_hid.

◆ F5Fwrite_fractionS()

F5_API F5ErrorCode F5Fwrite_fractionS ( F5Path * fpath,
const char * fieldname,
int rank,
const hsize_t * full_dims,
const hsize_t * fragment_dims,
hid_t fieldtype,
hid_t memtype,
const void * dataPtr,
const hsize_t * datastart,
const hsize_t * start_border,
const hsize_t * end_border,
const char * fraction_name,
hid_t property_id )

Write a dataset given as a compound as separate components, changing the in-memory data layout.

Definition at line 913 of file F5F.c.

919{
920hid_t field_id;
921int i;
922hsize_t full_dims[FIBER_MAX_RANK], start_dims[FIBER_MAX_RANK], ldims[FIBER_MAX_RANK],
923 sborder[FIBER_MAX_RANK], eborder[FIBER_MAX_RANK];
924
925 if (!fpath)
927
928 F5print_dimensions(20, "F5Fwrite_fractionS", rank, fraction_dims);
929
931 F5Tpermute_dimensions(fpath, rank, full_dims , Dims );
932 F5Tpermute_dimensions(fpath, rank, start_dims, datastart );
933 F5Tpermute_dimensions(fpath, rank, ldims , fraction_dims);
934 F5Tpermute_dimensions(fpath, rank, sborder , start_border );
935 F5Tpermute_dimensions(fpath, rank, eborder , end_border );
937
938 if (Dims) for(i=0; i<rank; i++)
939 {
940 if (datastart[i] >= Dims[i])
941 {
942 F5printf(-1, "F5Fwrite_fractionS(%s): fragment starts beyond dataspace in dimension %d: %d (max %d allowed)!",
943 fieldname, i, (int)datastart[i], (int)Dims[i] );
945 }
946 if (datastart[i]+fraction_dims[i] > Dims[i])
947 {
948 F5printf(-1, "F5Fwrite_fractionS(%s): fragment extends beyond dataspace in dimension %d: %d (max %d allowed)!",
949 fieldname, i, (int)(datastart[i]+fraction_dims[i]), (int)Dims[i] );
951 }
952 }
953 //
954 // closing the field in the FPath here
955 // because it will be overwritten with a new field ID soon
956 //
957 F5Fclose( fpath );
958
959#ifdef DO_DATASPACE_CONSISTENCY_CHECK
960 if (Dims)
961 {
962 if (!F5LTset_dataspace(fpath, rank, full_dims))
963 {
964 F5printf(-1, "F5Fwrite_fractionS(%s): cannot create, inconsistent dataspace!", fieldname);
965 return F5_SUCCESS; /* ??? */
966 }
967 }
968#endif
969
970 field_id = F5Lwrite_fractionS(fpath->Representation_hid, fieldname, rank, Dims ? full_dims : NULL, ldims,
971 F5file_type(fpath, fieldtype), memtype, dataPtr,
972 start_dims,
973 start_border?sborder:NULL, end_border?eborder:NULL,
974 fraction_name, F5LTmake_enum_type(fpath), property_id);
975
976 if (field_id<=0)
977 {
979 }
980
981 fpath->Field_hid = field_id;
982
983 F5printf(10,"~F5Fwrite_fractionS(%s) temporarily set type attribute...", fieldname);
984 F5Dset_type_attribute(fpath->Field_hid, F5file_type(fpath, fieldtype) );
985
987
988 F5I_add_field(fpath, fieldname);
989
990 F5printf(30, "~F5Fwrite_fraction(%s) wrote fragmented contigous field", fieldname);
991 return F5_SUCCESS;
992}
hid_t F5Lwrite_fractionS(hid_t R_id, const char *fieldname, int rank, const hsize_t *full_dims, const hsize_t *datasize, hid_t fieldtype, hid_t memtype, const void *dataPtr, const hsize_t *datastart, const hsize_t *start_border, const hsize_t *end_border, const char *fraction_name, hid_t enum_type, hid_t property_id)
Definition F5L.c:691

References F5_SUCCESS, F5Dset_type_attribute(), F5ERROR_INVALID_FPATH, F5ERROR_INVALID_FRAGMENT_END, F5ERROR_INVALID_FRAGMENT_START, F5ERROR_NONSPECIFIED, F5Fclose(), F5file_type(), F5I_add_field(), F5LTmake_enum_type(), F5LTset_dataspace(), F5Lwrite_fractionS(), F5print_dimensions(), F5printf, F5printf_indent, F5Tpermute_dimensions(), F5Tset_field_enum(), FIBER_MAX_RANK, F5Path::Field_hid, FragmentedSeparatedCompound, and F5Path::Representation_hid.

◆ F5Fwrite_linear()

F5_API int F5Fwrite_linear ( F5Path * fpath,
const char * fieldname,
int rank,
hsize_t * dims,
hid_t fieldtype,
const void * base,
const void * delta )

Write a field which is a linear mapping of a base and delta value.

Parameters
fpathAn F5Path object referring to the location where the field shall be created. It must contain a valid Representation_hid. Its Field_hid will contain a reference to the newly created Field on return. If the F5Path object already contained a valid Field_hid, then this one will be closed by this call.
rankThe rank (dimensionality) of the data set.
dimsThe extension of the data set.
fieldtypeThe type of the field, being compatible to base and delta.
Returns
zero, if the entry could not be opened, non-zero if successful.
Todo
Make this function compatible with F5FwriteX instead. Need to revise this function such that base and delta may be different types, for instance a point and a tangential vector. Possibly provide an alternative function where the min/max is specified instead.

Definition at line 1464 of file F5F.c.

1467{
1468hid_t field_id;
1469hsize_t save_dims[FIBER_MAX_RANK];
1470
1471 F5printf(40,"F5Fwrite_linear(%s): rank=%d, dims=%dx%dx%dx%d)", fieldname, rank,
1472 rank>0?(int)dims[0]:1, rank>1?(int)dims[1]:1, rank>2?(int)dims[2]:1, rank>3?(int)dims[3]:1 );
1473
1475 F5Tpermute_dimensions(fpath, rank, save_dims, dims );
1477
1478 F5Fclose( fpath );
1479
1480 F5printf(41,"F5Fwrite_linear(%s): permuted dims: rank=%d, dims=%dx%dx%dx%d)", fieldname, rank,
1481 rank>0?(int)save_dims[0]:1, rank>1?(int)save_dims[1]:1, rank>2?(int)save_dims[2]:1, rank>3?(int)save_dims[3]:1 );
1482
1483 if (!F5LTset_dataspace(fpath, rank, save_dims))
1484 {
1485 F5printf(-1, "F5Fwrite_linear(%s): cannot create, inconsistent dataspace!", fieldname);
1486 return 0;
1487 }
1488
1489 field_id = F5Lwrite_linear(fpath->Representation_hid, fieldname,
1490 rank, save_dims,
1491 F5file_type(fpath, fieldtype),
1492 base, delta);
1493
1494 if (field_id<0) return 0; /* already exists? */
1495
1496 {
1497 int rank = H5Tget_nmembers( fieldtype );
1498
1500 }
1501
1502 fpath->Field_hid = field_id;
1503
1505
1506 F5I_add_field(fpath, fieldname);
1507
1508 F5printf(40, "~F5Fwrite_linear()");
1509 return 1;
1510}
#define FIBER_UNIFORMARRAY_ELEMENTS_ATTRIBUTE
Definition F5defs.h:157
@ UniformSampling
Definition F5defs.h:276
int F5LAsave_dimensions(hid_t Field_id, const char *aname, int rank, const hsize_t *dims)
Definition F5A.c:192
hid_t F5Lwrite_linear(hid_t R_id, const char *fieldname, int dimension, const hsize_t *dims, hid_t fieldtype, const void *base, const void *delta)
Definition F5L.c:852

References F5_API, F5Fclose(), F5file_type(), F5I_add_field(), F5LAsave_dimensions(), F5LTmake_enum_type(), F5LTset_dataspace(), F5Lwrite_linear(), F5printf, F5printf_indent, F5Tpermute_dimensions(), F5Tset_field_enum(), FIBER_MAX_RANK, FIBER_UNIFORMARRAY_ELEMENTS_ATTRIBUTE, F5Path::Field_hid, F5Path::Representation_hid, and UniformSampling.

Referenced by F5Rcreate_rectilinear(), F5Rcreate_uniform_cartesian3D(), F5Rcreate_uniform_cartesian3Dbbox(), F5Rcreate_uniformd(), F5Rcreate_uniformf(), and saveF5image().

◆ F5Fwrite_linear_fraction()

F5_API int F5Fwrite_linear_fraction ( F5Path * fpath,
const char * fieldname,
int rank,
const hsize_t * full_dims,
const hsize_t * fragment_dims,
hid_t fieldtype,
const void * base,
const void * delta,
const hsize_t * datastart,
const char * fraction_name )

Write a dataset given as small "linear mappings" which only covers a fraction of the entire representation's domain. Useful to specify local bounding boxes.

Parameters
dimensionThe dimension of the data set.
full_dimsThe extension of the full (virtual) data set in each dimension, i.e. the size of the entire field when reconstructed from all fragments covering this field.
datastartThe (multidimensional) start index of the saved data set.
fragment_dimsThe number of elements of this fraction.
fraction_nameAn optional string to name this fraction. It may be NULL to use an internal default.
Note
Subsampling can not be specified here. Subsampled data need to go into another Topology group.
Returns
true
See also
F5Fwrite_linear_fraction_overlap()

Definition at line 1416 of file F5F.c.

1422{
1423hid_t F_id = F5Gappend(fpath->Representation_hid, fieldname);
1424hid_t B_id;
1425hsize_t ldims[FIBER_MAX_RANK];
1426hsize_t offset[FIBER_MAX_RANK];
1427//int i;
1428const char*fragment_name = fraction_name?fraction_name:F5Fblockname(rank, datastart);
1429 F5Fclose( fpath );
1430
1431 F5printf(8, "F5Fwrite_linear_fraction(%s)\n", fieldname);
1432
1433 F5Tpermute_dimensions(fpath, rank, ldims, local_dims );
1434 F5Tpermute_dimensions(fpath, rank, offset, datastart );
1435
1436 B_id = F5Lwrite_linear(F_id, fragment_name, rank, ldims,
1437 F5file_type(fpath, fieldtype),
1438 base, delta);
1439
1440 if (B_id<=0)
1441 return 0;
1442
1444
1445 if (full_dims)
1446 F5Lset_space(F_id, rank, full_dims);
1447
1449
1450 F5Xclose(B_id);
1451
1452 fpath->Field_hid = F_id;
1453
1455
1456 F5I_add_field(fpath, fieldname);
1457
1458 F5printf(9, "~F5Fwrite_linear_fraction(%s)\n", fieldname);
1459 return 1;
1460}
@ FragmentedUniformSampling
Definition F5defs.h:277
#define FIBER_FRAGMENT_OFFSET_ATTRIBUTE
Definition F5defs.h:174
int F5Lset_space(hid_t Field_id, int rank, const hsize_t *dims)
Definition F5L.c:292
herr_t F5Xclose(hid_t obj_id)
Definition F5X.c:347
hid_t F5Gappend(hid_t loc_id, const char *name)
Definition F5X.c:59

References F5Fclose(), F5file_type(), F5Gappend(), F5I_add_field(), F5LAsave_dimensions(), F5Lset_space(), F5LTmake_enum_type(), F5Lwrite_linear(), F5printf, F5Tpermute_dimensions(), F5Tset_field_enum(), F5Xclose(), FIBER_FRAGMENT_OFFSET_ATTRIBUTE, FIBER_MAX_RANK, F5Path::Field_hid, FragmentedUniformSampling, F5Path::Representation_hid, and UniformSampling.

◆ F5FwriteHyperDimensional()

F5_API F5ErrorCode F5FwriteHyperDimensional ( F5Path * fpath,
const char * fieldname,
int rank,
hsize_t * dims,
hid_t fieldtype,
hid_t memtype,
const void * dataPtr,
hid_t property_id )

Write some data as a contiguous field under the given F5Path location with the given name where the data dimensions are higher than the underlying skeleton. This functionality is useful to store data where the higher dimensions express constant, but unknown, number of data elements per point in the base space.

Definition at line 476 of file F5F.c.

480{
481// TODO: Implement consistency check on the base space dimensions!
482
483 return F5Fwrite_flexible( fpath, fieldname, rank, dims, fieldtype, memtype, dataPtr, property_id, 0 );
484}

References F5Fwrite_flexible().

◆ F5FwriteIMAGE()

F5_API F5ErrorCode F5FwriteIMAGE ( F5Path * fpath,
const char * fieldname,
int dimension,
hsize_t * dims,
hid_t fieldtype,
hid_t memtype,
const void * dataPtr,
hid_t property_id )

Save a dataset according to the specifications in https://support.hdfgroup.org/HDF5/doc/ADGuide/ImageSpec.html Only rank 2 dimensions are allowed here. All other arguments will lead to an error. Note that this specification is quite inconsistent, as an rgb data set is modeled as a three-dimensional array, not a two-dimensional array of type rgb. Still, we allow this format explicitely here since it is a standard.

Definition at line 487 of file F5F.c.

491{
492hsize_t save_dims[FIBER_MAX_RANK];
493 if (rank!=2)
494 {
495 F5printf(40,"F5FwriteIMAGE(%s, rank=%d, dims=%dx%dx%dx%d) INVALID RANK (must be 2)! \n", fieldname, rank, rank>0?(int)dims[0]:1,
496 rank>1?(int)dims[1]:1,rank>2?(int)dims[2]:1, rank>3?(int)dims[3]:1
497 );
499 }
500
501 F5printf(40,"F5FwriteIMAGE(%s, rank=%d, dims=%dx%dx%dx%d)\n", fieldname, rank, rank>0?(int)dims[0]:1,
502 rank>1?(int)dims[1]:1,rank>2?(int)dims[2]:1, rank>3?(int)dims[3]:1
503 );
504 if (!fpath)
506
507 F5Fclose(fpath);
508
510 F5Tpermute_dimensions(fpath, rank, save_dims, dims );
512
513 F5printf(41,"F5Fwrite(%s): permuted dims: rank=%d, dims=%dx%dx%dx%d)\n", fieldname, rank,
514 rank>0?(int)save_dims[0]:1, rank>1?(int)save_dims[1]:1, rank>2?(int)save_dims[2]:1, rank>3?(int)save_dims[3]:1 );
515
516 if (!F5LTset_dataspace(fpath, rank, save_dims))
517 {
518 F5printf(-1, "F5Fwrite(%s): cannot create, inconsistent dataspace!", fieldname);
520 }
521
522 if (fieldtype == F5T_RGB_REAL)
523 {
524 save_dims[2] = 3;
525 rank = 3;
526 fieldtype = H5T_NATIVE_FLOAT;
527 memtype = H5T_NATIVE_FLOAT;
528 fpath->Field_hid = F5Lwrite(fpath->Representation_hid, fieldname,
529 rank, save_dims,
530 F5file_type(fpath, fieldtype), memtype, dataPtr,
531 F5LTmake_enum_type(fpath),
532 dcpl_id);
533
534 if (fpath->Field_hid<=0)
535 {
536 F5printf(1, "F5Fwrite_IMAGE() - FAILED to append field fragment data.");
537 return -1;
538 }
539
540 /* FROM: http://hdf.ncsa.uiuc.edu/HDF5/doc/ADGuide/ImageSpec.html */
541 F5Asave_string(fpath->Field_hid, "CLASS", "IMAGE");
542 F5Asave_string(fpath->Field_hid, "INTERLACE_MODE", "INTERLACE_PIXEL");
543 F5Asave_string(fpath->Field_hid, "DISPLAY_ORIGIN", "LL");
544 F5Asave_string(fpath->Field_hid, "IMAGE_VERSION", "1.2");
545 F5Asave_string(fpath->Field_hid, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR");
546 F5Asave_string(fpath->Field_hid, "IMAGE_COLORMODEL", "RGB");
547
549 }
550 else if (fieldtype == F5T_RGB)
551 {
552 save_dims[2] = 3;
553 rank = 3;
554 fieldtype = H5T_NATIVE_UCHAR;
555 memtype = H5T_NATIVE_UCHAR;
556 fpath->Field_hid = F5Lwrite(fpath->Representation_hid, fieldname,
557 rank, save_dims,
558 F5file_type(fpath, fieldtype), memtype, dataPtr,
559 F5LTmake_enum_type(fpath),
560 dcpl_id);
561
562 /* FROM: http://www.hdfgroup.org/HDF5/doc/ADGuide/ImageSpec.html */
563#if 0
564 F5Asave_string(fpath->Field_hid, "CLASS", "IMAGE");
565 F5Asave_string(fpath->Field_hid, "INTERLACE_MODE", "INTERLACE_PIXEL");
566 F5Asave_string(fpath->Field_hid, "DISPLAY_ORIGIN", "LL");
567 F5Asave_string(fpath->Field_hid, "IMAGE_VERSION", "1.2");
568 F5Asave_string(fpath->Field_hid, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR");
569 F5Asave_string(fpath->Field_hid, "IMAGE_COLORMODEL", "RGB");
570#else
571 F5Asave_strings(fpath->Field_hid, "CLASS", "IMAGE",1);
572 F5Asave_strings(fpath->Field_hid, "INTERLACE_MODE", "INTERLACE_PIXEL",1);
573 F5Asave_strings(fpath->Field_hid, "DISPLAY_ORIGIN", "LL",1);
574 F5Asave_strings(fpath->Field_hid, "IMAGE_VERSION", "1.2",1);
575 F5Asave_strings(fpath->Field_hid, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR",1);
576 F5Asave_strings(fpath->Field_hid, "IMAGE_COLORMODEL", "RGB",1);
577#endif
578
579/* unsigned char MinMax[] = { 0, 0xFF };
580 F5Asave(fpath->Field_hid, "IMAGE_MINMAXRANGE",
581 H5T_NATIVE_UCHAR, H5T_NATIVE_UCHAR, MinMax, 2);
582*/
583// F5Dset_type_attribute(fpath->Field_hid, F5T_RGB);
584 }
585 else if (fieldtype == H5T_NATIVE_USHORT)
586 {
587 save_dims[2] = 1;
588 rank = 2;
589 fieldtype = H5T_NATIVE_USHORT;
590 memtype = H5T_NATIVE_USHORT;
591 fpath->Field_hid = F5Lwrite(fpath->Representation_hid, fieldname,
592 rank, save_dims,
593 F5file_type(fpath, fieldtype), memtype, dataPtr,
594 F5LTmake_enum_type(fpath),
595 dcpl_id);
596
597 /* FROM: http://www.hdfgroup.org/HDF5/doc/ADGuide/ImageSpec.html */
598#if 0
599 F5Asave_string(fpath->Field_hid, "CLASS", "IMAGE");
600 F5Asave_string(fpath->Field_hid, "INTERLACE_MODE", "INTERLACE_PIXEL");
601 F5Asave_string(fpath->Field_hid, "DISPLAY_ORIGIN", "LL");
602 F5Asave_string(fpath->Field_hid, "IMAGE_VERSION", "1.2");
603 F5Asave_string(fpath->Field_hid, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR");
604 F5Asave_string(fpath->Field_hid, "IMAGE_COLORMODEL", "RGB");
605#else
606 F5Asave_strings(fpath->Field_hid, "CLASS", "IMAGE",1);
607 F5Asave_strings(fpath->Field_hid, "DISPLAY_ORIGIN", "LL",1);
608 F5Asave_strings(fpath->Field_hid, "IMAGE_VERSION", "1.2",1);
609 F5Asave_strings(fpath->Field_hid, "IMAGE_SUBCLASS", "IMAGE_GRAYSCALE",1);
610#endif
611 unsigned short MinMax[] = { 0, 0xFFFF };
612 F5Asave(fpath->Field_hid, "IMAGE_MINMAXRANGE",
613 H5T_NATIVE_USHORT, H5T_NATIVE_USHORT, MinMax, 2);
614 }
615 else
616 {
617 fpath->Field_hid = F5Lwrite(fpath->Representation_hid, fieldname,
618 rank, save_dims,
619 F5file_type(fpath, fieldtype), memtype, dataPtr,
620 F5LTmake_enum_type(fpath),
621 dcpl_id);
622 }
623
625 F5I_add_field(fpath, fieldname);
626
627 F5printf(40,"F5Fwrite() ok");
628 return F5_SUCCESS;
629}
int F5Asave_string(hid_t loc_id, const char *name, const char *buf)
Definition F5A.c:45
int F5Asave(hid_t loc_id, const char *name, hid_t file_type_id, hid_t mem_type_id, const void *data, hsize_t n)
Definition F5A.c:529
int F5Asave_strings(hid_t loc_id, const char *name, const char *buf, int HowMany)
Definition F5A.c:79
#define F5T_RGB
Definition F5types.h:37
#define F5T_RGB_REAL
Definition F5types.h:42

References Contiguous, F5_API, F5_SUCCESS, F5Asave(), F5Asave_string(), F5Asave_strings(), F5Dset_type_attribute(), F5ERROR_INCONSISTENT_DATASPACE, F5ERROR_INVALID_FPATH, F5Fclose(), F5file_type(), F5I_add_field(), F5LTmake_enum_type(), F5LTset_dataspace(), F5Lwrite(), F5printf, F5printf_indent, F5T_RGB, F5T_RGB_REAL, F5Tpermute_dimensions(), F5Tset_field_enum(), FIBER_MAX_RANK, F5Path::Field_hid, and F5Path::Representation_hid.

Referenced by F5Fwrite_flexible().

◆ F5FwriteX()

F5_API F5ErrorCode F5FwriteX ( F5Path * fpath,
const char * fieldname,
int rank,
const hsize_t dims[],
hid_t fieldtype,
hid_t memtype,
const void *const dataPtr[],
const int polynom_order[],
const int component_map[],
hid_t property_id )

Write a field which is defined procedurally as a polynomial function of each manifold coordinate index.

Parameters
rankDimensionality of the base manifold
dims[rank]Extension of the base manifold
fieldtypeThe type of the field as it should appear in the file
memtypeThe type of the field as it resides in memory
dataPtr[COMPONENTS]An array of polynom coefficients for each component of fieldtype
polynom_order[COMPONENTS]The order of each component's polynom
component_map[rank]Mapping from manifold index to component

Definition at line 1312 of file F5F.c.

1318{
1319hid_t field_id;
1320hsize_t full_dims[FIBER_MAX_RANK];
1321
1322 F5printf(40, "F5FwriteX()");
1323 F5Tpermute_dimensions(fpath, rank, full_dims , dims );
1324
1325 if (!F5LTset_dataspace(fpath, rank, full_dims))
1326 {
1327 F5printf(-1, "F5FSwriteX(%s): cannot create, inconsistent dataspace!", fieldname);
1329 }
1330
1331 field_id = F5LwriteX(fpath->Representation_hid, fieldname,
1332 rank, dims,
1333 F5file_type(fpath, fieldtype), memtype,
1334 dataPtr, polynom_order,
1335 component_map,
1336 property_id,
1337 fpath->GlobalChart_hid);
1338
1339 if (field_id<0)
1340 {
1341 F5printf(-1, "F5FSwriteX(%s): cannot create direct product field!",
1342 fieldname);
1343
1344 if (field_id == -2) return F5ERROR_COMPOUND_EXPECTED;
1345 if (field_id == -3) return F5ERROR_COMPONENTMAP_EXPECTED;
1346 if (field_id == -4) return F5ERROR_COMPONENTMAP_INVALID;
1347
1349 }
1350
1351 F5Fclose( fpath );
1352 fpath->Field_hid = field_id;
1353
1354/*
1355 F5printf(10,"~F5FSwrite_fraction(%s) temporarily set type attribute...", fieldname);
1356 F5Dset_type_attribute(fpath->Field_hid, F5file_type(fpath, fieldtype) );
1357*/
1358
1360
1361 F5I_add_field(fpath, fieldname);
1362
1363 F5printf(9, "F5FSwriteX(%s) writing direct product\n", fieldname);
1364 return F5_SUCCESS;
1365}
hid_t F5LwriteX(hid_t R_id, const char *fieldname, int rank, const hsize_t *dims, hid_t fieldtype, hid_t memtype, const void *const *dataPtr, const int *polynom_order, const int component_map[], hid_t property_id, hid_t ProcIDLocation)
Definition F5L.c:1202
@ DirectProduct
Definition F5defs.h:274
hid_t GlobalChart_hid
Definition F5Path.h:54

References DirectProduct, F5_SUCCESS, F5ERROR_ALREADY_EXISTS, F5ERROR_COMPONENTMAP_EXPECTED, F5ERROR_COMPONENTMAP_INVALID, F5ERROR_COMPOUND_EXPECTED, F5ERROR_INCONSISTENT_DATASPACE, F5Fclose(), F5file_type(), F5I_add_field(), F5LTmake_enum_type(), F5LTset_dataspace(), F5LwriteX(), F5printf, F5Tpermute_dimensions(), F5Tset_field_enum(), FIBER_MAX_RANK, F5Path::Field_hid, F5Path::GlobalChart_hid, and F5Path::Representation_hid.

◆ F5Tget_space()

F5_API hid_t F5Tget_space ( F5Path * f)

Get the data space of an field, given an F5 path.

Returns
An HDF5 dataspace, caller must call H5Sclose().

Definition at line 167 of file F5F.c.

168{
169hsize_t dims[FIBER_MAX_RANK];
170int rank;
171
172 F5printf(40, "F5Tget_space()");
173
174 if (!f) return -1;
175 if (f->Topology_hid<0) return -1;
176
179 dims);
180
181 /* NOTE: This code could go into versioning-specific execution, i.e.
182 do only if the version is 0.0.0
183 */
184#ifdef F5_BACKWARD_COMPATIBILITY
185 if (rank<0 && f->Field_hid>0)
186 {
187 F5printf(40, "F5Tget_space(): F5LAget_dimensions() attribute "FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE
188 " not found on enveloping Topology, inspecting dataset.");
190 }
191 if (rank<0 && f->Field_hid>0)
192 {
193 F5printf(40, "F5Tget_space(): F5LAget_dimensions() attribute "FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE
194 " not found on data set, trying old `Size' attribute\n");
195 rank = F5LAget_dimensions(f->Field_hid, "Size", dims);
196 }
197#endif
198 if (rank<0 && f->Field_hid>0 && !F5Fis_group(f) )
199 {
200 F5printf(40, "F5Tget_space(): no data dims attribute found, returning field's data space...\n" );
201 return H5Dget_space(f->Field_hid);
202 }
203 if (rank<0)
204 {
205 F5printf(40, "F5Tget_space(): rank could not be determined...\n");
206 return -1;
207 }
208
209 F5printf(40, "F5Tget_space(): F5LAget_dimensions() reported rank %d\n", rank);
210 {
211 int i;
212 for(i=0; i<rank; i++)
213 {
214 if (dims[i] == 0)
215 {
216 F5printf(40, "F5Tget_space(): No topology associated...\n");
217 return -1;
218 }
219 }
220 }
221
222 return H5Screate_simple(rank, dims, dims );
223}
#define FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE
Definition F5defs.h:153
int F5LAget_dimensions(hid_t Field_id, const char *aname, hsize_t dims[FIBER_MAX_RANK])
Definition F5A.c:233
hid_t Topology_hid
Definition F5Path.h:57

References F5Fis_group(), F5LAget_dimensions(), F5printf, FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE, FIBER_MAX_RANK, F5Path::Field_hid, and F5Path::Topology_hid.

Referenced by F5Tget_extent().