FiberBundleHDF5  FiberHDF5 Documentation, Revision 2026
High-Performance Fiber Bundle Data Model for Scientific Visualization
Loading...
Searching...
No Matches
F5Fmeta.h File Reference
#include "F5L.h"
#include "F5Bchart.h"
#include "F5Path.h"

Go to the source code of this file.

Functions

F5_API int F5Fopen_group_or_dataset (F5Path *f, const char *name, hid_t *gid, hid_t *did)
F5_API int F5Fopen_or_create_group_or_dataset_attribute (F5Path *f, const char *attribute_name, hid_t gid, hid_t did, hsize_t N, hid_t type_id, int force, hid_t *space_id, hid_t *attr_id)
 F5_DEPRECATED ("Function does not provide benefits over raw HDF5 call", F5_API int F5Fread_attr_data(void *data, hsize_t N, hid_t type_id, hid_t attr_id, const char *attribute_name))
 F5_DEPRECATED ("Function does not provide benefits over raw HDF5 call", F5_API int F5Fwrite_attr_data(const void *data, hsize_t N, hid_t type_id, hid_t attr_id, const char *attribute_name))
F5_API int F5Fget_attribute (F5Path *f, const char *attribute_name, void *data, hsize_t N, hid_t mem_type_id)
F5_API int F5Fset_attribute (F5Path *f, const char *attribute_name, const void *data, hsize_t N, hid_t mem_type_id, int force)
F5_API int F5Fget_fragment_attribute (F5Path *f, const char *fragment_name, const char *attribute_name, void *data, hsize_t N, hid_t mem_type_id)
F5_API int F5Fset_fragment_attribute (F5Path *f, const char *fragment_name, const char *attribute_name, const void *data, hsize_t N, hid_t mem_type_id, int force)
F5_API int F5Fset_string_attribute (F5Path *f, const char *fragment_name, const char *attribute_name, const char *text, int force)
F5_API int F5Fget_string_attribute (F5Path *f, const char *fragment_name, const char *attribute_name, char **text)
F5_API int F5Fhas_attribute (F5Path *f, const char *attr_name)
F5_API hssize_t F5Fget_attribute_nr_elements (F5Path *f, const char *fragment_name, const char *attribute_name)
F5_API int F5Fhas_fragment_attribute (F5Path *f, const char *fragment_name, const char *attribute_name)
F5_API int F5Fis_attribute_of_type (F5Path *f, const char *attribute_name, hid_t HDF5_type)
F5_API int F5Fis_fragment_attribute_of_type (F5Path *f, const char *attribute_name, const char *fragment_name, hid_t HDF5_type)
F5_API int F5Fis_range_of_type (F5Path *f, const char *fragment_name, hid_t HDF5_type)
F5_API int F5Fget_fragment_range_ghost (F5Path *f, const char *fragment_name, void *minmax, void *minmax_ghost, hid_t mem_type_id)
F5_API int F5Fget_fragment_range_ghost2 (F5Path *f, const char *fragment_name, void *minmax_ghost)
F5_API int F5Fset_fragment_range_ghost2 (F5Path *f, const char *fragment_name, const void *minmax, const void *minmax_ghost, unsigned force)
F5_API int F5Fset_fragment_range_ghost (F5Path *f, const char *fragment_name, const void *minmax, const void *minmax_ghost)
F5_API int F5Fget_fragment_ghost_size (F5Path *f, const char *fragment_name, unsigned long *size_real, unsigned long *size_ghost)
F5_API int F5Fset_fragment_ghost_size (F5Path *f, const char *fragment_name, unsigned long size_real, unsigned long size_ghost, int force)
F5_API int F5Fget_average (F5Path *f, const char *fragment_name, void *avg)
F5_API int F5Fset_average2 (F5Path *f, const char *fragment_name, const void *avg, int force)
F5_API int F5Fset_average (F5Path *f, const char *fragment_name, const void *avg)
F5_API int F5Fget_deviation (F5Path *f, const char *fragment_name, void *dev)
F5_API int F5Fset_deviation2 (F5Path *f, const char *fragment_name, const void *dev, int force)
F5_API int F5Fset_deviation (F5Path *f, const char *fragment_name, const void *dev)
F5_API int F5Fget_histogram (F5Path *f, const char *fragment_name, unsigned long *histogram, hsize_t size)
F5_API int F5Fset_histogram2 (F5Path *f, const char *fragment_name, const unsigned long *his, hsize_t size, int force)
F5_API int F5Fset_histogram (F5Path *f, const char *fragment_name, const unsigned long *his, hsize_t size)
F5_API int F5Fset_original_type2 (F5Path *f, const char *fragment_name, int force)
F5_API int F5Fset_dictionary2 (F5Path *f, const char *fragment_name, const char *dictionary, const F5_uint16_t *words, int word_count, int force)
F5_API int F5Fset_dictionary (F5Path *f, const char *fragment_name, const char *dictionary, const F5_uint16_t *words, int word_count, int force)
F5_API int F5Fget_dictionary (F5Path *f, const char *fragment_name, char **dictionary, F5_uint16_t *words, int word_count)
F5_API int F5Fset_metric_unit_description (F5Path *f, const char *unit)

Function Documentation

◆ F5_DEPRECATED() [1/2]

F5_DEPRECATED ( "Function does not provide benefits over raw HDF5 call" ,
F5_API int F5Fread_attr_datavoid *data, hsize_t N, hid_t type_id, hid_t attr_id, const char *attribute_name )

References F5_API.

◆ F5_DEPRECATED() [2/2]

F5_DEPRECATED ( "Function does not provide benefits over raw HDF5 call" ,
F5_API int F5Fwrite_attr_dataconst void *data, hsize_t N, hid_t type_id, hid_t attr_id, const char *attribute_name )

References F5_API.

◆ F5Fget_attribute()

F5_API int F5Fget_attribute ( F5Path * f,
const char * attribute_name,
void * data,
hsize_t N,
hid_t mem_type_id )

Helper function. Retrieve an attribute of 2 values (e.g. 2 float, 2 doubles, 2 ints, 2 F5_vec3_float_t ... ) from a fragment.

Returns
: 1 in case of error, 0 otherwise.

Definition at line 191 of file F5Fmeta.c.

