OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
hdf4utils.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <productInfo.h>
#include <passthebuck.h>
Include dependency graph for hdf4utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  att_info_struct
 
struct  sds_info_struct
 

Macros

#define HDF4_UTILS_MAX_NAME   256
 
#define HDF4_UTILS_MAX_DIM   32
 
#define READ_GLBL_ATTR(nam, ptr)
 
#define READ_GLBL_ATTR_E(nam, ptr)
 
#define READ_SDS(nam, ptr, s0, s1, s2, e0, e1, e2)
 
#define READ_SDS_E(nam, ptr, s0, s1, s2, e0, e1, e2)
 
#define READ_SDS_ID(sd_id, nam, ptr, s0, s1, s2, s3, e0, e1, e2, e3)
 
#define READ_SDS_ID_E(sd_id, nam, ptr, s0, s1, s2, s3, e0, e1, e2, e3)
 
#define EOSMETALEN   32768
 
#define read_att(obj_id, attname, valptr)
 

Functions

int32_t hdf_sizeof (int32_t dtype)
 
char * GetFileDesc (const char *filename)
 
int CreateSDS (int32_t sd_id, const char *sname, const char *lname, const char *standard_name, const char *units, double low, double high, float slope, float offset, int32_t nt, int32_t rank, int32_t d0, int32_t d1, int32_t d2, const char *dn0, const char *dn1, const char *dn2)
 
int sd_create (int32_t id, const char *nam, int32_t typ, int32_t rank, int32_t d0, int32_t d1, int32_t d2, int32_t *sds_id)
 
int sd_select (int32_t sd_id, const char *name, int32_t *sds_id)
 
int sd_endaccess (int32_t id)
 
int sd_setdimnames (int32_t id, const char *d0, const char *d1, const char *d2)
 
int sd_setdimname (int32_t sds_id, int32_t dim_number, const char *name)
 
int sd_setattr (int32_t id, const char *nam, int32_t typ, int32_t cnt, const void *data)
 
int sd_readdata (int32_t sd_id, const char *name, void *data, int32_t s0, int32_t s1, int32_t s2, int32_t e0, int32_t e1, int32_t e2)
 
int sd_writedata (int32_t sd_id, const char *name, const void *data, int32_t s0, int32_t s1, int32_t s2, int32_t e0, int32_t e1, int32_t e2)
 
int AddSdsToVgroup (int32_t sd_id, int32_t v_id, const char *name)
 
int v_attach (int32_t h_id, int32_t *v_id)
 
int getDims (int32_t fileID, const char sdsname[], int32_t dims[])
 
int get_type (int32_t fileID, const char sdsname[], int32_t *dtype)
 
int rdSDS (int32_t fileID, const char sdsname[], int32_t start1, int32_t start2, int32_t edges1, int32_t edges2, void *array_data)
 
int getHDFattr (int32_t fileID, const char attrname[], const char sdsname[], void *data)
 
int32_t read_SDS (int32_t sdfid, const char *sds_name, void *buffer)
 
int attach_vdata (int32_t fid, const char *sname)
 
int rdvdata (int32_t vskey, const char *fields, int32_t start, int32_t nelt, unsigned char *databuf)
 
const char * hdf_typename (const int32_t ntype)
 
char * fmt_hdf_val (const void *array, const int32_t i, const int32_t ntype)
 
void fopen_warn (const char *filename, const char *file, int32_t const line)
 
void fopen_err (const char *filename, const char *file, int32_t const line)
 
int init_sds_byname (int32_t fileid, const char *sdsname, sds_struct *sds)
 
int readall_sds (sds_struct *sds)
 
void free_sds (sds_struct *sds)
 
void print_sds_info (const sds_struct sds)
 
int load_att_byname (int32_t obj_id, const char *attname, att_struct *att)
 
void print_att_vals (const att_struct att)
 
void print_att_info (const att_struct att)
 
int parse_odl (const char *odltext, const char *object, char *value)
 
int get_hdfeos_meta (int32_t sd_id, char *attribute, char *name, char *data)
 

Macro Definition Documentation

◆ EOSMETALEN

#define EOSMETALEN   32768

Definition at line 173 of file hdf4utils.h.

◆ HDF4_UTILS_MAX_DIM

#define HDF4_UTILS_MAX_DIM   32

Definition at line 12 of file hdf4utils.h.

◆ HDF4_UTILS_MAX_NAME

#define HDF4_UTILS_MAX_NAME   256

Definition at line 11 of file hdf4utils.h.

◆ read_att

#define read_att (   obj_id,
  attname,
  valptr 
)
Value:
SDreadattr(obj_id, \
SDfindattr(obj_id,attname), \
(void *) valptr)

Definition at line 177 of file hdf4utils.h.

◆ READ_GLBL_ATTR

#define READ_GLBL_ATTR (   nam,
  ptr 
)
Value:
{ \
if(SDreadattr(sd_id,SDfindattr(sd_id,(nam)),(void*)(ptr))){ \
fprintf(stderr, \
"-E- %s line %d: Could not get global attribute, %s.\n", \
__FILE__,__LINE__,(nam)); \
} \
}

