Back to index

salome-kernel  6.5.0
Functions
hdfi.h File Reference
#include "HDFtypes.h"

Go to the source code of this file.

Functions

hdf_idt HDFfileCreate (char *name)
hdf_err HDFfileClose (hdf_idt fid)
hdf_idt HDFfileOpen (char *name, hdf_access_mode access_mode)
hdf_err HDFfileMount (hdf_idt id, const char *name, hdf_idt fid)
hdf_err HDFfileUmount (hdf_idt id, const char *name)
hdf_idt HDFgroupCreate (hdf_idt pid, char *name)
hdf_idt HDFgroupOpen (hdf_idt pid, char *name)
hdf_err HDFgroupClose (hdf_idt id)
hdf_idt HDFdatasetOpen (hdf_idt pid, char *name)
hdf_err HDFdatasetClose (hdf_idt id)
hdf_idt HDFdatasetCreate (hdf_idt pid, char *name, hdf_type type, hdf_size *dimd, int ndim, hdf_byte_order order, hdf_idt arrayId)
hdf_err HDFdatasetWrite (hdf_idt id, void *val)
hdf_err HDFdatasetRead (hdf_idt id, void *val)
hdf_type HDFdatasetGetType (hdf_idt id)
hdf_type HDFarrayGetType (hdf_idt id)
hdf_idt HDFarrayGetTypeId (hdf_idt type_id)
hdf_err HDFarrayClose (hdf_idt id)
int HDFarrayGetnDim (hdf_idt id)
hdf_err HDFarrayGetDim (hdf_idt id, hdf_size dim[])
hdf_idt HDFarrayCreate (hdf_type dataType, int ndim, hdf_size *dim)
int HDFdatasetGetnDim (hdf_idt id)
hdf_err HDFdatasetGetDim (hdf_idt id, hdf_size dim[])
int HDFdatasetGetSize (hdf_idt id)
hdf_byte_order HDFdatasetGetOrder (hdf_idt id)
hdf_idt HDFattrOpen (hdf_idt pid, char *name)
hdf_err HDFattrClose (hdf_idt id)
hdf_idt HDFattrCreate (hdf_idt pid, char *name, hdf_type type, size_t size)
hdf_err HDFattrWrite (hdf_idt id, void *val)
hdf_err HDFattrRead (hdf_idt id, void *val)
hdf_type HDFattrGetType (hdf_idt id)
hdf_type HDFattrGetSize (hdf_idt id)
void HDFerrorModeLock ()
hdf_err HDFnObjects (hdf_idt fid, const char *path, int *n)
hdf_err HDFobjectIdentify (hdf_idt fid, const char *path, int i, char *name)
hdf_err HDFobjectType (hdf_idt id, char *name, hdf_object_type *type)

Function Documentation

Definition at line 42 of file HDFarrayClose.c.

{
  hdf_err ret;

  if ((ret = H5Tclose(id)) < 0)
    return -1;
  
  return 0;
}
hdf_idt HDFarrayCreate ( hdf_type  dataType,
int  ndim,
hdf_size dim 
)

Definition at line 43 of file HDFarrayCreate.c.

{
  hdf_idt type_hdf;
  switch(dataType)
      {
      case HDF_FLOAT64 :
#if defined (PCLINUX) || defined (PCLINUX64)
       type_hdf = H5T_IEEE_F64BE;
#else 
       type_hdf = H5T_IEEE_F64LE;
#endif
       break;

      case HDF_INT32 :
#if defined (PCLINUX) || defined (PCLINUX64)
       type_hdf = H5T_STD_I32BE;  
#else
       type_hdf = H5T_NATIVE_INT;
#endif
       break;
 
      case HDF_INT64 :
       type_hdf = H5T_NATIVE_LONG;
       break;
      case HDF_CHAR :
       type_hdf = H5T_NATIVE_CHAR;
       break;
      default:
       return -1;
       break;
      }
    
    return H5Tarray_create2( type_hdf, ndim, dim );
}
hdf_err HDFarrayGetDim ( hdf_idt  id,
hdf_size  dim[] 
)

Definition at line 34 of file HDFarrayGetDim.c.

{
  hdf_err ret = 0;
  hdf_size *tmp;
  int ndim, i;

  if ( (ndim = H5Tget_array_ndims(id)) < 0 )
    return -1;

  tmp = (hdf_size *) malloc(sizeof(hdf_size)*ndim);

  ret = H5Tget_array_dims2(id, tmp);
  
  for( i=0 ; i < ndim ; i++)
    dim[i] = tmp[i];
  
  free (tmp);
  
  return ret;
}
int HDFarrayGetnDim ( hdf_idt  id)