193{
194hid_t attr_id, space_id, type_id;
195
196 if (!f) return 0;
197
198 if( !F5Fopen_group_or_dataset_attribute( f, attribute_name, f->Field_hid, 0, N, &attr_id, &space_id ) )
199 return 0;
200
201 if (mem_type_id)
202 type_id = mem_type_id;
203 else
204 type_id = H5Aget_type(attr_id);
205
206 F5Fread_attr_data( data, N, type_id, attr_id, attribute_name );
207
208 H5Aclose(attr_id);
209 H5Sclose(space_id);
210 if (!mem_type_id)
211 H5Tclose(type_id);
212
213 return 1;
214}
F5_API int F5Fopen_group_or_dataset_attribute(F5Path *f, const char *attribute_name, hid_t gid, hid_t did, hsize_t N, hid_t *attr_id, hid_t *space_id)
Definition F5Fmeta.c:59
F5_API int F5Fread_attr_data(void *data, hsize_t N, hid_t type_id, hid_t attr_id, const char *attribute_name)
Definition F5Fmeta.c:152
H5Tclose(type_id)
hid_t Field_hid
Definition F5Path.h:59

References F5_API, F5Fopen_group_or_dataset_attribute(), F5Fread_attr_data(), F5Path::Field_hid, and H5Tclose().

Referenced by F5Fget_average(), F5Fget_deviation(), F5Fget_dictionary(), and F5Fget_histogram().

◆ F5Fget_attribute_nr_elements()

F5_API hssize_t F5Fget_attribute_nr_elements ( F5Path * f,
const char * fragment_name,
const char * attribute_name )

Definition at line 667 of file F5Fmeta.c.

668{
669hid_t attr_id;
670hid_t space_id;
671hssize_t nr_elements = 0;
672hid_t did = 0 , gid = 0;
673int check;
674
675 if (!f)
676 {
677 F5printf(50, "F5Fget_attribute_nr_elements, invalid F5Path");
678 return 0;
679 }
680
681 if( fragment_name != NULL )
682 {
683 check = F5Fopen_group_or_dataset( f, fragment_name, &gid, &did );
684
685 if( check == 0 ) return 0;
686
687 hid_t open_id = gid>0?gid:did;
688
689 if( open_id > 0 )
690 {
691 attr_id = F5Aopen_name( open_id, attribute_name);
692 if( attr_id < 0 )
693 {
694 F5printf(1,"F5Fget_attribute_nr_elements could not find attribute %s!", attribute_name);
695 return 0;
696 }
697 space_id = H5Aget_space( attr_id );
698 assert(space_id);
699 nr_elements = H5Sget_simple_extent_npoints( space_id );
700
701 H5Sclose( space_id );
702 H5Aclose( attr_id);
703 }
704
705 if( gid > 0 )
706 H5Gclose( gid );
707
708 if( did > 0 )
709 H5Dclose( gid );
710 }
711 else
712 {
713 attr_id = F5Aopen_name( f->Field_hid, attribute_name);
714 if( attr_id < 0 )
715 {
716 F5printf(1,"F5Fget_attribute_nr_elements could not find attribute %s!", attribute_name);
717 return 0;
718 }
719
720 space_id = H5Aget_space( attr_id );
721 assert(space_id);
722 nr_elements = H5Sget_simple_extent_npoints( space_id );
723
724 H5Sclose( space_id );
725 H5Aclose( attr_id);
726
727 }
728
729 return nr_elements;
730}
F5_API int F5Fopen_group_or_dataset(F5Path *f, const char *name, hid_t *gid, hid_t *did)
Definition F5Fmeta.c:26
#define F5printf(verbosity,...)
Definition F5private.h:60
hid_t F5Aopen_name(hid_t location, const char *name)
Definition F5A.c:34
#define H5Gclose(x)
Definition F5X.h:144

References F5_API, F5Aopen_name(), F5Fopen_group_or_dataset(), F5printf, F5Path::Field_hid, and H5Gclose.

◆ F5Fget_average()

F5_API int F5Fget_average ( F5Path * f,
const char * fragment_name,
void * avg )

Field attribute (optional): The average value of a dataset.

Definition at line 781 of file F5Fmeta.c.

782{
783hid_t type_id;
784int check;
785 type_id = F5Fget_type(f);
786 if( !fragment_name )
787 check = F5Fget_attribute( f, FIBER_FIELD_COMPONENT_AVERAGE, avg, 1, type_id );
788 else
789 check = F5Fget_fragment_attribute( f, fragment_name, FIBER_FIELD_COMPONENT_AVERAGE, avg, 1, type_id );
790 H5Tclose(type_id);
791 return check;
792}
hid_t F5Fget_type(F5Path *f)
Definition F5F.c:156
F5_API int F5Fget_fragment_attribute(F5Path *f, const char *fragment_name, const char *attribute_name, void *data, hsize_t N, hid_t mem_type_id)
Definition F5Fmeta.c:267
F5_API int F5Fget_attribute(F5Path *f, const char *attribute_name, void *data, hsize_t N, hid_t mem_type_id)
Definition F5Fmeta.c:191
#define FIBER_FIELD_COMPONENT_AVERAGE
Definition F5defs.h:192

References F5_API, F5Fget_attribute(), F5Fget_fragment_attribute(), F5Fget_type(), FIBER_FIELD_COMPONENT_AVERAGE, and H5Tclose().

◆ F5Fget_deviation()

F5_API int F5Fget_deviation ( F5Path * f,
const char * fragment_name,
void * dev )

Field attribute (optional): The standard deviation of data values from a field's average value.

Definition at line 813 of file F5Fmeta.c.

814{
815hid_t type_id;
816int check;
817 type_id = F5Fget_type(f);
818 if(!fragment_name)
819 check = F5Fget_attribute( f, FIBER_FIELD_COMPONENT_DEVIATION, dev, 1, type_id );
820 else
821 check = F5Fget_fragment_attribute( f, fragment_name, FIBER_FIELD_COMPONENT_DEVIATION, dev, 1, type_id );
822 H5Tclose(type_id);
823 return check;
824}
#define FIBER_FIELD_COMPONENT_DEVIATION
Definition F5defs.h:210

References F5_API, F5Fget_attribute(), F5Fget_fragment_attribute(), F5Fget_type(), FIBER_FIELD_COMPONENT_DEVIATION, and H5Tclose().

◆ F5Fget_dictionary()

F5_API int F5Fget_dictionary ( F5Path * f,
const char * fragment_name,
char ** dictionary,
F5_uint16_t * words,
int word_count )

Dictionary string has to be passed by reference. Dynamic memory is reserved for the dictionary and must be released afterwards. e.g. : char* dict; F5Fget_dictionary(f, NULL, &dict, .. ); free(dictionary)

Definition at line 945 of file F5Fmeta.c.