Definition at line 67 of file hdf4utils.h.

◆ READ_GLBL_ATTR_E

#define READ_GLBL_ATTR_E (   nam,
  ptr 
)
Value:
{ \
if(SDreadattr(sd_id,SDfindattr(sd_id,(nam)),(void*)(ptr))){ \
fprintf(stderr, \
"-E- %s line %d: Could not get global attribute, %s.\n", \
__FILE__,__LINE__,(nam)); \
exit(1); \
} \
}

Definition at line 75 of file hdf4utils.h.

◆ READ_SDS

#define READ_SDS (   nam,
  ptr,
  s0,
  s1,
  s2,
  e0,
  e1,
  e2 
)
Value:
{ \
int32_t start[3]; \
int32_t edge[3]; \
edge[0]=(e0); edge[1]=(e1); edge[2]=(e2); \
start[0]=(s0); start[1]=(s1); start[2]=(s2); \
if(SDreaddata(SDselect(sd_id, SDnametoindex(sd_id, (nam))), \
start, NULL, edge, (void*)(ptr)) == FAIL){ \
fprintf(stderr,"-E- %s line %d: Could not read SDS, %s.\n", \
__FILE__,__LINE__,(nam)); \
} \
}

Definition at line 84 of file hdf4utils.h.

◆ READ_SDS_E

#define READ_SDS_E (   nam,
  ptr,
  s0,
  s1,
  s2,
  e0,
  e1,
  e2 
)
Value:
{ \
int32_t start[3]; \
int32_t edge[3]; \
edge[0]=(e0); edge[1]=(e1); edge[2]=(e2); \
start[0]=(s0); start[1]=(s1); start[2]=(s2); \
if(SDreaddata(SDselect(sd_id, SDnametoindex(sd_id, (nam))), \
start, NULL, edge, (void*)(ptr)) == FAIL){ \
fprintf(stderr,"-E- %s line %d: Could not read SDS, %s.\n", \
__FILE__,__LINE__,(nam)); \
exit(1); \
} \
}

Definition at line 96 of file hdf4utils.h.

◆ READ_SDS_ID

#define READ_SDS_ID (   sd_id,
  nam,
  ptr,
  s0,
  s1,
  s2,
  s3,
  e0,
  e1,
  e2,
  e3 
)
Value:
{ \
int32_t start[4]; \
int32_t edge[4]; \
edge[0]=(e0); edge[1]=(e1); edge[2]=(e2); edge[3]=(e3); \
start[0]=(s0); start[1]=(s1); start[2]=(s2); start[3]=(s3); \
if(SDreaddata(SDselect((sd_id), SDnametoindex((sd_id), (nam))), \
start, NULL, edge, (void*)(ptr)) == FAIL){ \
fprintf(stderr,"-E- %s line %d: Could not read SDS, %s.\n", \
__FILE__,__LINE__,(nam)); \
} \
}

Definition at line 109 of file hdf4utils.h.

◆ READ_SDS_ID_E

#define READ_SDS_ID_E (   sd_id,
  nam,
  ptr,
  s0,
  s1,
  s2,
  s3,
  e0,
  e1,
  e2,
  e3 
)
Value:
{ \
int32_t start[4]; \
int32_t edge[4]; \
edge[0]=(e0); edge[1]=(e1); edge[2]=(e2); edge[3]=(e3); \
start[0]=(s0); start[1]=(s1); start[2]=(s2); start[3]=(s3); \
if(SDreaddata(SDselect((sd_id), SDnametoindex((sd_id), (nam))), \
start, NULL, edge, (void*)(ptr)) == FAIL){ \
fprintf(stderr,"-E- %s line %d: Could not read SDS, %s.\n", \
__FILE__,__LINE__,(nam)); \
exit(1); \
} \
}

Definition at line 121 of file hdf4utils.h.

Function Documentation

◆ AddSdsToVgroup()

int AddSdsToVgroup ( int32_t  sd_id,
int32_t  v_id,
const char *  name 
)

Definition at line 383 of file hdf_utils.c.

◆ attach_vdata()

int attach_vdata ( int32_t  fid,
const char *  sname 
)

◆ CreateSDS()

int CreateSDS ( int32_t  sd_id,
const char *  sname,
const char *  lname,
const char *  standard_name,
const char *  units,
double  low,
double  high,
float  slope,
float  offset,
int32_t  nt,
int32_t  rank,
int32_t  d0,
int32_t  d1,
int32_t  d2,
const char *  dn0,
const char *  dn1,
const char *  dn2 
)

Definition at line 77 of file hdf_utils.c.

◆ fmt_hdf_val()

char* fmt_hdf_val ( const void *  array,
const int32_t  i,
const int32_t  ntype 
)

Definition at line 211 of file hdf4_utils.c.

◆ fopen_err()