Definition at line 33 of file HDFarrayGetnDim.c.

{
  int ndim;

  if ((ndim = H5Tget_array_ndims(id)) < 0)
    return -1;

  return ndim;
}

Definition at line 33 of file HDFarrayGetType.c.

{
  hdf_idt super;
  hdf_type type;
  hdf_size_type size;
  
  if(type_id < 0 )
    return HDF_NONE; 
  
  if((super = H5Tget_super(type_id))  < 0 )
    return HDF_NONE;
  
  switch (H5Tget_class(super))
    {
    case H5T_INTEGER :
      size = H5Tget_size(super);
      if(size == 1)
       type = HDF_CHAR;
      else if (size == 4)
        type = HDF_INT32;
      else
        type = HDF_INT64;
      break;
      
    case H5T_FLOAT :
      type = HDF_FLOAT64;
      break;
      
    case H5T_STRING :
      type = HDF_STRING;
      break;
      
    default :
      type = HDF_NONE;
    }
  
  H5Tclose(super);
  return type;
}

Definition at line 33 of file HDFarrayGetTypeId.c.

                              {
  return H5Dget_type(id);
}

Definition at line 45 of file HDFattrClose.c.

{
  hdf_err ret;

  if ((ret = H5Aclose(id)) < 0)
    return -1;

  return 0;
}

Here is the caller graph for this function:

hdf_idt HDFattrCreate ( hdf_idt  pid,
char *  name,
hdf_type  type,
size_t  size 
)

Definition at line 42 of file HDFattrCreate.c.

{
  hdf_idt aid,attr;
  hdf_err ret;
  int type_hdf;

  switch(type) {
  case HDF_FLOAT64 :
#if defined (PCLINUX) || defined (PCLINUX64)
    type_hdf = H5T_IEEE_F64BE;
#else 
    type_hdf = H5T_IEEE_F64LE;
#endif
    break;
    
  case HDF_INT32 :
#if defined (PCLINUX) || defined (PCLINUX64)
    type_hdf = H5T_STD_I32BE;  
#else
    type_hdf = H5T_NATIVE_INT;
#endif
    break;
    
  case HDF_INT64 :
    type_hdf = H5T_NATIVE_LONG;
    break;

  case HDF_STRING :           
    if((type_hdf = H5Tcopy(H5T_C_S1)) < 0)
      return -1;
    if((ret = H5Tset_size(type_hdf, size)) < 0)
      return -1;
    break;
    
  default :
    return -1;
  }

  if ((aid = H5Screate(H5S_SCALAR)) < 0)
    return -1;
  
  if ((attr = H5Acreate(pid,name,type_hdf,aid,H5P_DEFAULT)) < 0)
    return -1;
  
  if ((ret = H5Sclose(aid)) < 0)
    return -1;
  
  return attr;
}

Here is the caller graph for this function:

Definition at line 32 of file HDFattrGetSize.c.

{
  hdf_type ret;
  hdf_idt type_id;

  if ((type_id = H5Aget_type(id)) < 0)
    return HDF_NONE;

  ret = (hdf_type)H5Tget_size(type_id);

  H5Tclose(type_id);

  return ret;
}

Definition at line 33 of file HDFattrGetType.c.

{
  hdf_idt type_id;
  hdf_type type;
  hdf_class_type hdf_type;
  hdf_size_type size;

  if ((type_id = H5Aget_type(id)) < 0)
    return HDF_NONE;

  hdf_type = H5Tget_class(type_id);

  switch (hdf_type)
    {
    case H5T_INTEGER :
      size = H5Tget_size(type_id);
      if (size == 4)
        type = HDF_INT32;
      else
        type = HDF_INT64;
      break;

    case H5T_FLOAT :
      type = HDF_FLOAT64;
      break;

    case H5T_STRING :
      type = HDF_STRING;
      break;

    default :
      type = HDF_NONE;
    }

  H5Tclose(type_id);

  return type;
}
hdf_idt HDFattrOpen ( hdf_idt  pid,
char *  name 
)

Definition at line 40 of file HDFattrOpen.c.

{
   hdf_idt aid;

   if ((aid = H5Aopen_name(pid,name)) < 0)
     return -1;

   return aid;
}

Here is the caller graph for this function:

hdf_err HDFattrRead ( hdf_idt  id,
void *  val 
)

Definition at line 41 of file HDFattrRead.c.