946{
947int check;
948
949 check = F5Fget_string_attribute( f, fragment_name, FIBER_FIELD_DICTIONARY, dictionary );
950
951 if(!check)
952 {
953 puts("F5Fget_dictionary() error getting FIBER_FIELD_DICTIONARY attribute!");
954 return check;
955 }
956
957 if( !fragment_name )
958 check = F5Fget_attribute( f, FIBER_FIELD_DICTIONARY_WORDS, words, word_count, H5T_NATIVE_USHORT );
959 else
960 check = F5Fget_fragment_attribute( f, fragment_name, FIBER_FIELD_DICTIONARY_WORDS, words, word_count, H5T_NATIVE_USHORT );
961
962 return check;
963}
F5_API int F5Fget_string_attribute(F5Path *f, const char *fragment_name, const char *attribute_name, char **text)
Definition F5Fmeta.c:425
#define FIBER_FIELD_DICTIONARY_WORDS
Definition F5defs.h:222
#define FIBER_FIELD_DICTIONARY
Definition F5defs.h:221

References F5_API, F5Fget_attribute(), F5Fget_fragment_attribute(), F5Fget_string_attribute(), FIBER_FIELD_DICTIONARY, and FIBER_FIELD_DICTIONARY_WORDS.

◆ F5Fget_fragment_attribute()

F5_API int F5Fget_fragment_attribute ( F5Path * f,
const char * fragment_name,
const char * attribute_name,
void * data,
hsize_t N,
hid_t mem_type_id )

Definition at line 267 of file F5Fmeta.c.

269{
270hid_t attr_id,
271 space_id,
272 type_id,
273 gid = -1, did = -1;
274
275 F5Fopen_group_or_dataset( f, fragment_name, &gid, &did );
276
277 if( !F5Fopen_group_or_dataset_attribute(f, attribute_name, gid, did, N, &attr_id, &space_id) )
278 return 0;
279
280 if (mem_type_id)
281 type_id = mem_type_id;
282 else
283 type_id = H5Aget_type(attr_id);
284
285 F5Fread_attr_data( data, N, type_id, attr_id, attribute_name );
286
287 if (gid>0) H5Gclose(gid);
288 if (did>0) H5Dclose(did);
289 H5Aclose(attr_id);
290 H5Sclose(space_id);
291
292 if (!mem_type_id)
293 H5Tclose(type_id);
294
295 F5printf(55,"F5Fget_fragment_attribute() returning normally!");
296
297 return 1;
298}

References F5_API, F5Fopen_group_or_dataset(), F5Fopen_group_or_dataset_attribute(), F5Fread_attr_data(), F5printf, H5Gclose, and H5Tclose().

Referenced by F5Fget_average(), F5Fget_deviation(), F5Fget_dictionary(), F5Fget_fragment_ghost_size(), F5Fget_fragment_range_ghost(), F5Fget_fragment_range_ghost2(), and F5Fget_histogram().

◆ F5Fget_fragment_ghost_size()

F5_API int F5Fget_fragment_ghost_size ( F5Path * f,
const char * fragment_name,
unsigned long * size_real,
unsigned long * size_ghost )

If available a data-array icludes values of a ghost zone and the array is partitioned in two contiguous parts. The first part contains the values inside the fragment and has size size_real, the second part contains the value inside the ghost zone with size size_ghost.

Definition at line 554 of file F5Fmeta.c.

556{
557unsigned long sizes[2];
558int check;
560 sizes, 2, H5T_NATIVE_ULONG );
561
562 *size_real = sizes[0];
563 *size_ghost = sizes[1];
564
565 return check;
566}
#define FIBER_FRAGMENT_ARRAY_SIZE_GHOST_ATTRIBUTE
Definition F5defs.h:168

References F5_API, F5Fget_fragment_attribute(), and FIBER_FRAGMENT_ARRAY_SIZE_GHOST_ATTRIBUTE.

◆ F5Fget_fragment_range_ghost()

F5_API int F5Fget_fragment_range_ghost ( F5Path * f,
const char * fragment_name,
void * minmax,
void * minmax_ghost,
hid_t mem_type_id )

Field attribute (optional): Bounding box including the ghost zone.

Definition at line 533 of file F5Fmeta.c.

534{
535 if( F5Fget_fragment_attribute( f, fragment_name, FIBER_FIELD_COMPONENT_RANGE, minmax, 2 ,mem_type_id) )
536 {
538 minmax_ghost, 2, mem_type_id);
539 }
540 else
541 return 0;
542
543}
#define FIBER_FIELD_COMPONENT_RANGE
Definition F5defs.h:186
#define FIBER_FIELD_COMPONENT_RANGE_GHOST
Definition F5defs.h:187

References F5_API, F5Fget_fragment_attribute(), FIBER_FIELD_COMPONENT_RANGE, and FIBER_FIELD_COMPONENT_RANGE_GHOST.

◆ F5Fget_fragment_range_ghost2()

F5_API int F5Fget_fragment_range_ghost2 ( F5Path * f,
const char * fragment_name,
void * minmax_ghost )

Definition at line 545 of file F5Fmeta.c.

546{
547hid_t type_id;
548 type_id = F5Fget_type(f);
549
551 minmax_ghost, 2, type_id);
552}

References F5_API, F5Fget_fragment_attribute(), F5Fget_type(), and FIBER_FIELD_COMPONENT_RANGE_GHOST.

◆ F5Fget_histogram()

F5_API int F5Fget_histogram ( F5Path * f,
const char * fragment_name,
unsigned long * histogram,
hsize_t size )

Field attribute (optional): The histogram of a scalar field.

Definition at line 846 of file F5Fmeta.c.

847{
848 if( !fragment_name)
849 return F5Fget_attribute( f, FIBER_FIELD_COMPONENT_HISTOGRAM, histogram, size, H5T_NATIVE_ULONG );
850 else
851 return F5Fget_fragment_attribute( f, fragment_name, FIBER_FIELD_COMPONENT_HISTOGRAM, histogram, size, H5T_NATIVE_ULONG );
852}
#define FIBER_FIELD_COMPONENT_HISTOGRAM
Definition F5defs.h:215

References F5_API, F5Fget_attribute(), F5Fget_fragment_attribute(), and FIBER_FIELD_COMPONENT_HISTOGRAM.

◆ F5Fget_string_attribute()

F5_API int F5Fget_string_attribute ( F5Path * f,
const char * fragment_name,
const char * attribute_name,
char ** text )

Definition at line 425 of file F5Fmeta.c.