void fopen_err ( const char *  filename,
const char *  file,
int32_t const  line 
)

Definition at line 266 of file hdf4_utils.c.

◆ fopen_warn()

void fopen_warn ( const char *  filename,
const char *  file,
int32_t const  line 
)

Definition at line 261 of file hdf4_utils.c.

◆ free_sds()

void free_sds ( sds_struct *  sds)

Definition at line 161 of file hdf4_utils.c.

◆ get_hdfeos_meta()

int get_hdfeos_meta ( int32_t  sd_id,
char *  attribute,
char *  name,
char *  data 
)

Definition at line 326 of file hdf4_utils.c.

◆ get_type()

int get_type ( int32_t  fileID,
const char  sdsname[],
int32_t *  dtype 
)

◆ getDims()

int getDims ( int32_t  fileID,
const char  sdsname[],
int32_t  dims[] 
)

◆ GetFileDesc()

char* GetFileDesc ( const char *  filename)

Definition at line 752 of file hdf_utils.c.

◆ getHDFattr()

int getHDFattr ( int32_t  fileID,
const char  attrname[],
const char  sdsname[],
void *  data 
)

◆ hdf_sizeof()

int32_t hdf_sizeof ( int32_t  dtype)

return the sizeof dtype in bytes

Definition at line 28 of file hdf_utils.c.

◆ hdf_typename()

const char* hdf_typename ( const int32_t  ntype)

Definition at line 189 of file hdf4_utils.c.

◆ init_sds_byname()

int init_sds_byname ( int32_t  fileid,
const char *  sdsname,
sds_struct *  sds 
)

Definition at line 92 of file hdf4_utils.c.

◆ load_att_byname()

int load_att_byname ( int32_t  obj_id,
const char *  attname,
att_struct *  att 
)

Definition at line 31 of file hdf4_utils.c.

◆ parse_odl()

int parse_odl ( const char *  odltext,
const char *  object,
char *  value 
)

Definition at line 274 of file hdf4_utils.c.

◆ print_att_info()

void print_att_info ( const att_struct  att)

Definition at line 37 of file hdf4_utils.c.

◆ print_att_vals()

void print_att_vals ( const att_struct  att)

Definition at line 50 of file hdf4_utils.c.

◆ print_sds_info()

void print_sds_info ( const sds_struct  sds)

Definition at line 103 of file hdf4_utils.c.

◆ rdSDS()

int rdSDS ( int32_t  fileID,
const char  sdsname[],
int32_t  start1,
int32_t  start2,
int32_t  edges1,
int32_t  edges2,
void *  array_data 
)

◆ rdvdata()

int rdvdata ( int32_t  vskey,
const char *  fields,
int32_t  start,
int32_t  nelt,
unsigned char *  databuf 
)

◆ read_SDS()

int32_t read_SDS ( int32_t  sdfid,
const char *  sds_name,
void *  buffer 
)

◆ readall_sds()

int readall_sds ( sds_struct *  sds)

Definition at line 138 of file hdf4_utils.c.

◆ sd_create()

int sd_create ( int32_t  id,
const char *  nam,
int32_t  typ,
int32_t  rank,
int32_t  d0,
int32_t  d1,
int32_t  d2,
int32_t *  sds_id 
)

Definition at line 227 of file hdf_utils.c.

◆ sd_endaccess()

int sd_endaccess ( int32_t  id)

Definition at line 255 of file hdf_utils.c.

◆ sd_readdata()

int sd_readdata ( int32_t  sd_id,
const char *  name,
void *  data,
int32_t  s0,
int32_t  s1,
int32_t  s2,
int32_t  e0,
int32_t  e1,
int32_t  e2 
)

◆ sd_select()

int sd_select ( int32_t  sd_id,
const char *  name,
int32_t *  sds_id 
)

Definition at line 355 of file hdf_utils.c.

◆ sd_setattr()

int sd_setattr ( int32_t  id,
const char *  nam,
int32_t  typ,
int32_t  cnt,
const void *  data 
)

Definition at line 216 of file hdf_utils.c.

◆ sd_setdimname()

int sd_setdimname ( int32_t  sds_id,
int32_t  dim_number,
const char *  name 
)

Definition at line 275 of file hdf_utils.c.

◆ sd_setdimnames()

int sd_setdimnames ( int32_t  id,
const char *  d0,
const char *  d1,
const char *  d2 
)

Definition at line 264 of file hdf_utils.c.

◆ sd_writedata()

int sd_writedata ( int32_t  sd_id,
const char *  name,
const void *  data,
int32_t  s0,
int32_t  s1,
int32_t  s2,
int32_t  e0,
int32_t  e1,
int32_t  e2 
)

Definition at line 293 of file hdf_utils.c.

◆ v_attach()

int v_attach ( int32_t  h_id,
int32_t *  v_id 
)

Definition at line 404 of file hdf_utils.c.

#define FAIL
Definition: ObpgReadGrid.h:18
#define NULL
Definition: decode_rs.h:63