{
  hdf_err ret = -1;
  hdf_idt type_hdf;
  
  if ((type_hdf = H5Aget_type(id)) >= 0) {
#if defined (PCLINUX) || defined (PCLINUX64)
    if ((H5Tget_class(type_hdf) == H5T_INTEGER) && (H5Tget_size(type_hdf) == 4)) 
      type_hdf = H5T_NATIVE_INT;
#endif 
    ret = H5Aread(id, type_hdf, val);
  }

  H5Tclose(type_hdf);
  return ret;
}

Here is the caller graph for this function:

hdf_err HDFattrWrite ( hdf_idt  id,
void *  val 
)

Definition at line 41 of file HDFattrWrite.c.

{
  hdf_idt type_id;
  int ret = 0;
#if defined (PCLINUX) || defined (PCLINUX64)
  int isI32BE = 0;
#endif

  if ((type_id = H5Aget_type(id)) < 0)
    return -1;

#if defined (PCLINUX) || defined (PCLINUX64)
  if((H5Tget_class(type_id) == H5T_INTEGER) && (H5Tget_size(type_id) == 4)) {
    isI32BE = 1; /* See HDFattrCreate */
    if (H5Tconvert(H5T_NATIVE_INT,H5T_STD_I32BE,1,(void *)val,NULL,(hid_t)0) < 0)
      return -1;
  }
#endif

  ret = H5Awrite(id,type_id, val);


#if defined (PCLINUX) || defined (PCLINUX64)
  if (isI32BE && (H5Tconvert(H5T_STD_I32BE,H5T_NATIVE_INT,1,(void *)val,NULL,(hid_t)0) < 0))
    return -1;
#endif

  H5Tclose(type_id);

  return ret;
}

Here is the caller graph for this function:

Definition at line 42 of file HDFdatasetClose.c.

{
  hdf_err ret;

  if ((ret = H5Dclose(id)) < 0)
    return -1;
  
  return 0;
}

Here is the caller graph for this function:

hdf_idt HDFdatasetCreate ( hdf_idt  pid,
char *  name,
hdf_type  type,
hdf_size dimd,
int  ndim,
hdf_byte_order  order,
hdf_idt  arrayId 
)

Definition at line 45 of file HDFdatasetCreate.c.

{
  hdf_idt dataset, dataspace = 0;
  hdf_err ret;
  hdf_idt type_hdf, new_type_hdf = -1;

  switch(type)
    {
    case HDF_FLOAT64 :
#if defined (PCLINUX) || defined (PCLINUX64)
      type_hdf = H5T_IEEE_F64BE;
#else 
      type_hdf = H5T_IEEE_F64LE;
#endif
      break;

    case HDF_INT32 :
#if defined (PCLINUX) || defined (PCLINUX64)
      type_hdf = H5T_STD_I32BE;  
#else
      type_hdf = H5T_NATIVE_INT;
#endif
      break;
 
    case HDF_INT64 :
      type_hdf = H5T_NATIVE_LONG;
      break;

    case HDF_STRING :           
      if((new_type_hdf = H5Tcopy(H5T_C_S1)) < 0)
        return -1;
      if((ret = H5Tset_size(new_type_hdf,1)) < 0)
        return -1;
      break;    

    case HDF_ARRAY :
      type_hdf = arrayId;
      break;
      
    default :
      return -1;
    }

  /* set order */
  if ( order != H5T_ORDER_ERROR && 
       order != H5T_ORDER_NONE && 
       type  != HDF_STRING )
    {
      if (( new_type_hdf = H5Tcopy( type_hdf )) < 0 )
        return -1;
      if (( ret = H5Tset_order (new_type_hdf, order )) < 0 )
        return -1;
    }

  if ((dataset = H5Dopen(pid,name)) < 0)
    {
      if ((dataspace = H5Screate_simple(ndim, dimd, NULL)) < 0)                                                         
        return -1;
      if ((dataset = H5Dcreate(pid,name,
                               new_type_hdf < 0 ? type_hdf : new_type_hdf,
                               dataspace, H5P_DEFAULT)) < 0)
        return -1;
    }
  else
    return -1;

  if ( ! (new_type_hdf < 0) && (ret = H5Tclose(new_type_hdf)) < 0)
    return -1;
  if ((ret = H5Sclose(dataspace)) < 0)
    return -1;

  return dataset;
}

Here is the caller graph for this function:

Definition at line 34 of file HDFdatasetGetDim.c.