426{
427hid_t attr_id, space_id;
428
429 if (f->Field_hid > 0)
430 {
431 if( fragment_name != NULL )
432 {
433 H5E_BEGIN_TRY
434 attr_id = H5Aopen( f->Field_hid, attribute_name, H5P_DEFAULT);
435 H5E_END_TRY
436 if (attr_id > 0)
437 {
438 F5printf(50, "F5Fset_string_attribute(): txt attribute %s fount at %d.",
439 attribute_name, (int)f->Field_hid);
440 hid_t type_id;
441 type_id = H5Aget_type( attr_id );
442
443 size_t str_len = H5Tget_size( type_id );
444
445 *text = (char*) calloc( str_len, sizeof(char) );
446
447 H5Aread(attr_id, H5T_STRING, *text );
448
449 H5Tclose( type_id );
450 H5Aclose(attr_id);
451 }
452 else
453 {
454 F5printf(50, "F5Fset_string_attribute(): WARNING Unit Attribute not written to %s/%d.",
455 text, (int)f->Field_hid);
456 }
457
458 return 1;
459 }
460 else
461 {
462 if( F5Fis_group( f ) )
463 {
464 puts("isgroup");
465 if( !F5Fopen_group_or_dataset_attribute( f, attribute_name, f->Field_hid, 0, 1, &attr_id, &space_id ) )
466 return 0;
467 }
468 else
469 {
470 puts("isnogroup");
471 if( !F5Fopen_group_or_dataset_attribute( f, attribute_name, 0, f->Field_hid, 1, &attr_id, &space_id ) )
472 return 0;
473 }
474
475 puts("read attr");
476
477 if (attr_id > 0)
478 {
479
480 F5printf(50, "F5Fset_string_attribute(): txt attribute %s fount at %d.",
481 attribute_name, (int)f->Field_hid);
482 hid_t type_id;
483 type_id = H5Aget_type( attr_id );
484
485 size_t str_len = H5Tget_size( type_id );
486
487// printf("str_len: %d\n", str_len);
488
489 *text = (char*) calloc( str_len, sizeof(char) );
490
491 H5Aread(attr_id, type_id, *text );
492
493 H5Tclose( type_id );
494
495 H5Aclose(attr_id);
496 }
497 else
498 {
499 F5printf(50, "F5Fset_string_attribute(): WARNING Unit Attribute not written to %s/%d.", text, (int)f->Field_hid);
500 }
501
502
503 return 1;
504 }
505
506 }
507 else
508 F5printf(50, "F5Fset_string_attribute(): Invalid field ID.");
509
510 return 0;
511}
int F5Fis_group(const F5Path *fpath)
Definition F5F.c:126

References F5_API, F5Fis_group(), F5Fopen_group_or_dataset_attribute(), F5printf, F5Path::Field_hid, and H5Tclose().

Referenced by F5Fget_dictionary().

◆ F5Fhas_attribute()

F5_API int F5Fhas_attribute ( F5Path * f,
const char * attr_name )

Test whether a field attribute exists or not

Returns
1 if exists, 0 otherwise

Definition at line 646 of file F5Fmeta.c.

647{
648 if (!f)
649 {
650 F5printf(50, "F5Fhas_attribute, invalid F5Path");
651 return 0;
652 }
653
654htri_t exist = H5Aexists(f->Field_hid, attr_name);
655
656 if (exist > 0)
657 return 1;
658 else if (exist < 0)
659 {
660 puts("F5Fhas_attribute, ERROR H5Aexists failed");
661 return 0;
662 }
663 else
664 return exist;
665}

References F5_API, F5printf, and F5Path::Field_hid.

◆ F5Fhas_fragment_attribute()

F5_API int F5Fhas_fragment_attribute ( F5Path * f,
const char * fragment_name,
const char * attribute_name )

Test whether a field fragment attribute exists or not

Returns
1 if exists, 0 otherwise

Definition at line 732 of file F5Fmeta.c.

733{
734 if (!f)
735 {
736 F5printf(50, "F5Fhas_attribute, invalid F5Path");
737 return 0;
738 }
739
740hid_t Gid = -1, Did = -1;
741
742 H5E_BEGIN_TRY
743
744 Gid = H5Gopen2(f->Field_hid, fragment_name, H5P_DEFAULT);
745
746 if (Gid<0)
747 {
748 F5printf(55,"F5Fhas_fragment_attribute() no group, trying for a dataset!");
749 Did = H5Dopen2(f->Field_hid, fragment_name, H5P_DEFAULT);
750 if(Did<0)
751 {
752 F5printf(55,"F5Fhas_fragment_attribute() no dataset found");
753 H5Dclose(Did);
754 H5Gclose(Gid);
755 return 0;
756 }
757 else
758 F5printf(55,"F5Fhas_fragment_attribute() Yay dataset found!");
759 }
760 else
761 F5printf(55,"F5Fhas_fragment_attribute() Yay! found group!");
762
763 H5E_END_TRY
764
765htri_t exist = H5Aexists((Gid>0)?Gid:Did, attr_name);
766
767 if (Did > 0) H5Dclose(Did);
768 if (Gid > 0) H5Gclose(Gid);
769
770 if (exist > 0)
771 return 1;
772 else if (exist < 0)
773 {
774 puts("F5Fhas_attribute, ERROR H5Aexists failed");
775 return 0;
776 }
777 else
778 return exist;
779}

References F5_API, F5printf, F5Path::Field_hid, and H5Gclose.

◆ F5Fis_attribute_of_type()

F5_API int F5Fis_attribute_of_type ( F5Path * f,
const char * attribute_name,
hid_t HDF5_type )

Definition at line 577 of file F5Fmeta.c.

578{
579hid_t attrib = 0;
580
581 if (!f)
582 {
583 F5printf(50, "F5Fis_attribute_of_type, invalid F5Path");
584 return 0;
585 }
586
587hid_t gettype = F5Aget_type(f->Field_hid, attribute_name, &attrib);
588
589 if (H5Tequal(HDF5_type,gettype))
590 {
591 H5Tclose(gettype);
592 H5Aclose(attrib);
593 return 1;
594 }
595
596 H5Tclose(gettype);
597 H5Aclose(attrib);
598
599 return 0;
600}
F5_API hid_t F5Aget_type(hid_t loc_id, const char *name, hid_t *attrib)
Definition F5A.c:167

References F5_API, F5Aget_type(), F5printf, F5Path::Field_hid, and H5Tclose().

Referenced by F5Fis_range_of_type().

◆ F5Fis_fragment_attribute_of_type()

F5_API int F5Fis_fragment_attribute_of_type ( F5Path * f,
const char * attribute_name,
const char * fragment_name,
hid_t HDF5_type )

Definition at line 611 of file F5Fmeta.c.

612{
613hid_t attrib = 0, gid = -1, did = -1;
614
615 if (!f)
616 {
617 F5printf(15, "F5Fis_range_of_type, invalid F5Path");
618 return 0;
619 }
620
621 if( !F5Fopen_group_or_dataset( f, fragment_name, &gid, &did ) )
622 return 0;
623
624 hid_t gettype = F5Aget_type((gid>0)?gid:did, attribute_name, &attrib);
625
626 if (H5Tequal(HDF5_type,gettype))
627 {
628 H5Tclose(gettype);
629 H5Aclose(attrib);
630
631 if (did > 0) H5Dclose(did);
632 if (gid > 0) H5Gclose(gid);
633
634 return 1;
635 }
636
637 H5Tclose(gettype);
638 H5Aclose(attrib);
639
640 if (did > 0) H5Dclose(did);
641 if (gid > 0) H5Gclose(gid);
642
643 return 0;
644}

