GADGET-4
hdf5_util.cc File Reference

some helper functions for HDF5 I/O routines More...

#include "gadgetconfig.h"
#include <hdf5.h>
#include <math.h>
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../data/allvars.h"
#include "../data/dtypes.h"
#include "../io/hdf5_util.h"
#include "../half/half.hpp"

Go to the source code of this file.

Macros

#define HALF_ROUND_STYLE   1
 

Functions

void my_create_HDF5_halfprec_handler (void)
 
void my_create_HDF5_special_integer_types (void)
 
hid_t my_H5Fcreate (const char *fname, unsigned int flags, hid_t fcpl_id, hid_t fapl_id)
 
hid_t my_H5Gcreate (hid_t loc_id, const char *groupname, size_t size_hint)
 
hid_t my_H5Dcreate (hid_t loc_id, const char *datasetname, hid_t type_id, hid_t space_id, hid_t dcpl_id)
 
herr_t my_H5Dwrite (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, const void *buf, const char *datasetname)
 
hid_t my_H5Acreate (hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id)
 
herr_t my_H5Awrite (hid_t attr_id, hid_t mem_type_id, const void *buf, const char *attr_name)
 
hid_t my_H5Screate (H5S_class_t type)
 
hid_t my_H5Screate_simple (int rank, const hsize_t *current_dims, const hsize_t *maximum_dims)
 
hid_t my_H5Fopen (const char *fname, unsigned int flags, hid_t fapl_id)
 
hid_t my_H5Gopen (hid_t loc_id, const char *groupname)
 
hid_t my_H5Dopen (hid_t file_id, const char *datasetname)
 
herr_t my_H5Dset_extent (hid_t dset_id, const hsize_t size[])
 
hid_t my_H5Dopen_if_existing (hid_t file_id, const char *datasetname)
 
hid_t my_H5Aopen_name (hid_t loc_id, const char *attr_name)
 
herr_t my_H5Dread (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, void *buf, const char *datasetname)
 
herr_t my_H5Aread (hid_t attr_id, hid_t mem_type_id, void *buf, const char *attr_name, hssize_t size)
 
herr_t my_H5Aclose (hid_t attr_id, const char *attr_name)
 
herr_t my_H5Dclose (hid_t dataset_id, const char *datasetname)
 
herr_t my_H5Gclose (hid_t group_id, const char *groupname)
 
herr_t my_H5Pclose (hid_t plist)
 
herr_t my_H5Fclose (hid_t file_id, const char *fname)
 
herr_t my_H5Sclose (hid_t dataspace_id, H5S_class_t type)
 
hid_t my_H5Tcopy (hid_t type_id)
 
herr_t my_H5Tclose (hid_t type_id)
 
herr_t my_H5Sselect_hyperslab (hid_t space_id, H5S_seloper_t op, const hsize_t *start, const hsize_t *stride, const hsize_t *count, const hsize_t *block)
 
size_t my_H5Tget_size (hid_t datatype_id)
 
herr_t my_H5Tset_size (hid_t datatype_id, size_t size)
 
void read_scalar_attribute (hid_t handle, const char *attr_name, void *buf, hid_t mem_type_id)
 
int read_scalar_attribute (hid_t handle, const char *attr_name, const char *alternative_name, void *buf, hid_t mem_type_id)
 
void read_vector_attribute (hid_t handle, const char *attr_name, void *buf, hid_t mem_type_id, int length)
 
void write_scalar_attribute (hid_t handle, const char *attr_name, const void *buf, hid_t mem_type_id)
 
void write_vector_attribute (hid_t handle, const char *attr_name, const void *buf, hid_t mem_type_id, int length)
 
void write_string_attribute (hid_t handle, const char *attr_name, const char *buf)
 

Variables

hid_t Halfprec_memtype
 
hid_t Int48_memtype
 
hid_t Int128_memtype
 

Detailed Description

some helper functions for HDF5 I/O routines

Definition in file hdf5_util.cc.

Macro Definition Documentation

◆ HALF_ROUND_STYLE

#define HALF_ROUND_STYLE   1

Definition at line 25 of file hdf5_util.cc.

Function Documentation

◆ my_create_HDF5_halfprec_handler()

void my_create_HDF5_halfprec_handler ( void  )

Definition at line 121 of file hdf5_util.cc.

◆ my_create_HDF5_special_integer_types()

void my_create_HDF5_special_integer_types ( void  )