{
  hdf_err ret = 0;
  hdf_size *tmp;
  int ndim;
  hdf_idt space_id;

  if ((space_id = H5Dget_space(id)) < 0)
    return -1;

  if ((ndim = H5Sget_simple_extent_ndims(space_id)) < 0)
    return -1;

  tmp = (hdf_size *) malloc(sizeof(hdf_size)*ndim);
  ret = H5Sget_simple_extent_dims(space_id, dim, tmp);
  ret =  H5Sclose(space_id);
  
 free (tmp);

  return ret;
}

Here is the caller graph for this function:

Definition at line 33 of file HDFdatasetGetnDim.c.

{
  int ndim;
  hdf_idt space_id;
  hdf_err ret;

  if ((space_id = H5Dget_space(id)) < 0)
    return -1;

  if ((ndim = H5Sget_simple_extent_ndims(space_id)) < 0)
    return -1;

  if ((ret = H5Sclose(space_id)) < 0)
    return -1;

  return ndim;
}

Here is the caller graph for this function:

Definition at line 33 of file HDFdatasetGetOrder.c.

{
  hdf_idt type_id;
  hdf_byte_order order;

  if ((type_id = H5Dget_type(dataset_id)) < 0)
    return H5T_ORDER_ERROR;

  order = H5Tget_order(type_id);

  H5Tclose(type_id);

  return order;
}

Definition at line 32 of file HDFdatasetGetSize.c.

{
  hdf_size size;

  if ((size = H5Dget_storage_size(id)) < 0)
    return -1;

  return (int) size;
}

Definition at line 33 of file HDFdatasetGetType.c.

{
  hdf_idt type_id;
  hdf_type type;
  hdf_size_type size;

  if ((type_id = H5Dget_type(id)) < 0)
    return HDF_NONE;

  switch (H5Tget_class(type_id))
    {
    case H5T_INTEGER :
      size = H5Tget_size(type_id);
      if (size == 4)
        type = HDF_INT32;
      else
        type = HDF_INT64;
      break;

    case H5T_FLOAT :
      type = HDF_FLOAT64;
      break;

    case H5T_STRING :
      type = HDF_STRING;
      break;
      
    case H5T_ARRAY :
      type = HDF_ARRAY;
      break;

    default :
      type = HDF_NONE;
    }

  H5Tclose(type_id);

  return type;
}
hdf_idt HDFdatasetOpen ( hdf_idt  pid,
char *  name 
)

Definition at line 43 of file HDFdatasetOpen.c.

{
  hdf_idt id;

  if ((id = H5Dopen(pid,name)) < 0)
    return -1;

  return id;
}

Here is the caller graph for this function:

hdf_err HDFdatasetRead ( hdf_idt  id,
void *  val 
)

Definition at line 41 of file HDFdatasetRead.c.

{
  hdf_idt datatype;
  hdf_err ret;

  if ((datatype = H5Dget_type(id)) < 0)
    return -1;

//#if defined (PCLINUX) || defined (PCLINUX64)
  if ((H5Tget_class(datatype) == H5T_INTEGER) && (H5Tget_size(datatype) == 4)) 
    datatype = H5T_NATIVE_INT;
//#endif 

  if ((ret = H5Dread(id,datatype,H5S_ALL,H5S_ALL,H5P_DEFAULT, val)) < 0)
    return -1;

  return 0;
}

Here is the caller graph for this function:

hdf_err HDFdatasetWrite ( hdf_idt  id,
void *  val 
)

Definition at line 42 of file HDFdatasetWrite.c.

{
  hdf_idt datatype;
  hdf_err ret;
#if defined (PCLINUX) || defined (PCLINUX64)
  int isI32BE = 0;
  int size = 0;
#endif

  if ((datatype = H5Dget_type(id)) < 0)
    return -1;

#if defined (PCLINUX) || defined (PCLINUX64)
  if((H5Tget_class(datatype) == H5T_INTEGER) && (H5Tget_size(datatype) == 4)) {
    isI32BE = 1; /* See HDFdatasetCreate */

    /*SRN : bug IPAL9619:  replaced the method of getting the size of INT32 dataset */ 
    int i, ndim = HDFdatasetGetnDim(id);
    if(ndim < 0) return -1;
    
    hdf_size *dim = (hdf_size *) malloc(sizeof(hdf_size)*ndim);
    if ((ret = HDFdatasetGetDim(id, dim)) < 0)  return -1;
        
    for(i=0; i<ndim; i++) size+=dim[i];    
    free(dim);
    /*SRN : end of the fix */
    
    if(size == 0) 
      return -1;
    if(H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32BE, size, (void *)val, NULL, (hid_t)0) < 0) 
      return -1;
  }