References F5_API, F5Aget_type(), F5Fopen_group_or_dataset(), F5printf, H5Gclose, and H5Tclose().

Referenced by F5Fis_range_of_type().

◆ F5Fis_range_of_type()

F5_API int F5Fis_range_of_type ( F5Path * f,
const char * fragment_name,
hid_t HDF5_type )

Test if range attribute is of certain type

Returns
1 if matching, 0 otherwise

Definition at line 602 of file F5Fmeta.c.

603{
604 if( !fragment_name )
606 else
607 return F5Fis_fragment_attribute_of_type(f, fragment_name, FIBER_FIELD_COMPONENT_RANGE, HDF5_type );
608
609}
F5_API int F5Fis_fragment_attribute_of_type(F5Path *f, const char *fragment_name, const char *attribute_name, hid_t HDF5_type)
Definition F5Fmeta.c:611
F5_API int F5Fis_attribute_of_type(F5Path *f, const char *attribute_name, hid_t HDF5_type)
Definition F5Fmeta.c:577

References F5_API, F5Fis_attribute_of_type(), F5Fis_fragment_attribute_of_type(), and FIBER_FIELD_COMPONENT_RANGE.

◆ F5Fopen_group_or_dataset()

F5_API int F5Fopen_group_or_dataset ( F5Path * f,
const char * name,
hid_t * gid,
hid_t * did )

Definition at line 26 of file F5Fmeta.c.

27{
28 if (!f) return 0;
29
30H5E_BEGIN_TRY
31 *gid = H5Gopen2(f->Field_hid, name, H5P_DEFAULT);
32 if (*gid<0)
33 {
34 F5printf(55,"F5Fopen_group_or_dataset() no group, trying for a dataset!");
35 *did = H5Dopen2(f->Field_hid, name, H5P_DEFAULT);
36 if(*did<0)
37 {
38 F5printf(55,"F5Fopen_group_or_dataset() no dataset found");
39 return 0;
40 }
41 else
42 F5printf(55,"F5Fopen_group_or_dataset() Yay dataset found!");
43 }
44 else
45 F5printf(55,"F5Fopen_group_or_dataset() Yay! found group!");
46H5E_END_TRY
47
48 return 1;
49}
name
Definition F5P.c:82

References F5_API, F5printf, F5Path::Field_hid, and name.

Referenced by F5Fget_attribute_nr_elements(), F5Fget_fragment_attribute(), F5Fis_fragment_attribute_of_type(), and F5Fset_fragment_attribute().

◆ F5Fopen_or_create_group_or_dataset_attribute()

F5_API int F5Fopen_or_create_group_or_dataset_attribute ( F5Path * f,
const char * attribute_name,
hid_t gid,
hid_t did,
hsize_t N,
hid_t type_id,
int force,
hid_t * space_id,
hid_t * attr_id )

Definition at line 117 of file F5Fmeta.c.

118{
119 if( !f ) return 0;
120
121 H5E_BEGIN_TRY
122 *attr_id = H5Acreate2( gid>0? gid : did,
123 attribute_name, type_id, *space_id,
124 H5P_DEFAULT, H5P_DEFAULT );
125 H5E_END_TRY
126
127 if (*attr_id < 0 && force == 0)
128 {
129 F5printf(55,"F5Fopen_or_create_group_or_dataset_attribute() Could not set %s attribute, might already exist.", attribute_name);
130 H5Sclose(*space_id);
131 H5Tclose(type_id);
132// if (gid>0) H5Gclose(gid);
133// if (did>0) H5Dclose(did);
134 return 0;
135 }
136 else if( *attr_id<0 ) // try for existing attribute
137 {
138 F5printf(1,"F5Fopen_or_create_group_or_dataset_attribute() Could not create attribute.");
139 return F5Fopen_group_or_dataset_attribute( f, attribute_name, gid, did, N, attr_id, space_id );
140 }
141
142 return 1;
143}

References F5_API, F5Fopen_group_or_dataset_attribute(), F5printf, and H5Tclose().

Referenced by F5Fset_attribute(), F5Fset_fragment_attribute(), and F5Fset_string_attribute().

◆ F5Fset_attribute()

F5_API int F5Fset_attribute ( F5Path * f,
const char * attribute_name,
const void * data,
hsize_t N,
hid_t mem_type_id,
int force )

Definition at line 216 of file F5Fmeta.c.

218{
219const hsize_t dims = N;
220hid_t attr_id, type_id, space_id;
221
222 if (!f)
223 {
224 F5printf(5,"F5Fset_attribute() got NULL F5Path, no range written!");
225 return 0;
226 }
227 if (f->Field_hid<1)
228 {
229 F5printf(5,"F5Fset_attribute() F5Path has no field ID, no range written!");
230 return 0;
231 }
232
233 space_id= H5Screate_simple(1, &dims, &dims );
234
235 if (mem_type_id)
236 type_id = mem_type_id;
237 else
238 type_id = H5Aget_type(attr_id); // this code CANNOT work because attr_id has not been initialized!!!
239
240/*
241 This is an extremely complicated workaround due to the wrong design of function F5Fopen_or_create_group_or_dataset_attribute().
242 All what is required here is to use the Field_id in the F5Path object and to write an attribute using this Field_id, regardless
243 what type it is.
244 */
245 if( F5Fis_group( f ) )
246 {
247 if( !F5Fopen_or_create_group_or_dataset_attribute( f, attribute_name, f->Field_hid, 0, N, type_id, force, &space_id, &attr_id ) )
248 return 0;
249 }
250 else
251 {
252 if( !F5Fopen_or_create_group_or_dataset_attribute( f, attribute_name, 0, f->Field_hid, N, type_id, force, &space_id, &attr_id ) )
253 return 0;
254 }
255
256 F5Fwrite_attr_data( data, N, type_id, attr_id, attribute_name );
257
258 H5Aclose(attr_id);
259 H5Sclose(space_id);
260
261 if (!mem_type_id)
262 H5Tclose(type_id);
263
264 return 1;
265}
F5_API int F5Fopen_or_create_group_or_dataset_attribute(F5Path *f, const char *attribute_name, hid_t gid, hid_t did, hsize_t N, hid_t type_id, int force, hid_t *space_id, hid_t *attr_id)
Definition F5Fmeta.c:117
F5_API int F5Fwrite_attr_data(const void *data, hsize_t N, hid_t type_id, hid_t attr_id, const char *attribute_name)
Definition F5Fmeta.c:171