Definition at line 135 of file hdf5_util.cc.

◆ my_H5Aclose()

herr_t my_H5Aclose ( hid_t  attr_id,
const char *  attr_name 
)

This routine wraps closing an attribute to give a nice error message

Definition at line 429 of file hdf5_util.cc.

◆ my_H5Acreate()

hid_t my_H5Acreate ( hid_t  loc_id,
const char *  attr_name,
hid_t  type_id,
hid_t  space_id,
hid_t  acpl_id 
)

This routine wraps creating an attribute to give a nice error message

Definition at line 223 of file hdf5_util.cc.

◆ my_H5Aopen_name()

hid_t my_H5Aopen_name ( hid_t  loc_id,
const char *  attr_name 
)

This routine wraps opening an attribute to give a nice error message

Definition at line 371 of file hdf5_util.cc.

◆ my_H5Aread()

herr_t my_H5Aread ( hid_t  attr_id,
hid_t  mem_type_id,
void *  buf,
const char *  attr_name,
hssize_t  size 
)

This routine wraps reading an attribute to give a nice error message

Definition at line 400 of file hdf5_util.cc.

◆ my_H5Awrite()

herr_t my_H5Awrite ( hid_t  attr_id,
hid_t  mem_type_id,
const void *  buf,
const char *  attr_name 
)

This routine wraps writing an attribute to give a nice error message

Definition at line 242 of file hdf5_util.cc.

◆ my_H5Dclose()

herr_t my_H5Dclose ( hid_t  dataset_id,
const char *  datasetname 
)

This routine wraps closing a dataset to give a nice error message

Definition at line 443 of file hdf5_util.cc.

◆ my_H5Dcreate()

hid_t my_H5Dcreate ( hid_t  loc_id,
const char *  datasetname,
hid_t  type_id,
hid_t  space_id,
hid_t  dcpl_id 
)

This routine wraps creating a dataset to give a nice error message

Definition at line 190 of file hdf5_util.cc.

◆ my_H5Dopen()

hid_t my_H5Dopen ( hid_t  file_id,
const char *  datasetname 
)

This routine wraps opening a dataset to give a nice error message

Definition at line 325 of file hdf5_util.cc.

◆ my_H5Dopen_if_existing()

hid_t my_H5Dopen_if_existing ( hid_t  file_id,
const char *  datasetname 
)

This routine wraps opening a dataset. However, in contrast to my_H5Dopen(), if the dataset does not exist it does not terminate the run. This is useful while reading an ICs file because in that case a non-exisitng dataset is put to zero (see also read_ic.c)

Definition at line 352 of file hdf5_util.cc.

◆ my_H5Dread()

herr_t my_H5Dread ( hid_t  dataset_id,
hid_t  mem_type_id,
hid_t  mem_space_id,
hid_t  file_space_id,
hid_t  xfer_plist_id,
void *  buf,
const char *  datasetname 
)

This routine wraps reading a dataset to give a nice error message

Definition at line 385 of file hdf5_util.cc.

◆ my_H5Dset_extent()

herr_t my_H5Dset_extent ( hid_t  dset_id,
const hsize_t  size[] 
)

Definition at line 336 of file hdf5_util.cc.

◆ my_H5Dwrite()

herr_t my_H5Dwrite ( hid_t  dataset_id,
hid_t  mem_type_id,
hid_t  mem_space_id,
hid_t  file_space_id,
hid_t  xfer_plist_id,
const void *  buf,
const char *  datasetname 
)

This routine wraps writing a dataset to give a nice error message

Definition at line 206 of file hdf5_util.cc.

◆ my_H5Fclose()

herr_t my_H5Fclose ( hid_t  file_id,
const char *  fname 
)

This routine wraps closing a file to give a nice error message

Definition at line 482 of file hdf5_util.cc.

◆ my_H5Fcreate()

hid_t my_H5Fcreate ( const char *  fname,
unsigned int  flags,
hid_t  fcpl_id,
hid_t  fapl_id 
)

This routine wraps creating a file to give a nice error message

Definition at line 158 of file hdf5_util.cc.

◆ my_H5Fopen()

hid_t my_H5Fopen ( const char *  fname,
unsigned int  flags,
hid_t  fapl_id 
)

This routine wraps opening a file to give a nice error message

Definition at line 297 of file hdf5_util.cc.

◆ my_H5Gclose()

herr_t my_H5Gclose ( hid_t  group_id,
const char *  groupname 
)

