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 COPYING file, which can be found at the root of the source code *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/. *
10  * If you do not have access to either file, you may request a copy from *
11  * help@hdfgroup.org. *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /* $Id$ */
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, uintn buf_size, char *ext_filename, int32 *offset, int32 *length);
175 
177  (int32 id, const char *filename, int32 offset);
178 
180  (int32 id, intn start_bit, intn bit_len, intn sign_ext, intn fill_one);
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, comp_info *c_info);
190 
192  (int32 id, comp_coder_t* type);
193 
194 HDFLIBAPI int32 SDfindattr
195  (int32 id, const char *attrname);
196 
197 HDFLIBAPI int32 SDidtoref
198  (int32 id);
199 
201  (int32 fid, int32 ref);
202 
203 HDFLIBAPI int32 SDisrecord
204  (int32 id);
205 
207  (int32 id);
208 
210  (int32 id, uintn accesstype);
211 
213  (int32 sdsid, int32 block_size);
214 
216  (int32 sdsid, int32 *block_size);
217 
219  (int32 dimid, intn compt_mode);
220 
222  (int32 dimid);
223 
225  (int32 sdsid, intn *emptySDS);
226 
228  (int32 an_id);
229 
231  (intn req_max);
232 
234  (intn *curr_max, intn *sys_limit);
235 
237  ();
238 
240  (int32 sdsid, int32 *comp_size, int32 *uncomp_size);
241 
243  (int32 fid, char *filename);
244 
246  (int32 sdsid, uint16 *name_len);
247 
248 /*====================== Chunking Routines ================================*/
249 
250 /* For defintion of HDF_CHUNK_DEF union see hproto.h since
251  this defintion is also used by GRs. */
252 
253 /******************************************************************************
254  NAME
255  SDsetchunk -- make SDS a chunked SDS
256 
257  DESCRIPTION
258  This routine makes the SDS a chunked SDS according to the chunk
259  definition passed in.
260 
261  The dataset currently cannot be special already. i.e. NBIT,
262  COMPRESSED, or EXTERNAL. This is an Error.
263 
264  The defintion of the HDF_CHUNK_DEF union with relvant fields is:
265 
266  typedef union hdf_chunk_def_u
267  {
268  int32 chunk_lengths[H4_MAX_VAR_DIMS]; Chunk lengths along each dimension
269 
270  struct
271  {
272  int32 chunk_lengths[H4_MAX_VAR_DIMS]; Chunk lengths along each dimension
273  int32 comp_type; Compression type
274  comp_info cinfo; Compression info struct
275  }comp;
276 
277  } HDF_CHUNK_DEF
278 
279  The simplist is the 'chunk_lengths' array specifiying chunk
280  lengths for each dimension where the 'flags' argument set to
281  'HDF_CHUNK';
282 
283  COMPRESSION is set by using the 'HDF_CHUNK_DEF' structure to set the
284  appropriate compression information along with the required chunk lengths
285  for each dimension. The compression information is the same as
286  that set in 'SDsetcompress()'. The bit-or'd'flags' argument' is set to
287  'HDF_CHUNK | HDF_COMP'.
288 
289  See the example in pseudo-C below for further usage.
290 
291  The maximum number of Chunks in an HDF file is 65,535.
292 
293  The dataset currently cannot have an UNLIMITED dimension.
294 
295  The performance of the SDxxx interface with chunking is greatly
296  affected by the users access pattern over the dataset and by
297  the maximum number of chunks set in the chunk cache. The cache contains
298  the Least Recently Used(LRU cache replacment policy) chunks. See the
299  routine SDsetchunkcache() for further info on the chunk cache and how
300  to set the maximum number of chunks in the chunk cache. A default chunk
301  cache is always created.
302 
303  The following example shows the organization of chunks for a 2D array.
304  e.g. 4x4 array with 2x2 chunks. The array shows the layout of
305  chunks in the chunk array.
306 
307  4 ---------------------
308  | | |
309  Y | (0,1) | (1,1) |
310  ^ | | |
311  | 2 ---------------------
312  | | | |
313  | | (0,0) | (1,0) |
314  | | | |
315  | ---------------------
316  | 0 2 4
317  ---------------> X
318 
319  --Without compression--:
320  {
321  HDF_CHUNK_DEF chunk_def;
322 
323  .......
324  -- Set chunk lengths --
325  chunk_def.chunk_lengths[0]= 2;
326  chunk_def.chunk_lengths[1]= 2;
327 
328  -- Set Chunking --
329  SDsetchunk(sdsid, chunk_def, HDF_CHUNK);
330  ......
331  }
332 
333  --With compression--:
334  {
335  HDF_CHUNK_DEF chunk_def;
336 
337  .......
338  -- Set chunk lengths first --
339  chunk_def.chunk_lengths[0]= 2;
340  chunk_def.chunk_lengths[1]= 2;
341 
342  -- Set compression --
343  chunk_def.comp.cinfo.deflate.level = 9;
344  chunk_def.comp.comp_type = COMP_CODE_DEFLATE;
345 
346  -- Set Chunking with Compression --
347  SDsetchunk(sdsid, chunk_def, HDF_CHUNK | HDF_COMP);
348  ......
349  }
350 
351  RETURNS
352  SUCCEED/FAIL
353 ******************************************************************************/
355  (int32 sdsid, /* IN: sds access id */
356  HDF_CHUNK_DEF chunk_def, /* IN: chunk definition */
357  int32 flags /* IN: flags */);
358 
359 /******************************************************************************
360  NAME
361  SDgetchunkinfo -- get Info on SDS
362 
363  DESCRIPTION
364  This routine gets any special information on the SDS. If its chunked,
365  chunked and compressed or just a regular SDS. Currently it will only
366  fill the array of chunk lengths for each dimension as specified in
367  the 'HDF_CHUNK_DEF' union. It does not tell you the type of compression
368  used or the compression parameters. You can pass in a NULL for 'chunk_def'
369  if don't want the chunk lengths for each dimension.
370  Additionaly if successfull it will return a bit-or'd value in 'flags'
371  indicating if the SDS is:
372 
373  Chunked -> flags = HDF_CHUNK
374  Chunked and compressed -> flags = HDF_CHUNK | HDF_COMP
375  Non-chunked -> flags = HDF_NONE
376 
377  e.g. 4x4 array - Pseudo-C
378  {
379  int32 rcdims[3];
380  HDF_CHUNK_DEF rchunk_def;
381  int32 cflags;
382  ...
383  rchunk_def.chunk_lengths = rcdims;
384  SDgetchunkinfo(sdsid, &rchunk_def, &cflags);
385  ...
386  }
387 
388  RETURNS
389  SUCCEED/FAIL
390 ******************************************************************************/
392  (int32 sdsid, /* IN: sds access id */
393  HDF_CHUNK_DEF *chunk_def, /* IN/OUT: chunk definition */
394  int32 *flags /* IN/OUT: flags */);
395 
396 /******************************************************************************
397  NAME
398  SDwritechunk -- write the specified chunk to the SDS
399 
400  DESCRIPTION
401  This routine writes a whole chunk of data to the chunked SDS
402  specified by chunk 'origin' for the given SDS and can be used
403  instead of SDwritedata() when this information is known. This
404  routine has less overhead and is much faster than using SDwritedata().
405 
406  Origin specifies the co-ordinates of the chunk according to the chunk
407  position in the overall chunk array.
408 
409  'datap' must point to a whole chunk of data.
410 
411  See SDsetchunk() for a description of the organization of chunks in an SDS.
412 
413  RETURNS
414  SUCCEED/FAIL
415 ******************************************************************************/
417  (int32 sdsid, /* IN: sds access id */
418  int32 *origin, /* IN: origin of chunk to write */
419  const void *datap /* IN: buffer for data */);
420 
421 /******************************************************************************
422  NAME
423  SDreadchunk -- read the specified chunk to the SDS
424 
425  DESCRIPTION
426  This routine reads a whole chunk of data from the chunked SDS
427  specified by chunk 'origin' for the given SDS and can be used
428  instead of SDreaddata() when this information is known. This
429  routine has less overhead and is much faster than using SDreaddata().
430 
431  Origin specifies the co-ordinates of the chunk according to the chunk
432  position in the overall chunk array.
433 
434  'datap' must point to a whole chunk of data.
435 
436  See SDsetchunk() for a description of the organization of chunks in an SDS.
437 
438  RETURNS
439  SUCCEED/FAIL
440 ******************************************************************************/
442  (int32 sdsid, /* IN: sds access id */
443  int32 *origin, /* IN: origin of chunk to read */
444  void *datap /* IN/OUT: buffer for data */);
445 
446 /******************************************************************************
447 NAME
448  SDsetchunkcache -- maximum number of chunks to cache
449 
450 DESCRIPTION
451  Set the maximum number of chunks to cache.
452 
453  The cache contains the Least Recently Used(LRU cache replacment policy)
454  chunks. This routine allows the setting of maximum number of chunks that
455  can be cached, 'maxcache'.
456 
457  The performance of the SDxxx interface with chunking is greatly
458  affected by the users access pattern over the dataset and by
459  the maximum number of chunks set in the chunk cache. The number chunks
460  that can be set in the cache is process memory limited. It is a good
461  idea to always set the maximum number of chunks in the cache as the
462  default heuristic does not take into account the memory available for
463  the application.
464 
465  By default when the SDS is promoted to a chunked element the
466  maximum number of chunks in the cache 'maxcache' is set to the number of
467  chunks along the last dimension.
468 
469  The values set here affects the current object's caching behaviour.
470 
471  If the chunk cache is full and 'maxcache' is greater then the
472  current 'maxcache' value, then the chunk cache is reset to the new
473  'maxcache' value, else the chunk cache remains at the current
474  'maxcache' value.
475 
476  If the chunk cache is not full, then the chunk cache is set to the
477  new 'maxcache' value only if the new 'maxcache' value is greater than the
478  current number of chunks in the cache.
479 
480  Use flags argument of 'HDF_CACHEALL' if the whole object is to be cached
481  in memory, otherwise pass in zero(0). Currently you can only
482  pass in zero.
483 
484  See SDsetchunk() for a description of the organization of chunks in an SDS.
485 
486 RETURNS
487  Returns the 'maxcache' value for the chunk cache if successful
488  and FAIL otherwise
489 ******************************************************************************/
491  (int32 sdsid, /* IN: sds access id */
492  int32 maxcache, /* IN: max number of chunks to cache */
493  int32 flags /* IN: flags = 0, HDF_CACHEALL */);
494 
495 
496 #ifdef __cplusplus
497 }
498 #endif
499 
500 #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)
HDFLIBAPI intn SDgetexternalinfo(int32 id, uintn buf_size, char *ext_filename, int32 *offset, int32 *length)
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 SDgetblocksize(int32 sdsid, int32 *block_size)
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