References F5_API, F5Fis_group(), F5Fopen_or_create_group_or_dataset_attribute(), F5Fwrite_attr_data(), F5printf, F5Path::Field_hid, and H5Tclose().

Referenced by F5Fset_average2(), F5Fset_deviation2(), F5Fset_dictionary2(), F5Fset_histogram2(), F5Fset_original_type2(), and F5Rcreate_uniform_sparse2().

◆ F5Fset_average()

F5_API int F5Fset_average ( F5Path * f,
const char * fragment_name,
const void * avg )

Definition at line 808 of file F5Fmeta.c.

809{
810 return F5Fset_average2( f, fragment_name, avg, 0 );
811}
F5_API int F5Fset_average2(F5Path *f, const char *fragment_name, const void *avg, int force)
Definition F5Fmeta.c:794

References F5_API, and F5Fset_average2().

Referenced by F5Rcreate_uniform_cartesian3D(), and F5Rcreate_uniform_cartesian3Dbbox().

◆ F5Fset_average2()

F5_API int F5Fset_average2 ( F5Path * f,
const char * fragment_name,
const void * avg,
int force )

Definition at line 794 of file F5Fmeta.c.

795{
796hid_t type_id;
797int check;
798 type_id = F5Fget_type(f);
799 if(!fragment_name)
800 check = F5Fset_attribute(f, FIBER_FIELD_COMPONENT_AVERAGE, avg, 1, type_id, force);
801 else
802 check = F5Fset_fragment_attribute(f, fragment_name, FIBER_FIELD_COMPONENT_AVERAGE, avg, 1, type_id, force);
803
804 H5Tclose(type_id);
805 return check;
806}
F5_API int F5Fset_fragment_attribute(F5Path *f, const char *fragment_name, const char *attribute_name, const void *data, const hsize_t N, hid_t mem_type_id, int force)
Definition F5Fmeta.c:300
F5_API int F5Fset_attribute(F5Path *f, const char *attribute_name, const void *data, hsize_t N, hid_t mem_type_id, int force)
Definition F5Fmeta.c:216

References F5_API, F5Fget_type(), F5Fset_attribute(), F5Fset_fragment_attribute(), FIBER_FIELD_COMPONENT_AVERAGE, and H5Tclose().

Referenced by F5Fset_average().

◆ F5Fset_deviation()

F5_API int F5Fset_deviation ( F5Path * f,
const char * fragment_name,
const void * dev )

Definition at line 841 of file F5Fmeta.c.

842{
843 return F5Fset_deviation2(f, fragment_name, dev, 0);
844}
F5_API int F5Fset_deviation2(F5Path *f, const char *fragment_name, const void *dev, int force)
Definition F5Fmeta.c:826

References F5_API, and F5Fset_deviation2().

◆ F5Fset_deviation2()

F5_API int F5Fset_deviation2 ( F5Path * f,
const char * fragment_name,
const void * dev,
int force )

Definition at line 826 of file F5Fmeta.c.

827{
828
829hid_t type_id;
830int check;
831 type_id = F5Fget_type(f);
832 if( !fragment_name )
833 check = F5Fset_attribute(f, FIBER_FIELD_COMPONENT_DEVIATION, dev, 1, type_id, force);
834 else
835 check = F5Fset_fragment_attribute(f, fragment_name, FIBER_FIELD_COMPONENT_DEVIATION, dev, 1, type_id, force);
836
837 H5Tclose(type_id);
838 return check;
839}

References F5_API, F5Fget_type(), F5Fset_attribute(), F5Fset_fragment_attribute(), FIBER_FIELD_COMPONENT_DEVIATION, and H5Tclose().

Referenced by F5Fset_deviation().

◆ F5Fset_dictionary()

F5_API int F5Fset_dictionary ( F5Path * f,
const char * fragment_name,
const char * dictionary,
const F5_uint16_t * words,
int word_count,
int force )

Definition at line 940 of file F5Fmeta.c.

941{
942 return F5Fset_dictionary2( f, fragment_name, dictionary, words, word_count, 0 );
943}
F5_API int F5Fset_dictionary2(F5Path *f, const char *fragment_name, const char *dictionary, const F5_uint16_t *words, int word_count, int force)
Definition F5Fmeta.c:915

References F5_API, and F5Fset_dictionary2().

◆ F5Fset_dictionary2()

F5_API int F5Fset_dictionary2 ( F5Path * f,
const char * fragment_name,
const char * dictionary,
const F5_uint16_t * words,
int word_count,
int force )

Field attribute (optional): A dictionary of words and a stored as string attribute, along with a seperator i.e. used for a field containing integer indeces into the dictionary (label-field) The get function does not allocate the string buffers

Definition at line 915 of file F5Fmeta.c.

916{
917int check;
918
919 if( !fragment_name )
920 check = F5Fset_string_attribute(f, NULL, FIBER_FIELD_DICTIONARY, dictionary, 1 );
921 else
922 check = F5Fset_string_attribute(f, fragment_name, FIBER_FIELD_DICTIONARY, dictionary, 1 );
923
924 if(!check)
925 {
926 puts("F5Fset_dictionary2() error setting FIBER_FIELD_DICTIONARY attribute!");
927 return check;
928 }
929
930 if( !fragment_name )
931 check = F5Fset_attribute(f, FIBER_FIELD_DICTIONARY_WORDS, words, word_count,
932 H5T_NATIVE_USHORT, force);
933 else
934 check = F5Fset_fragment_attribute(f, fragment_name, FIBER_FIELD_DICTIONARY_WORDS, words, word_count,
935 H5T_NATIVE_USHORT, force);
936
937 return check;
938}
F5_API int F5Fset_string_attribute(F5Path *f, const char *fragment_name, const char *attribute_name, const char *text, int force)
Definition F5Fmeta.c:350

References F5_API, F5Fset_attribute(), F5Fset_fragment_attribute(), F5Fset_string_attribute(), FIBER_FIELD_DICTIONARY, and FIBER_FIELD_DICTIONARY_WORDS.

Referenced by F5Fset_dictionary().

◆ F5Fset_fragment_attribute()

F5_API int F5Fset_fragment_attribute ( F5Path * f,
const char * fragment_name,
const char * attribute_name,
const void * data,
hsize_t N,
hid_t mem_type_id,
int force )

Definition at line 300 of file F5Fmeta.c.