#endif

  if ((ret = H5Dwrite(id, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, val)) < 0) 
    return -1;

#if defined (PCLINUX) || defined (PCLINUX64)
  if (isI32BE && (H5Tconvert(H5T_STD_I32BE, H5T_NATIVE_INT, size, (void *)val, NULL, (hid_t)0) < 0)) 
    return -1;
#endif

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void HDFerrorModeLock ( )

Definition at line 37 of file HDFerrorModeLock.c.

{
  H5Eset_auto(NULL,NULL);
}

Here is the caller graph for this function:

Definition at line 41 of file HDFfileClose.c.

{
  hdf_err ret;

  H5Fflush(fid,H5F_SCOPE_GLOBAL);

  if ((ret = H5Fclose(fid)) < 0)
    return -1;

  return 0;
}

Here is the caller graph for this function:

hdf_idt HDFfileCreate ( char *  name)

Definition at line 40 of file HDFfileCreate.c.

{
  hdf_idt fid;

  if ((fid = H5Fcreate(name,H5F_ACC_TRUNC,
                               H5P_DEFAULT,H5P_DEFAULT)) < 0)
    return -1;

  return fid;
}

Here is the caller graph for this function:

hdf_err HDFfileMount ( hdf_idt  id,
const char *  name,
hdf_idt  fid 
)

Definition at line 33 of file HDFfileMount.c.

{
  hdf_err ret = 0;

  ret = H5Fmount(id, name, fid,H5P_DEFAULT);
    
  return ret;
} 
hdf_idt HDFfileOpen ( char *  name,
hdf_access_mode  access_mode 
)

Definition at line 41 of file HDFfileOpen.c.

{ 
  hdf_idt fid;
  int mode;

  switch(access_mode)
    {
    case HDF_RDONLY:
      mode = H5F_ACC_RDONLY;
      break;

    case HDF_RDWR :
      mode = H5F_ACC_RDWR; 
      break;

    default :
      return -1;
    }  

  if ((fid = H5Fopen(name,mode,H5P_DEFAULT)) < 0)
    return -1;

  return fid;
}

Here is the caller graph for this function:

hdf_err HDFfileUmount ( hdf_idt  id,
const char *  name 
)

Definition at line 33 of file HDFfileUmount.c.

{
  hdf_err ret;

  ret = H5Funmount(id,name);

  return ret;
}

Definition at line 42 of file HDFgroupClose.c.

{
  hdf_err ret;

  if ((ret = H5Gclose(id)) < 0)
    return -1;
  
  return 0;
}

Here is the caller graph for this function:

hdf_idt HDFgroupCreate ( hdf_idt  pid,
char *  name 
)

Definition at line 43 of file HDFgroupCreate.c.

{
  hdf_idt id;

  if ((id = H5Gcreate(pid,name,0)) < 0)
    return -1;

  return id;
}

Here is the caller graph for this function:

hdf_idt HDFgroupOpen ( hdf_idt  pid,
char *  name 
)

Definition at line 43 of file HDFgroupOpen.c.

{
  hdf_idt id;

  if ((id = H5Gopen(pid,name)) < 0)
    return -1;

  return id;
}

Here is the caller graph for this function:

hdf_err HDFnObjects ( hdf_idt  fid,
const char *  path,
int *  n 
)

Definition at line 46 of file HDFnObjects.c.

{
  int idx;
  int m = 0;

  if ((idx  = H5Giterate(fid,path,NULL,Num,(void*)&m)) < 0)
    return -1;

  *n = (int) m;

  return 0;
}

Here is the call graph for this function:

hdf_err HDFobjectIdentify ( hdf_idt  fid,
const char *  path,
int  i,
char *  name 
)

Definition at line 48 of file HDFobjectIdentify.c.

{
  int idx;

  if ((idx = H5Giterate(fid,path,&i,RankInfo,
                        name)) < 0)
    return -1;

  return 0;
}

Here is the call graph for this function:

hdf_err HDFobjectType ( hdf_idt  id,
char *  name,
hdf_object_type type 
)

Definition at line 32 of file HDFobjectType.c.

{
  hdf_bool follow = 1;
  H5G_stat_t buf;
  hdf_err ret;

  if ((ret = H5Gget_objinfo(id,name,follow,&buf) < 0))
    return -1; 
  
  switch(buf.type)
    {
    case H5G_GROUP :
      *type = HDF_GROUP;
      break;

    case H5G_DATASET :
      *type = HDF_DATASET;
      break;
     
    default :
      return -1;
    }

  return 0;
}