MISR Toolkit  1.5.1
mfhdf.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group. *
3  * Copyright by the Board of Trustees of the University of Illinois. *
4  * All rights reserved. *
5  * *
6  * This file is part of HDF. The full HDF copyright notice, including *
7  * terms governing use, modification, and redistribution, is contained in *
8  * the files COPYING and Copyright.html. COPYING can be found at the root *
9  * of the source code distribution tree; Copyright.html can be found at *
10  * http://hdfgroup.org/products/hdf4/doc/Copyright.html. If you do not have *
11  * access to either file, you may request a copy from help@hdfgroup.org. *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /* $Id: mfhdf.h 5648 2011-06-09 05:18:42Z bmribler $ */
15 
16 #ifndef _MFSD_H_
17 #define _MFSD_H_
18 
19 #ifndef HDF
20 #define HDF 1
21 #endif
22 
23 #include "H4api_adpt.h"
24 
25 /* change this back if it causes problems on other machines than the Alhpa-QAK */
26 /* Reverse back to the previous way. AKC */
27 #include "hdf.h"
28 #ifdef H4_HAVE_NETCDF
29 #include "netcdf.h"
30 #else
31 #include "hdf4_netcdf.h"
32 #endif
33 #ifdef OLD_WAY
34 #include "local_nc.h"
35 #endif /* OLD_WAY */
36 
37 #include "mfhdfi.h"
38 #include "mfdatainfo.h"
39 
40 #define SD_UNLIMITED NC_UNLIMITED /* use this as marker for unlimited dimension */
41 #define SD_NOFILL NC_NOFILL
42 #define SD_FILL NC_FILL
43 #define SD_DIMVAL_BW_COMP 1
44 #define SD_DIMVAL_BW_INCOMP 0
45 #define SD_RAGGED -1 /* marker for ragged dimension */
46 
47 /* used to indicate the type of the variable at an index */
48 typedef struct hdf_varlist
49 {
50  int32 var_index; /* index of the current variable */
51  hdf_vartype_t var_type; /* type of a variable (IS_SDSVAR, IS_CRDVAR, or UNKNOWN */
53 
54 /* enumerated types for various types of ids in SD interface */
55 typedef enum
56 {
57  NOT_SDAPI_ID = -1, /* not an SD API id */
58  SD_ID = 0, /* SD id */
59  SDS_ID, /* SDS id */
60  DIM_ID /* Dimension id */
61 } hdf_idtype_t;
62 
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66 
67 HDFLIBAPI int32 SDstart
68  (const char *name, int32 accs);
69 
70 HDFLIBAPI intn SDend
71  (int32 fid);
72 
74  (int32 fid, int32 *datasets, int32 *attrs);
75 
76 HDFLIBAPI int32 SDselect
77  (int32 fid, int32 idx);
78 
80  (int32 sdsid, char *name, int32 *rank, int32 *dimsizes,
81  int32 *nt, int32 *nattr);
82 
83 #ifndef __CSTAR__
85  (int32 sdsid, int32 *start, int32 *stride, int32 *end, void * data);
86 #endif
87 
89  (int32 sdsid);
90 
92  (int32 fid, const char *name);
93 
95  (int32 fid, const char *name, hdf_varlist_t *var_list);
96 
98  (int32 fid, const char *name, int32 *n_vars);
99 
101  (int32 sdsid, void * pmax, void * pmin);
102 
103 HDFLIBAPI int32 SDcreate
104  (int32 fid, const char *name, int32 nt, int32 rank, int32 *dimsizes);
105 
106 HDFLIBAPI int32 SDgetdimid
107  (int32 sdsid, intn number);
108 
110  (int32 id, const char *name);
111 
113  (int32 id);
114 
116  (int32 sdsid, void * pmax, void * pmin);
117 
118 HDFLIBAPI intn SDsetattr
119  (int32 id, const char *name, int32 nt, int32 count, const void * data);
120 
122  (int32 id, int32 idx, char *name, int32 *nt, int32 *count);
123 
125  (int32 id, int32 idx, void * buf);
126 
127 #ifndef __CSTAR__
129  (int32 sdsid, int32 *start, int32 *stride, int32 *end, void * data);
130 #endif
131 
133  (int32 sdsid, const char *l, const char *u, const char *f, const char *c);
134 
135 HDFLIBAPI intn SDsetcal
136  (int32 sdsid, float64 cal, float64 cale, float64 ioff,
137  float64 ioffe, int32 nt);
138 
140  (int32 sdsid, void * val);
141 
143  (int32 sdsid, void * val);
144 
146  (int32 id, intn fillmode);
147 
149  (int32 sdsid, char *l, char *u, char *f, char *c, intn len);
150 
151 HDFLIBAPI intn SDgetcal
152  (int32 sdsid, float64 *cal, float64 *cale, float64 *ioff,
153  float64 *ioffe, int32 *nt);
154 
156  (int32 id, const char *l, const char *u, const char *f);
157 
159  (int32 id, int32 count, int32 nt, void * data);
160 
162  (int32 id, void * data);
163 
164 HDFLIBAPI intn SDdiminfo
165  (int32 id, char *name, int32 *size, int32 *nt, int32 *nattr);
166 
168  (int32 id, char *l, char *u, char *f, intn len);
169 
171  (int32 id, intn buf_size, char *ext_filename, int32 *offset);
172 
174  (int32 id, const char *filename, int32 offset);
175 
177  (int32 id, intn start_bit, intn bit_len, intn sign_ext, intn fill_one);
178 
180  (int32 id, comp_coder_t type, comp_info *c_info);
181 
183  (int32 id, comp_coder_t* type, comp_info *c_info);
184 
186  (int32 id, comp_coder_t* type, comp_info *c_info);
187 
189  (int32 id, comp_coder_t* type);
190 
191 HDFLIBAPI int32 SDfindattr
192  (int32 id, const char *attrname);
193 
194 HDFLIBAPI int32 SDidtoref
195  (int32 id);
196 
198  (int32 fid, int32 ref);
199 
200 HDFLIBAPI int32 SDisrecord
201  (int32 id);
202 
204  (int32 id);
205 
207  (int32 id, uintn accesstype);
208 
210  (int32 sdsid, int32 block_size);
211 
213  (int32 dimid, intn compt_mode);
214 
216  (int32 dimid);
217 
219  (int32 sdsid, intn *emptySDS);
220 
222  (int32 an_id);
223 
225  (intn req_max);
226 
228  (intn *curr_max, intn *sys_limit);
229 
231  ();
232 
234  (int32 sdsid, int32 *comp_size, int32 *uncomp_size);
235 
237  (int32 fid, char *filename);
238 
240  (int32 sdsid, uint16 *name_len);
241 
242 /*====================== Chunking Routines ================================*/
243 
244 /* For defintion of HDF_CHUNK_DEF union see hproto.h since
245  this defintion is also used by GRs. */
246 
247 /******************************************************************************
248  NAME
249  SDsetchunk -- make SDS a chunked SDS
250 
251  DESCRIPTION
252  This routine makes the SDS a chunked SDS according to the chunk
253  definition passed in.
254 
255  The dataset currently cannot be special already. i.e. NBIT,
256  COMPRESSED, or EXTERNAL. This is an Error.
257 
258  The defintion of the HDF_CHUNK_DEF union with relvant fields is:
259 
260  typedef union hdf_chunk_def_u
261  {
262  int32 chunk_lengths[H4_MAX_VAR_DIMS]; Chunk lengths along each dimension
263 
264  struct
265  {
266  int32 chunk_lengths[H4_MAX_VAR_DIMS]; Chunk lengths along each dimension
267  int32 comp_type; Compression type
268  comp_info cinfo; Compression info struct
269  }comp;
270 
271  } HDF_CHUNK_DEF
272 
273  The simplist is the 'chunk_lengths' array specifiying chunk
274  lengths for each dimension where the 'flags' argument set to
275  'HDF_CHUNK';
276 
277  COMPRESSION is set by using the 'HDF_CHUNK_DEF' structure to set the
278  appropriate compression information along with the required chunk lengths
279  for each dimension. The compression information is the same as
280  that set in 'SDsetcompress()'. The bit-or'd'flags' argument' is set to
281  'HDF_CHUNK | HDF_COMP'.
282 
283  See the example in pseudo-C below for further usage.
284 
285  The maximum number of Chunks in an HDF file is 65,535.
286 
287  The dataset currently cannot have an UNLIMITED dimension.
288 
289  The performance of the SDxxx interface with chunking is greatly
290  affected by the users access pattern over the dataset and by
291  the maximum number of chunks set in the chunk cache. The cache contains
292  the Least Recently Used(LRU cache replacment policy) chunks. See the
293  routine SDsetchunkcache() for further info on the chunk cache and how
294  to set the maximum number of chunks in the chunk cache. A default chunk
295  cache is always created.
296 
297  The following example shows the organization of chunks for a 2D array.
298  e.g. 4x4 array with 2x2 chunks. The array shows the layout of
299  chunks in the chunk array.
300 
301  4 ---------------------
302  | | |
303  Y | (0,1) | (1,1) |
304  ^ | | |
305  | 2 ---------------------
306  | | | |
307  | | (0,0) | (1,0) |
308  | | | |
309  | ---------------------
310  | 0 2 4
311  ---------------> X
312 
313  --Without compression--:
314  {
315  HDF_CHUNK_DEF chunk_def;
316 
317  .......
318  -- Set chunk lengths --
319  chunk_def.chunk_lengths[0]= 2;
320  chunk_def.chunk_lengths[1]= 2;
321 
322  -- Set Chunking --
323  SDsetchunk(sdsid, chunk_def, HDF_CHUNK);
324  ......
325  }
326 
327  --With compression--:
328  {
329  HDF_CHUNK_DEF chunk_def;
330 
331  .......
332  -- Set chunk lengths first --
333  chunk_def.chunk_lengths[0]= 2;
334  chunk_def.chunk_lengths[1]= 2;
335 
336  -- Set compression --
337  chunk_def.comp.cinfo.deflate.level = 9;
338  chunk_def.comp.comp_type = COMP_CODE_DEFLATE;
339 
340  -- Set Chunking with Compression --
341  SDsetchunk(sdsid, chunk_def, HDF_CHUNK | HDF_COMP);
342  ......
343  }
344 
345  RETURNS
346  SUCCEED/FAIL
347 ******************************************************************************/
349  (int32 sdsid, /* IN: sds access id */
350  HDF_CHUNK_DEF chunk_def, /* IN: chunk definition */
351  int32 flags /* IN: flags */);
352 
353 /******************************************************************************
354  NAME
355  SDgetchunkinfo -- get Info on SDS
356 
357  DESCRIPTION
358  This routine gets any special information on the SDS. If its chunked,
359  chunked and compressed or just a regular SDS. Currently it will only
360  fill the array of chunk lengths for each dimension as specified in
361  the 'HDF_CHUNK_DEF' union. It does not tell you the type of compression
362  used or the compression parameters. You can pass in a NULL for 'chunk_def'
363  if don't want the chunk lengths for each dimension.
364  Additionaly if successfull it will return a bit-or'd value in 'flags'
365  indicating if the SDS is:
366 
367  Chunked -> flags = HDF_CHUNK
368  Chunked and compressed -> flags = HDF_CHUNK | HDF_COMP
369  Non-chunked -> flags = HDF_NONE
370 
371  e.g. 4x4 array - Pseudo-C
372  {
373  int32 rcdims[3];
374  HDF_CHUNK_DEF rchunk_def;
375  int32 cflags;
376  ...
377  rchunk_def.chunk_lengths = rcdims;
378  SDgetchunkinfo(sdsid, &rchunk_def, &cflags);
379  ...
380  }
381 
382  RETURNS
383  SUCCEED/FAIL
384 ******************************************************************************/
386  (int32 sdsid, /* IN: sds access id */
387  HDF_CHUNK_DEF *chunk_def, /* IN/OUT: chunk definition */
388  int32 *flags /* IN/OUT: flags */);
389 
390 /******************************************************************************
391  NAME
392  SDwritechunk -- write the specified chunk to the SDS
393 
394  DESCRIPTION
395  This routine writes a whole chunk of data to the chunked SDS
396  specified by chunk 'origin' for the given SDS and can be used
397  instead of SDwritedata() when this information is known. This
398  routine has less overhead and is much faster than using SDwritedata().
399 
400  Origin specifies the co-ordinates of the chunk according to the chunk
401  position in the overall chunk array.
402 
403  'datap' must point to a whole chunk of data.
404 
405  See SDsetchunk() for a description of the organization of chunks in an SDS.
406 
407  RETURNS
408  SUCCEED/FAIL
409 ******************************************************************************/
411  (int32 sdsid, /* IN: sds access id */
412  int32 *origin, /* IN: origin of chunk to write */
413  const void *datap /* IN: buffer for data */);
414 
415 /******************************************************************************
416  NAME
417  SDreadchunk -- read the specified chunk to the SDS
418 
419  DESCRIPTION
420  This routine reads a whole chunk of data from the chunked SDS
421  specified by chunk 'origin' for the given SDS and can be used
422  instead of SDreaddata() when this information is known. This
423  routine has less overhead and is much faster than using SDreaddata().
424 
425  Origin specifies the co-ordinates of the chunk according to the chunk
426  position in the overall chunk array.
427 
428  'datap' must point to a whole chunk of data.
429 
430  See SDsetchunk() for a description of the organization of chunks in an SDS.
431 
432  RETURNS
433  SUCCEED/FAIL
434 ******************************************************************************/
436  (int32 sdsid, /* IN: sds access id */
437  int32 *origin, /* IN: origin of chunk to read */
438  void *datap /* IN/OUT: buffer for data */);
439 
440 /******************************************************************************
441 NAME
442  SDsetchunkcache -- maximum number of chunks to cache
443 
444 DESCRIPTION
445  Set the maximum number of chunks to cache.
446 
447  The cache contains the Least Recently Used(LRU cache replacment policy)
448  chunks. This routine allows the setting of maximum number of chunks that
449  can be cached, 'maxcache'.
450 
451  The performance of the SDxxx interface with chunking is greatly
452  affected by the users access pattern over the dataset and by
453  the maximum number of chunks set in the chunk cache. The number chunks
454  that can be set in the cache is process memory limited. It is a good
455  idea to always set the maximum number of chunks in the cache as the
456  default heuristic does not take into account the memory available for
457  the application.
458 
459  By default when the SDS is promoted to a chunked element the
460  maximum number of chunks in the cache 'maxcache' is set to the number of
461  chunks along the last dimension.
462 
463  The values set here affects the current object's caching behaviour.
464 
465  If the chunk cache is full and 'maxcache' is greater then the
466  current 'maxcache' value, then the chunk cache is reset to the new
467  'maxcache' value, else the chunk cache remains at the current
468  'maxcache' value.
469 
470  If the chunk cache is not full, then the chunk cache is set to the
471  new 'maxcache' value only if the new 'maxcache' value is greater than the
472  current number of chunks in the cache.
473 
474  Use flags argument of 'HDF_CACHEALL' if the whole object is to be cached
475  in memory, otherwise pass in zero(0). Currently you can only
476  pass in zero.
477 
478  See SDsetchunk() for a description of the organization of chunks in an SDS.
479 
480 RETURNS
481  Returns the 'maxcache' value for the chunk cache if successful
482  and FAIL otherwise
483 ******************************************************************************/
485  (int32 sdsid, /* IN: sds access id */
486  int32 maxcache, /* IN: max number of chunks to cache */
487  int32 flags /* IN: flags = 0, HDF_CACHEALL */);
488 
489 
490 #ifdef __cplusplus
491 }
492 #endif
493 
494 #endif /* _MFSD_H_ */
HDFLIBAPI int32 SDnametoindex(int32 fid, const char *name)
HDFFCLIBAPI intf intf intf * count
HDFLIBAPI intn SDsetdimname(int32 id, const char *name)
HDFFCLIBAPI intf * len
HDFLIBAPI intn SDgetexternalfile(int32 id, intn buf_size, char *ext_filename, int32 *offset)
HDFFCLIBAPI intf * block_size
HDFLIBAPI intn SDgetfillvalue(int32 sdsid, void *val)
HDFLIBAPI intn SDsetcompress(int32 id, comp_coder_t type, comp_info *c_info)
HDFFCLIBAPI intf * idx
HDFLIBAPI int32 SDcheckempty(int32 sdsid, intn *emptySDS)
char * filename
Definition: cdjpeg.h:133
HDFLIBAPI intn SDgetdimscale(int32 id, void *data)
HDFLIBAPI intn SDgetrange(int32 sdsid, void *pmax, void *pmin)
HDFLIBAPI uint16 SDgerefnumber(int32 sdsid)
HDFLIBAPI intn SDsetaccesstype(int32 id, uintn accesstype)
HDFLIBAPI intn SDgetnamelen(int32 sdsid, uint16 *name_len)
HDFLIBAPI intn SDisdimval_bwcomp(int32 dimid)
HDFLIBAPI int32 SDgetdimid(int32 sdsid, intn number)
HDFLIBAPI intn SDreaddata(int32 sdsid, int32 *start, int32 *stride, int32 *end, void *data)
HDFFCLIBAPI float64 float64 * ioff
HDFFCLIBAPI intf * accesstype
HDFLIBAPI intn SDsetnbitdataset(int32 id, intn start_bit, intn bit_len, intn sign_ext, intn fill_one)
void origin(double A)
HDFLIBAPI int32 SDidtoref(int32 id)
HDFLIBAPI intn SDsetcal(int32 sdsid, float64 cal, float64 cale, float64 ioff, float64 ioffe, int32 nt)
HDFLIBAPI intn SDiscoordvar(int32 id)
HDFLIBAPI intn SDsetfillmode(int32 id, intn fillmode)
HDFFCLIBAPI intf dimsizes[]
HDFLIBAPI intn SDgetcomptype(int32 id, comp_coder_t *type)
HDFLIBAPI intn SDendaccess(int32 id)
HDFLIBAPI hdf_idtype_t SDidtype(int32 an_id)
HDFFCLIBAPI intf intf _fcd attrname
HDFLIBAPI intn SDgetcal(int32 sdsid, float64 *cal, float64 *cale, float64 *ioff, float64 *ioffe, int32 *nt)
HDFLIBAPI int32 SDstart(const char *name, int32 accs)
hdf_vartype_t
Definition: mfhdfi.h:21
HDFLIBAPI intn SDreset_maxopenfiles(intn req_max)
HDFFCLIBAPI intf * maxcache
HDFLIBAPI intn SDdiminfo(int32 id, char *name, int32 *size, int32 *nt, int32 *nattr)
Definition: mfhdf.h:59
HDFLIBAPI intn SDreadattr(int32 id, int32 idx, void *buf)
HDFLIBAPI intn SDget_numopenfiles()
HDFFCLIBAPI _fcd intf intf * nt
HDFLIBAPI intn SDgetcompress(int32 id, comp_coder_t *type, comp_info *c_info)
HDFFCLIBAPI void * pmin
HDFLIBAPI intn SDsetchunkcache(int32 sdsid, int32 maxcache, int32 flags)
HDFFCLIBAPI _fcd name
HDFLIBAPI intn SDgetinfo(int32 sdsid, char *name, int32 *rank, int32 *dimsizes, int32 *nt, int32 *nattr)
HDFFCLIBAPI intf intf * ref
hdf_idtype_t
Definition: mfhdf.h:55
HDFLIBAPI intn SDnametoindices(int32 fid, const char *name, hdf_varlist_t *var_list)
HDFLIBAPI intn SDend(int32 fid)
HDFLIBAPI int32 SDcreate(int32 fid, const char *name, int32 nt, int32 rank, int32 *dimsizes)
HDFLIBAPI intn SDgetfilename(int32 fid, char *filename)
comp_coder_t
Definition: hcomp.h:38
HDFFCLIBAPI intf * size
HDFLIBAPI intn SDsetdimstrs(int32 id, const char *l, const char *u, const char *f)
HDFLIBAPI intn SDsetdimval_comp(int32 dimid, intn compt_mode)
Definition: mfhdf.h:58
HDFLIBAPI int32 SDselect(int32 fid, int32 idx)
HDFLIBAPI intn SDgetchunkinfo(int32 sdsid, HDF_CHUNK_DEF *chunk_def, int32 *flags)
HDFLIBAPI intn SDsetattr(int32 id, const char *name, int32 nt, int32 count, const void *data)
HDFLIBAPI int32 SDfindattr(int32 id, const char *attrname)
HDFLIBAPI intn SDget_maxopenfiles(intn *curr_max, intn *sys_limit)
HDFLIBAPI intn SDwritechunk(int32 sdsid, int32 *origin, const void *datap)
HDFLIBAPI intn SDgetdimstrs(int32 id, char *l, char *u, char *f, intn len)
hdf_vartype_t var_type
Definition: mfhdf.h:51
HDFLIBAPI intn SDgetcompinfo(int32 id, comp_coder_t *type, comp_info *c_info)
int32 var_index
Definition: mfhdf.h:50
HDFLIBAPI intn SDsetrange(int32 sdsid, void *pmax, void *pmin)
HDFFCLIBAPI _fcd intf intf intf intf intf * nattr
HDFLIBAPI intn SDattrinfo(int32 id, int32 idx, char *name, int32 *nt, int32 *count)
HDFFCLIBAPI intf intf start[]
HDFFCLIBAPI void * data
HDFLIBAPI intn SDfileinfo(int32 fid, int32 *datasets, int32 *attrs)
HDFLIBAPI intn SDsetblocksize(int32 sdsid, int32 block_size)
HDFLIBAPI intn SDgetdatasize(int32 sdsid, int32 *comp_size, int32 *uncomp_size)
HDFLIBAPI intn SDsetexternalfile(int32 id, const char *filename, int32 offset)
struct hdf_varlist hdf_varlist_t
HDFLIBAPI intn SDreadchunk(int32 sdsid, int32 *origin, void *datap)
HDFFCLIBAPI intf intf intf * type
HDFFCLIBAPI intf intf * flags
HDFLIBAPI intn SDsetfillvalue(int32 sdsid, void *val)
HDFLIBAPI intn SDsetchunk(int32 sdsid, HDF_CHUNK_DEF chunk_def, int32 flags)
HDFFCLIBAPI intf stride[]
#define HDFLIBAPI
Definition: H4api_adpt.h:195
HDFLIBAPI int32 SDisrecord(int32 id)
HDFFCLIBAPI intf * offset
int val
Definition: jpeglib.h:956
HDFFCLIBAPI intf * rank
HDFLIBAPI intn SDsetdimscale(int32 id, int32 count, int32 nt, void *data)
HDFLIBAPI intn SDwritedata(int32 sdsid, int32 *start, int32 *stride, int32 *end, void *data)
Definition: mfhdf.h:60
HDFFCLIBAPI intf * buf
HDFLIBAPI intn SDgetnumvars_byname(int32 fid, const char *name, int32 *n_vars)
HDFLIBAPI int32 SDreftoindex(int32 fid, int32 ref)
HDFLIBAPI intn SDgetdatastrs(int32 sdsid, char *l, char *u, char *f, char *c, intn len)
HDFLIBAPI intn SDsetdatastrs(int32 sdsid, const char *l, const char *u, const char *f, const char *c)

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:52