302{
303const hsize_t dims = N;
304hid_t attr_id,
305 type_id,
306 space_id,
307 gid = -1, did = -1;
308
309 if (!f)
310 {
311 F5printf(5,"F5Fset_fragment_attribute() got NULL F5Path, no range written!");
312 return 0;
313 }
314 if (f->Field_hid<1)
315 {
316 F5printf(5,"F5Fset_fragment_attribute() F5Path has no field ID, no range written!");
317 return 0;
318 }
319
320 space_id= H5Screate_simple(1, &dims, &dims );
321 type_id = mem_type_id;
322
323 if( !F5Fopen_group_or_dataset( f, fragment_name, &gid, &did ) )
324 {
325 F5printf(50,"F5Fset_fragment_attribute() Could not set %s attribute, fragment %s does not exist.",
326 attribute_name, fragment_name);
327 H5Sclose(space_id);
328 H5Tclose(type_id);
329 return 0;
330 }
331
332 if( !F5Fopen_or_create_group_or_dataset_attribute( f, attribute_name, gid, did, N, type_id, force, &space_id, &attr_id ) )
333 return 0;
334
335 F5Fwrite_attr_data( data, N, type_id, attr_id, attribute_name );
336
337 H5Aclose(attr_id);
338 H5Sclose(space_id);
339 if (gid>0) H5Gclose(gid);
340 if (did>0) H5Dclose(did);
341
342 F5printf(55,"F5Fset_fragment_attribute2() returning normally!");
343
344 return 1;
345
346
347 return 1;
348}

References F5_API, F5Fopen_group_or_dataset(), F5Fopen_or_create_group_or_dataset_attribute(), F5Fwrite_attr_data(), F5printf, F5Path::Field_hid, H5Gclose, and H5Tclose().

Referenced by F5Fset_average2(), F5Fset_deviation2(), F5Fset_dictionary2(), F5Fset_fragment_ghost_size(), F5Fset_fragment_range_ghost2(), F5Fset_histogram2(), and F5Fset_original_type2().

◆ F5Fset_fragment_ghost_size()

F5_API int F5Fset_fragment_ghost_size ( F5Path * f,
const char * fragment_name,
unsigned long size_real,
unsigned long size_ghost,
int force )

Definition at line 568 of file F5Fmeta.c.

569{
570unsigned long sizes[2];
571 sizes[0] = size_real;
572 sizes[1] = size_ghost;
574 sizes, 2, H5T_NATIVE_ULONG, force );
575}

References F5_API, F5Fset_fragment_attribute(), and FIBER_FRAGMENT_ARRAY_SIZE_GHOST_ATTRIBUTE.

◆ F5Fset_fragment_range_ghost()

F5_API int F5Fset_fragment_range_ghost ( F5Path * f,
const char * fragment_name,
const void * minmax,
const void * minmax_ghost )

Definition at line 528 of file F5Fmeta.c.

529{
530 return F5Fset_fragment_range_ghost2(f, fragment_name, minmax, minmax_ghost, 0 );
531}
F5_API int F5Fset_fragment_range_ghost2(F5Path *f, const char *fragment_name, const void *minmax, const void *minmax_ghost, unsigned force)
Definition F5Fmeta.c:514

References F5_API, and F5Fset_fragment_range_ghost2().

◆ F5Fset_fragment_range_ghost2()

F5_API int F5Fset_fragment_range_ghost2 ( F5Path * f,
const char * fragment_name,
const void * minmax,
const void * minmax_ghost,
unsigned force )

Definition at line 514 of file F5Fmeta.c.

515{
516hid_t type_id;
517int check;
518 type_id = F5Fget_type(f);
519 check = F5Fset_fragment_attribute(f, fragment_name, FIBER_FIELD_COMPONENT_RANGE, minmax, 2, type_id, force);
520
521 if( check )
522 check = F5Fset_fragment_attribute(f, fragment_name, FIBER_FIELD_COMPONENT_RANGE_GHOST, minmax_ghost, 2, type_id, force);
523
524 H5Tclose(type_id);
525 return check;
526}

References F5_API, F5Fget_type(), F5Fset_fragment_attribute(), FIBER_FIELD_COMPONENT_RANGE, FIBER_FIELD_COMPONENT_RANGE_GHOST, and H5Tclose().

Referenced by F5Fset_fragment_range_ghost().

◆ F5Fset_histogram()

F5_API int F5Fset_histogram ( F5Path * f,
const char * fragment_name,
const unsigned long * his,
hsize_t size )

Definition at line 862 of file F5Fmeta.c.

863{
864 return F5Fset_histogram2(f, fragment_name, his, size, 0);
865}
F5_API int F5Fset_histogram2(F5Path *f, const char *fragment_name, const unsigned long *his, hsize_t size, int force)
Definition F5Fmeta.c:854

References F5_API, and F5Fset_histogram2().

◆ F5Fset_histogram2()

F5_API int F5Fset_histogram2 ( F5Path * f,
const char * fragment_name,
const unsigned long * his,
hsize_t size,
int force )

Definition at line 854 of file F5Fmeta.c.

855{
856 if(!fragment_name)
857 return F5Fset_attribute(f, FIBER_FIELD_COMPONENT_HISTOGRAM, his, size, H5T_NATIVE_ULONG, force);
858 else
859 return F5Fset_fragment_attribute(f, fragment_name, FIBER_FIELD_COMPONENT_HISTOGRAM, his, size, H5T_NATIVE_ULONG, force);
860}

References F5_API, F5Fset_attribute(), F5Fset_fragment_attribute(), and FIBER_FIELD_COMPONENT_HISTOGRAM.

Referenced by F5Fset_histogram().

◆ F5Fset_metric_unit_description()

F5_API int F5Fset_metric_unit_description ( F5Path * f,
const char * unit )

Adds a string attribute to describe units to a data field. The F5Path must contain a valid Field_hid identifier, which2 may be either a group or a dataset. This function will set an attribute named F5_METRIC_UNIT_DESCRIPTION to the given object, which can be an arbitrary string.

Note
This unit description is only supposed to provide means for human interpretation, not for defining units in a programmatic way. Thus, the given string can be arbitrary,
Returns
-1 in case of error
Todo
Make this function using a char* and length such that it can be called directly from an c++ string and does not require the string to be 0-terminated. This needs to be supported in the function implementation as well.

Definition at line 967 of file F5Fmeta.c.

968{
969 return F5Fset_string_attribute(f, NULL, F5_METRIC_UNIT_DESCRIPTION, unit, 1 );
970}
#define F5_METRIC_UNIT_DESCRIPTION
Definition F5defs.h:299

References F5_API, F5_METRIC_UNIT_DESCRIPTION, and F5Fset_string_attribute().

Referenced by F5write_particle_cartesian3DvU().

◆ F5Fset_original_type2()

F5_API int F5Fset_original_type2 ( F5Path * f,
const char * fragment_name,
int force )

Definition at line 867 of file F5Fmeta.c.