This routine wraps closing a group to give a nice error message

Definition at line 457 of file hdf5_util.cc.

◆ my_H5Gcreate()

hid_t my_H5Gcreate ( hid_t  loc_id,
const char *  groupname,
size_t  size_hint 
)

This routine wraps creating a group to give a nice error message

Definition at line 174 of file hdf5_util.cc.

◆ my_H5Gopen()

hid_t my_H5Gopen ( hid_t  loc_id,
const char *  groupname 
)

This routine wraps opening a group to give a nice error message

Definition at line 311 of file hdf5_util.cc.

◆ my_H5Pclose()

herr_t my_H5Pclose ( hid_t  plist)

Definition at line 468 of file hdf5_util.cc.

◆ my_H5Sclose()

herr_t my_H5Sclose ( hid_t  dataspace_id,
H5S_class_t  type 
)

This routine wraps closing a dataspace to give a nice error message

Definition at line 496 of file hdf5_util.cc.

◆ my_H5Screate()

hid_t my_H5Screate ( H5S_class_t  type)

This routine wraps creating a dataspace to give a nice error message

Definition at line 258 of file hdf5_util.cc.

◆ my_H5Screate_simple()

hid_t my_H5Screate_simple ( int  rank,
const hsize_t *  current_dims,
const hsize_t *  maximum_dims 
)

This routine wraps creating a simple dataspace to give a nice error message

Definition at line 283 of file hdf5_util.cc.

◆ my_H5Sselect_hyperslab()

herr_t my_H5Sselect_hyperslab ( hid_t  space_id,
H5S_seloper_t  op,
const hsize_t *  start,
const hsize_t *  stride,
const hsize_t *  count,
const hsize_t *  block 
)

This routine wraps selecting a hyperslab to give a nice error message

Definition at line 549 of file hdf5_util.cc.

◆ my_H5Tclose()

herr_t my_H5Tclose ( hid_t  type_id)

This routine wraps closing a datatype to give a nice error message

Definition at line 535 of file hdf5_util.cc.

◆ my_H5Tcopy()

hid_t my_H5Tcopy ( hid_t  type_id)

This routine wraps copying an existing datatype to give a nice error message

Definition at line 521 of file hdf5_util.cc.

◆ my_H5Tget_size()

size_t my_H5Tget_size ( hid_t  datatype_id)

This routine wraps returning the size in bytes of a given datatype to give a nice error message

Definition at line 564 of file hdf5_util.cc.

◆ my_H5Tset_size()

herr_t my_H5Tset_size ( hid_t  datatype_id,
size_t  size 
)

This routine wraps setting the size in bytes of a given datatype to give a nice error message

Definition at line 578 of file hdf5_util.cc.

◆ read_scalar_attribute() [1/2]

int read_scalar_attribute ( hid_t  handle,
const char *  attr_name,
const char *  alternative_name,
void *  buf,
hid_t  mem_type_id 
)

Definition at line 596 of file hdf5_util.cc.

◆ read_scalar_attribute() [2/2]

void read_scalar_attribute ( hid_t  handle,
const char *  attr_name,
void *  buf,
hid_t  mem_type_id 
)

Definition at line 589 of file hdf5_util.cc.

◆ read_vector_attribute()

void read_vector_attribute ( hid_t  handle,
const char *  attr_name,
void *  buf,
hid_t  mem_type_id,
int  length 
)

Definition at line 614 of file hdf5_util.cc.

◆ write_scalar_attribute()

void write_scalar_attribute ( hid_t  handle,
const char *  attr_name,
const void *  buf,
hid_t  mem_type_id 
)

Definition at line 621 of file hdf5_util.cc.

◆ write_string_attribute()

void write_string_attribute ( hid_t  handle,
const char *  attr_name,
const char *  buf 
)

Definition at line 654 of file hdf5_util.cc.

◆ write_vector_attribute()

void write_vector_attribute ( hid_t  handle,
const char *  attr_name,
const void *  buf,
hid_t  mem_type_id,
int  length 
)

Definition at line 636 of file hdf5_util.cc.

Variable Documentation

◆ Halfprec_memtype

hid_t Halfprec_memtype

Definition at line 29 of file hdf5_util.cc.

◆ Int128_memtype

hid_t Int128_memtype

Definition at line 31 of file hdf5_util.cc.

◆ Int48_memtype

hid_t Int48_memtype

Definition at line 30 of file hdf5_util.cc.