868{
869char buf[256];
870 strcpy( buf, "Undefined" );
871hid_t type_id;
872int check;
873 type_id = F5Fget_type(f);
874
875 if( H5Tequal( H5T_NATIVE_USHORT, type_id ) ) // scalars
876 strcpy( buf, "H5T_NATIVE_USHORT" );
877 else if( H5Tequal( H5T_NATIVE_INT, type_id ) )
878 strcpy( buf, "H5T_NATIVE_INT" );
879 else if( H5Tequal( H5T_NATIVE_UCHAR, type_id ) )
880 strcpy( buf, "H5T_NATIVE_UCHAR" );
881 else if( H5Tequal( H5T_NATIVE_FLOAT, type_id ) )
882 strcpy( buf, "H5T_NATIVE_FLOAT" );
883 else if( H5Tequal( H5T_NATIVE_DOUBLE, type_id ) )
884 strcpy( buf, "H5T_NATIVE_DOUBLE" );
885 else if( H5Tequal( F5T_COORD3_FLOAT, type_id ) ) // coords/vecs
886 strcpy( buf, "F5T_COORD3_FLOAT" );
887 else if( H5Tequal( F5T_COORD3_DOUBLE, type_id ) )
888 strcpy( buf, "F5T_COORD3_DOUBLE" );
889 else if( H5Tequal( F5T_VEC3_FLOAT, type_id ) )
890 strcpy( buf, "F5T_VEC3_FLOAT" );
891 else if( H5Tequal( F5T_VEC3_DOUBLE, type_id ) )
892 strcpy( buf, "F5T_VEC3_DOUBLE" );
893 else if( H5Tequal( F5T_BIVEC3_FLOAT, type_id ) ) //bivecs
894 strcpy( buf, "F5T_BIVEC3_FLOAT" );
895 else if( H5Tequal( F5T_BIVEC3_DOUBLE, type_id ) )
896 strcpy( buf, "F5T_BIVEC3_DOUBLE" );
897 else if( H5Tequal( F5T_METRIC33_FLOAT, type_id ) ) // 2nd order tensors
898 strcpy( buf, "F5T_METRIC33_FLOAT" );
899 else if( H5Tequal( F5T_METRIC33_DOUBLE, type_id ) )
900 strcpy( buf, "F5T_METRIC33_DOUBLE" );
901
902
903
904
905
906 if( !fragment_name )
907 check = F5Fset_attribute(f, FIBER_FIELD_ORIGIANL_TYPE, buf, strlen(buf), H5Tcopy(H5T_C_S1), force);
908 else
909 check = F5Fset_fragment_attribute(f, fragment_name, FIBER_FIELD_ORIGIANL_TYPE, buf, strlen(buf), H5Tcopy(H5T_C_S1), force);
910
911 H5Tclose(type_id);
912 return check;
913}
#define F5T_BIVEC3_DOUBLE
#define F5T_COORD3_FLOAT
#define F5T_COORD3_DOUBLE
#define F5T_VEC3_FLOAT
#define F5T_VEC3_DOUBLE
#define F5T_METRIC33_DOUBLE
#define F5T_BIVEC3_FLOAT
#define FIBER_FIELD_ORIGIANL_TYPE
Definition F5defs.h:219

References F5_API, F5Fget_type(), F5Fset_attribute(), F5Fset_fragment_attribute(), F5T_BIVEC3_DOUBLE, F5T_BIVEC3_FLOAT, F5T_COORD3_DOUBLE, F5T_COORD3_FLOAT, F5T_METRIC33_DOUBLE, F5T_VEC3_DOUBLE, F5T_VEC3_FLOAT, FIBER_FIELD_ORIGIANL_TYPE, and H5Tclose().

◆ F5Fset_string_attribute()

F5_API int F5Fset_string_attribute ( F5Path * f,
const char * fragment_name,
const char * attribute_name,
const char * text,
int force )

Definition at line 350 of file F5Fmeta.c.

351{
352 if (f->Field_hid > 0)
353 {
354 if( fragment_name != NULL )
355 {
356 hid_t type_id = H5Tcopy(H5T_C_S1);
357 hid_t space_id = H5Screate(H5S_SCALAR);
358 hid_t attr_id;
359 size_t size = strlen(text);
360 H5Tset_size(type_id, size);
361 H5Tset_strpad(type_id, H5T_STR_NULLTERM);
362
363 H5E_BEGIN_TRY
364 attr_id = H5Acreate2( f->Field_hid, attribute_name, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
365 H5E_END_TRY
366 if (attr_id > 0)
367 {
368 F5printf(50, "F5Fset_string_attribute(): Unit Attribute %s written to %d.",
369 text, (int)f->Field_hid);
370 H5Awrite(attr_id, type_id, text);
371 H5Aclose(attr_id);
372 }
373 else
374 {
375 F5printf(50, "F5Fset_string_attribute(): WARNING Unit Attribute not written to %s/%d.",
376 text, (int)f->Field_hid);
377 }
378
379 H5Sclose(space_id);
380 H5Tclose(type_id);
381 return 1;
382 }
383 else
384 {
385 hid_t type_id = H5Tcopy(H5T_C_S1);
386 hid_t space_id = H5Screate(H5S_SCALAR);
387 hid_t attr_id;
388 size_t size = strlen(text);
389 H5Tset_size(type_id, size);
390 H5Tset_strpad(type_id, H5T_STR_NULLTERM);
391
392 if( F5Fis_group( f ) )
393 {
394 if( !F5Fopen_or_create_group_or_dataset_attribute( f, attribute_name, f->Field_hid, 0, 1, type_id, force, &space_id, &attr_id ) )
395 return 0;
396 }
397 else
398 {
399 if( !F5Fopen_or_create_group_or_dataset_attribute( f, attribute_name, 0, f->Field_hid, 1, type_id, force, &space_id, &attr_id ) )
400 return 0;
401 }
402
403 if (attr_id > 0)
404 {
405 F5printf(50, "F5Fset_string_attribute(): String attribute %s written to %d.", text, (int)f->Field_hid);
406 H5Awrite(attr_id, type_id, text);
407 H5Aclose(attr_id);
408 }
409 else
410 {
411 F5printf(50, "F5Fset_string_attribute(): WARNING Unit Attribute not written to %s/%d.", text, (int)f->Field_hid);
412 return 0;
413 }
414
415 return 1;
416 }
417
418 }
419 else
420 F5printf(50, "F5Fset_string_attribute(): Invalid field ID.");
421
422 return 0;
423}

References F5_API, F5Fis_group(), F5Fopen_or_create_group_or_dataset_attribute(), F5printf, F5Path::Field_hid, and H5Tclose().

Referenced by F5Fset_dictionary2(), and F5Fset_metric_unit_description().