Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HDF4 Class Referenceabstract

A class to serialize HDF calls for multithreaded apps. More...

#include <HDF4.h>

Public Member Functions

virtual ~HDF4 ()=0
 
virtual ~HDF4 ()=0
 

Static Public Member Functions

static void init ()
 Create and start the I/O thread. More...
 
static void finalize ()
 Destroy the I/O thread. More...
 
static int32 Select (int32 sd_id, int32 &index, char *name, int32 *rank, int32 *size, int32 *dType, int32 *nAttrs, int32 dsCount=-1)
 "Open" and "close" HDF files efficiently. More...
 
static int SizeOf (int32 dType)
 Get the size in bytes of an HDF data type. More...
 
static void Terminate ()
 Terminate the I/O thread. More...
 
static std::string error_msg ()
 return error message More...
 
static void init ()
 Create and start the I/O thread. More...
 
static void finalize ()
 Destroy the I/O thread. More...
 
static int32 Select (int32 sd_id, int32 &index, char *name, int32 *rank, int32 *size, int32 *dType, int32 *nAttrs, int32 dsCount=-1)
 "Open" and "close" HDF files efficiently. More...
 
static int SizeOf (int32 dType)
 Get the size in bytes of an HDF data type. More...
 
static void Terminate ()
 Terminate the I/O thread. More...
 
static std::string error_msg ()
 return error message More...
 
static intn Hishdf (const char *filename)
 HDF4 wrapper functions. More...
 
static int32 SDstart (const char *filename, int32 accessMode)
 
static intn SDend (int32 sd_id)
 
static intn SDfileinfo (int32 id, int32 *dsCount, int32 *nAttrs)
 
static int32 SDcreate (int32 sd_id, const char *name, int32 dType, int32 rank, int32 *size)
 
static int32 SDselect (int32 sd_id, int32 index)
 
static intn SDendaccess (int32 sds_id)
 
static int32 SDfindattr (int32 id, const char *attrName)
 
static intn SDgetinfo (int32 sds_id, char *name, int32 *rank, int32 *size, int32 *dType, int32 *nAttrs)
 
static intn SDsetdatastrs (int32 sds_id, const char *label, const char *units, const char *format, const char *coordsys)
 
static intn SDgetdatastrs (int32 sds_id, char *label, char *units, char *format, char *coordsys, intn length)
 
static intn SDsetrange (int32 sds_id, VOIDP max, VOIDP min)
 
static intn SDgetrange (int32 sds_id, VOIDP max, VOIDP min)
 
static intn SDwritedata (int32 sds_id, int32 *start, int32 *stride, int32 *end, VOIDP data)
 
static intn SDreaddata (int32 sds_id, int32 *start, int32 *stride, int32 *end, VOIDP data)
 
static intn DFSDsetdims (intn rank, int32 dimsizes[])
 Single file interface. More...
 
static intn DFSDsetNT (int32 numbertype)
 
static intn DFSDsetdatastrs (const char *label, const char *unit, const char *format, const char *coordsys)
 
static intn DFSDsetrange (VOIDP maxi, VOIDP mini)
 
static intn DFSDadddata (const char *filename, intn rank, int32 dimsizes[], VOIDP data)
 
static intn DFSDputdata (const char *filename, intn rank, int32 dimsizes[], VOIDP data)
 
static intn Hishdf (const char *filename)
 HDF4 wrapper functions. More...
 
static int32 SDstart (const char *filename, int32 accessMode)
 
static intn SDend (int32 sd_id)
 
static intn SDfileinfo (int32 id, int32 *dsCount, int32 *nAttrs)
 
static int32 SDcreate (int32 sd_id, const char *name, int32 dType, int32 rank, int32 *size)
 
static int32 SDselect (int32 sd_id, int32 index)
 
static intn SDendaccess (int32 sds_id)
 
static int32 SDfindattr (int32 id, const char *attrName)
 
static intn SDgetinfo (int32 sds_id, char *name, int32 *rank, int32 *size, int32 *dType, int32 *nAttrs)
 
static intn SDsetdatastrs (int32 sds_id, const char *label, const char *units, const char *format, const char *coordsys)
 
static intn SDgetdatastrs (int32 sds_id, char *label, char *units, char *format, char *coordsys, intn length)
 
static intn SDsetrange (int32 sds_id, VOIDP max, VOIDP min)
 
static intn SDgetrange (int32 sds_id, VOIDP max, VOIDP min)
 
static intn SDwritedata (int32 sds_id, int32 *start, int32 *stride, int32 *end, VOIDP data)
 
static intn SDreaddata (int32 sds_id, int32 *start, int32 *stride, int32 *end, VOIDP data)
 
static intn DFSDsetdims (intn rank, int32 dimsizes[])
 Single file interface. More...
 
static intn DFSDsetNT (int32 numbertype)
 
static intn DFSDsetdatastrs (const char *label, const char *unit, const char *format, const char *coordsys)
 
static intn DFSDsetrange (VOIDP maxi, VOIDP mini)
 
static intn DFSDadddata (const char *filename, intn rank, int32 dimsizes[], VOIDP data)
 
static intn DFSDputdata (const char *filename, intn rank, int32 dimsizes[], VOIDP data)
 

Detailed Description

A class to serialize HDF calls for multithreaded apps.

Since the HDF4 libraries aren't thread-safe, it's necessary to make sure that two threads don't use HDF routines concurrently. This class starts an I/O thread and passes HDF commands to it. It also provides a few utility functions, and supports caching of open file descriptors.

Definition at line 56 of file Rocin/include/HDF4.h.

Constructor & Destructor Documentation

virtual ~HDF4 ( )
pure virtual
virtual ~HDF4 ( )
pure virtual

Member Function Documentation

intn DFSDadddata ( const char *  filename,
intn  rank,
int32  dimsizes[],
VOIDP  data 
)
static

Definition at line 573 of file HDF4.C.

References HDF_DEBUG, and rank.

575 {
576  if (HDF_DEBUG)
577  std::cout << "HDF4::DFSDadddata" << std::endl;
578 
579 #ifdef USE_PTHREADS
580  HDF4Cmd c(HDF4Cmd::DFSDadddata);
581 
582  c.m_args.resize(4);
583  c.m_args[0].asCharP = const_cast<char*>(filename);
584  c.m_args[1].asIntn = rank;
585  c.m_args[2].asInt32P = dimsizes;
586  c.m_args[3].asVOIDP = data;
587 
588  PostCommand(&c);
589 
590  return c.m_result.asIntn;
591 #else
592  return ::DFSDadddata(filename, rank, dimsizes, data);
593 #endif // USE_PTHREADS
594 }
const int HDF_DEBUG
Definition: HDF4.C:37
static int rank
Definition: advectest.C:66
static intn DFSDadddata ( const char *  filename,
intn  rank,
int32  dimsizes[],
VOIDP  data 
)
static
intn DFSDputdata ( const char *  filename,
intn  rank,
int32  dimsizes[],
VOIDP  data 
)
static

Definition at line 596 of file HDF4.C.

References HDF_DEBUG, and rank.

598 {
599  if (HDF_DEBUG)
600  std::cout << "HDF4::DFSDputdata" << std::endl;
601 
602 #ifdef USE_PTHREADS
603  HDF4Cmd c(HDF4Cmd::DFSDputdata);
604 
605  c.m_args.resize(4);
606  c.m_args[0].asCharP = const_cast<char*>(filename);
607  c.m_args[1].asIntn = rank;
608  c.m_args[2].asInt32P = dimsizes;
609  c.m_args[3].asVOIDP = data;
610 
611  PostCommand(&c);
612 
613  return c.m_result.asIntn;
614 #else
615  return ::DFSDputdata(filename, rank, dimsizes, data);
616 #endif // USE_PTHREADS
617 }
const int HDF_DEBUG
Definition: HDF4.C:37
static int rank
Definition: advectest.C:66
static intn DFSDputdata ( const char *  filename,
intn  rank,
int32  dimsizes[],
VOIDP  data 
)
static
intn DFSDsetdatastrs ( const char *  label,
const char *  unit,
const char *  format,
const char *  coordsys 
)
static

Definition at line 530 of file HDF4.C.

References HDF_DEBUG.

532 {
533  if (HDF_DEBUG)
534  std::cout << "HDF4::DFSDsetdatastrs" << std::endl;
535 
536 #ifdef USE_PTHREADS
537  HDF4Cmd c(HDF4Cmd::DFSDsetdatastrs);
538 
539  c.m_args.resize(4);
540  c.m_args[0].asCharP = const_cast<char*>(label);
541  c.m_args[1].asCharP = const_cast<char*>(unit);
542  c.m_args[2].asCharP = const_cast<char*>(format);
543  c.m_args[3].asCharP = const_cast<char*>(coordsys);
544 
545  PostCommand(&c);
546 
547  return c.m_result.asIntn;
548 #else
549  return ::DFSDsetdatastrs(label, unit, format, coordsys);
550 #endif // USE_PTHREADS
551 }
const int HDF_DEBUG
Definition: HDF4.C:37
static intn DFSDsetdatastrs ( const char *  label,
const char *  unit,
const char *  format,
const char *  coordsys 
)
static
static intn DFSDsetdims ( intn  rank,
int32  dimsizes[] 
)
static

Single file interface.

intn DFSDsetdims ( intn  rank,
int32  dimsizes[] 
)
static

Single file interface.

Definition at line 491 of file HDF4.C.

References HDF_DEBUG, and rank.

492 {
493  if (HDF_DEBUG)
494  std::cout << "HDF4::DFSDsetdims" << std::endl;
495 
496 #ifdef USE_PTHREADS
497  HDF4Cmd c(HDF4Cmd::DFSDsetdims);
498 
499  c.m_args.resize(2);
500  c.m_args[0].asIntn = rank;
501  c.m_args[1].asInt32P = dimsizes;
502 
503  PostCommand(&c);
504 
505  return c.m_result.asIntn;
506 #else
507  return ::DFSDsetdims(rank, dimsizes);
508 #endif // USE_PTHREADS
509 }
const int HDF_DEBUG
Definition: HDF4.C:37
static int rank
Definition: advectest.C:66
static intn DFSDsetNT ( int32  numbertype)
static
intn DFSDsetNT ( int32  numbertype)
static

Definition at line 511 of file HDF4.C.

References HDF_DEBUG.

512 {
513  if (HDF_DEBUG)
514  std::cout << "HDF4::DFSDsetNT" << std::endl;
515 
516 #ifdef USE_PTHREADS
517  HDF4Cmd c(HDF4Cmd::DFSDsetNT);
518 
519  c.m_args.resize(1);
520  c.m_args[0].asInt32 = numbertype;
521 
522  PostCommand(&c);
523 
524  return c.m_result.asIntn;
525 #else
526  return ::DFSDsetNT(numbertype);
527 #endif // USE_PTHREADS
528 }
const int HDF_DEBUG
Definition: HDF4.C:37
intn DFSDsetrange ( VOIDP  maxi,
VOIDP  mini 
)
static

Definition at line 553 of file HDF4.C.

References HDF_DEBUG.

554 {
555  if (HDF_DEBUG)
556  std::cout << "HDF4::DFSDsetrange" << std::endl;
557 
558 #ifdef USE_PTHREADS
559  HDF4Cmd c(HDF4Cmd::DFSDsetrange);
560 
561  c.m_args.resize(2);
562  c.m_args[0].asVOIDP = maxi;
563  c.m_args[1].asVOIDP = mini;
564 
565  PostCommand(&c);
566 
567  return c.m_result.asIntn;
568 #else
569  return ::DFSDsetrange(maxi, mini);
570 #endif // USE_PTHREADS
571 }
const int HDF_DEBUG
Definition: HDF4.C:37
static intn DFSDsetrange ( VOIDP  maxi,
VOIDP  mini 
)
static
std::string error_msg ( )
static

return error message

Definition at line 961 of file HDF4.C.

961  {
962  return HEstring((hdf_err_code_t)HEvalue(1));
963 }
static std::string error_msg ( )
static

return error message

void finalize ( )
static

Destroy the I/O thread.

Definition at line 128 of file HDF4.C.

References HDF_DEBUG, and Terminate().

Referenced by Rocout::finalize(), and Rocin::finalize().

129 {
130  if (HDF_DEBUG)
131  std::cout << "HDF4::finalize()" << std::endl;
132 
133 #ifdef USE_PTHREADS
134  --sm_counter;
135  if (sm_counter > 0)
136  return;
137 
138  HDF4::Terminate();
139 
140  void* retval;
141  pthread_join(sm_id, &retval);
142 
143  sm_id = 0;
144 #endif // USE_PTHREADS
145 }
const int HDF_DEBUG
Definition: HDF4.C:37
static void Terminate()
Terminate the I/O thread.
Definition: HDF4.C:625

Here is the call graph for this function:

Here is the caller graph for this function:

static void finalize ( )
static

Destroy the I/O thread.

intn Hishdf ( const char *  filename)
static

HDF4 wrapper functions.

Each wrapper function adds a command request to the end of the command queue and signals the I/O thread that a command is pending.

Multi-file interface.

See the HDF4 documentation for details on parameters and return values for each function.

Definition at line 154 of file HDF4.C.

References HDF_DEBUG.

155 {
156  if (HDF_DEBUG)
157  std::cout << "HDF4::Hishdf" << std::endl;
158 
159 #ifdef USE_PTHREADS
160  // Sprecify the command.
161  HDF4Cmd c(HDF4Cmd::Hishdf);
162 
163  // Add the arguments to the argument list.
164  c.m_args.resize(1);
165  c.m_args[0].asCharP = const_cast<char*>(filename);
166 
167  // Push the command request onto the command queue.
168  PostCommand(&c);
169 
170  // Return the result.
171  return c.m_result.asIntn;
172 #else
173  return ::Hishdf(filename);
174 #endif // USE_PTHREADS
175 }
const int HDF_DEBUG
Definition: HDF4.C:37
static intn Hishdf ( const char *  filename)
static

HDF4 wrapper functions.

Multi-file interface.

void init ( )
static

Create and start the I/O thread.

Make sure that an I/O thread isn't running already.

If it is, then don't create another one.

Definition at line 108 of file HDF4.C.

References HDF_DEBUG.

Referenced by Rocout::init(), and Rocin::init().

109 {
110  if (HDF_DEBUG)
111  std::cout << "HDF4::init()" << std::endl;
112 
113 #ifdef USE_PTHREADS
114  ++sm_counter;
115 
116  // Make sure that a thread isn't already running.
117  if (sm_id != 0)
118  return;
119 
120  pthread_attr_t attr;
121  pthread_attr_init(&attr);
122  pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
123  pthread_create(&sm_id, &attr, HDF4::Entry, NULL);
124  pthread_attr_destroy(&attr);
125 #endif // USE_PTHREADS
126 }
const int HDF_DEBUG
Definition: HDF4.C:37

Here is the caller graph for this function:

static void init ( )
static

Create and start the I/O thread.

static int32 SDcreate ( int32  sd_id,
const char *  name,
int32  dType,
int32  rank,
int32 *  size 
)
static
int32 SDcreate ( int32  sd_id,
const char *  name,
int32  dType,
int32  rank,
int32 *  size 
)
static

Definition at line 244 of file HDF4.C.

References HDF_DEBUG, and rank.

246 {
247  if (HDF_DEBUG)
248  std::cout << "HDF4::SDcreate" << std::endl;
249 
250 #ifdef USE_PTHREADS
251  HDF4Cmd c(HDF4Cmd::SDcreate);
252 
253  c.m_args.resize(5);
254  c.m_args[0].asInt32 = sds_id;
255  c.m_args[1].asCharP = const_cast<char*>(name);
256  c.m_args[2].asInt32 = dType;
257  c.m_args[3].asInt32 = rank;
258  c.m_args[4].asInt32P = size;
259 
260  PostCommand(&c);
261 
262  return c.m_result.asIntn;
263 #else
264  return ::SDcreate(sds_id, name, dType, rank, size);
265 #endif // USE_PTHREADS
266 }
const int HDF_DEBUG
Definition: HDF4.C:37
static int rank
Definition: advectest.C:66
static intn SDend ( int32  sd_id)
static
intn SDend ( int32  sd_id)
static

Definition at line 200 of file HDF4.C.

References HDF_DEBUG.

Referenced by FindFirstGeometryDataset(), load_data_HDF4(), and scan_files_HDF4().

201 {
202  if (HDF_DEBUG)
203  std::cout << "HDF4::SDend" << std::endl;
204 
205 #ifdef USE_PTHREADS
206  HDF4Cmd c(HDF4Cmd::SDend);
207 
208  c.m_args.resize(1);
209  c.m_args[0].asInt32 = sd_id;
210 
211  PostCommand(&c);
212 
213  return c.m_result.asIntn;
214 #else
215  return ::SDend(sd_id);
216 #endif // USE_PTHREADS
217 }
const int HDF_DEBUG
Definition: HDF4.C:37

Here is the caller graph for this function:

static intn SDendaccess ( int32  sds_id)
static
intn SDendaccess ( int32  sds_id)
static

Definition at line 288 of file HDF4.C.

References HDF_DEBUG.

Referenced by FindFirstGeometryDataset(), load_data_HDF4(), scan_files_HDF4(), and Select().

289 {
290  if (HDF_DEBUG)
291  std::cout << "HDF4::SDendaccess" << std::endl;
292 
293 #ifdef USE_PTHREADS
294  HDF4Cmd c(HDF4Cmd::SDendaccess);
295 
296  c.m_args.resize(1);
297  c.m_args[0].asInt32 = sds_id;
298 
299  PostCommand(&c);
300 
301  return c.m_result.asIntn;
302 #else
303  return ::SDendaccess(sds_id);
304 #endif // USE_PTHREADS
305 }
const int HDF_DEBUG
Definition: HDF4.C:37

Here is the caller graph for this function:

static intn SDfileinfo ( int32  id,
int32 *  dsCount,
int32 *  nAttrs 
)
static
intn SDfileinfo ( int32  id,
int32 *  dsCount,
int32 *  nAttrs 
)
static

Definition at line 219 of file HDF4.C.

References HDF_DEBUG, and id().

Referenced by FindFirstGeometryDataset(), scan_files_HDF4(), and Select().

220 {
221  if (HDF_DEBUG)
222  std::cout << "HDF4::SDfileinfo" << std::endl;
223 
224 #ifdef USE_PTHREADS
225  HDF4Cmd c(HDF4Cmd::SDfileinfo);
226 
227  c.m_args.resize(3);
228  c.m_args[0].asInt32 = id;
229  c.m_args[1].asInt32P = dsCount;
230  c.m_args[2].asInt32P = nAttrs;
231 
232  if(HDF_DEBUG)
233  std::cout << " Posting command" << std::endl;
234  PostCommand(&c);
235 
236  if(HDF_DEBUG)
237  std::cout << " Returning" << std::endl;
238  return c.m_result.asIntn;
239 #else
240  return ::SDfileinfo(id, dsCount, nAttrs);
241 #endif // USE_PTHREADS
242 }
const int HDF_DEBUG
Definition: HDF4.C:37
unsigned long id(const Leda_like_handle &x)
Definition: Handle.h:107

Here is the call graph for this function:

Here is the caller graph for this function:

static int32 SDfindattr ( int32  id,
const char *  attrName 
)
static
int32 SDfindattr ( int32  id,
const char *  attrName 
)
static

Definition at line 307 of file HDF4.C.

References HDF_DEBUG, and id().

308 {
309  if (HDF_DEBUG)
310  std::cout << "HDF4::SDfindattr" << std::endl;
311 
312 #ifdef USE_PTHREADS
313  HDF4Cmd c(HDF4Cmd::SDfindattr);
314 
315  c.m_args.resize(2);
316  c.m_args[0].asInt32 = id;
317  c.m_args[1].asCharP = const_cast<char*>(attrName);
318 
319  PostCommand(&c);
320 
321  return c.m_result.asInt32;
322 #else
323  return ::SDfindattr(id, attrName);
324 #endif // USE_PTHREADS
325 }
const int HDF_DEBUG
Definition: HDF4.C:37
unsigned long id(const Leda_like_handle &x)
Definition: Handle.h:107

Here is the call graph for this function:

static intn SDgetdatastrs ( int32  sds_id,
char *  label,
char *  units,
char *  format,
char *  coordsys,
intn  length 
)
static
intn SDgetdatastrs ( int32  sds_id,
char *  label,
char *  units,
char *  format,
char *  coordsys,
intn  length 
)
static

Definition at line 376 of file HDF4.C.

References HDF_DEBUG, and Mesquite::length().

Referenced by FindFirstGeometryDataset(), and scan_files_HDF4().

378 {
379  if (HDF_DEBUG)
380  std::cout << "HDF4::SDgetdatastrs" << std::endl;
381 
382 #ifdef USE_PTHREADS
383  HDF4Cmd c(HDF4Cmd::SDgetdatastrs);
384 
385  c.m_args.resize(6);
386  c.m_args[0].asInt32 = sds_id;
387  c.m_args[1].asCharP = label;
388  c.m_args[2].asCharP = units;
389  c.m_args[3].asCharP = format;
390  c.m_args[4].asCharP = coordsys;
391  c.m_args[5].asIntn = length;
392 
393  PostCommand(&c);
394 
395  return c.m_result.asIntn;
396 #else
397  return ::SDgetdatastrs(sds_id, label, units, format, coordsys, length);
398 #endif // USE_PTHREADS
399 }
double length(Vector3D *const v, int n)
const int HDF_DEBUG
Definition: HDF4.C:37

Here is the call graph for this function:

Here is the caller graph for this function:

intn SDgetinfo ( int32  sds_id,
char *  name,
int32 *  rank,
int32 *  size,
int32 *  dType,
int32 *  nAttrs 
)
static

Definition at line 327 of file HDF4.C.

References HDF_DEBUG, and rank.

Referenced by Select().

329 {
330  if (HDF_DEBUG)
331  std::cout << "HDF4::SDgetinfo" << std::endl;
332 
333 #ifdef USE_PTHREADS
334  HDF4Cmd c(HDF4Cmd::SDgetinfo);
335 
336  c.m_args.resize(6);
337  c.m_args[0].asInt32 = sds_id;
338  c.m_args[1].asCharP = name;
339  c.m_args[2].asInt32P = rank;
340  c.m_args[3].asInt32P = size;
341  c.m_args[4].asInt32P = dType;
342  c.m_args[5].asInt32P = nAttrs;
343 
344  PostCommand(&c);
345 
346  return c.m_result.asIntn;
347 #else
348  return ::SDgetinfo(sds_id, name, rank, size, dType, nAttrs);
349 #endif // USE_PTHREADS
350 }
const int HDF_DEBUG
Definition: HDF4.C:37
static int rank
Definition: advectest.C:66

Here is the caller graph for this function:

static intn SDgetinfo ( int32  sds_id,
char *  name,
int32 *  rank,
int32 *  size,
int32 *  dType,
int32 *  nAttrs 
)
static
static intn SDgetrange ( int32  sds_id,
VOIDP  max,
VOIDP  min 
)
static
intn SDgetrange ( int32  sds_id,
VOIDP  max,
VOIDP  min 
)
static

Definition at line 422 of file HDF4.C.

References HDF_DEBUG, max(), and min().

423 {
424  if (HDF_DEBUG)
425  std::cout << "HDF4::SDgetrange" << std::endl;
426 
427 #ifdef USE_PTHREADS
428  HDF4Cmd c(HDF4Cmd::SDgetrange);
429 
430  c.m_args.resize(3);
431  c.m_args[0].asInt32 = sds_id;
432  c.m_args[1].asVOIDP = max;
433  c.m_args[2].asVOIDP = min;
434 
435  PostCommand(&c);
436 
437  return c.m_result.asIntn;
438 #else
439  return ::SDgetrange(sds_id, max, min);
440 #endif // USE_PTHREADS
441 }
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
const int HDF_DEBUG
Definition: HDF4.C:37
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346

Here is the call graph for this function:

intn SDreaddata ( int32  sds_id,
int32 *  start,
int32 *  stride,
int32 *  end,
VOIDP  data 
)
static

Definition at line 467 of file HDF4.C.

References HDF_DEBUG.

Referenced by load_data_HDF4(), and scan_files_HDF4().

469 {
470  if (HDF_DEBUG)
471  std::cout << "HDF4::SDreaddata" << std::endl;
472 
473 #ifdef USE_PTHREADS
474  HDF4Cmd c(HDF4Cmd::SDreaddata);
475 
476  c.m_args.resize(5);
477  c.m_args[0].asInt32 = sds_id;
478  c.m_args[1].asInt32P = start;
479  c.m_args[2].asInt32P = stripe;
480  c.m_args[3].asInt32P = end;
481  c.m_args[4].asVOIDP = data;
482 
483  PostCommand(&c);
484 
485  return c.m_result.asIntn;
486 #else
487  return ::SDreaddata(sds_id, start, stripe, end, data);
488 #endif // USE_PTHREADS
489 }
const int HDF_DEBUG
Definition: HDF4.C:37

Here is the caller graph for this function:

static intn SDreaddata ( int32  sds_id,
int32 *  start,
int32 *  stride,
int32 *  end,
VOIDP  data 
)
static
static int32 SDselect ( int32  sd_id,
int32  index 
)
static
int32 SDselect ( int32  sd_id,
int32  index 
)
static

Definition at line 268 of file HDF4.C.

References HDF_DEBUG.

Referenced by load_data_HDF4(), and Select().

269 {
270  if (HDF_DEBUG)
271  std::cout << "HDF4::SDselect( sd_id == " << sd_id << ", index == " << index << " )" << std::endl;
272 
273 #ifdef USE_PTHREADS
274  HDF4Cmd c(HDF4Cmd::SDselect);
275 
276  c.m_args.resize(2);
277  c.m_args[0].asInt32 = sd_id;
278  c.m_args[1].asInt32 = index;
279 
280  PostCommand(&c);
281 
282  return c.m_result.asInt32;
283 #else
284  return ::SDselect(sd_id, index);
285 #endif // USE_PTHREADS
286 }
const int HDF_DEBUG
Definition: HDF4.C:37

Here is the caller graph for this function:

static intn SDsetdatastrs ( int32  sds_id,
const char *  label,
const char *  units,
const char *  format,
const char *  coordsys 
)
static
intn SDsetdatastrs ( int32  sds_id,
const char *  label,
const char *  units,
const char *  format,
const char *  coordsys 
)
static

Definition at line 352 of file HDF4.C.

References HDF_DEBUG.

354 {
355  if (HDF_DEBUG)
356  std::cout << "HDF4::SDsetdatastrs" << std::endl;
357 
358 #ifdef USE_PTHREADS
359  HDF4Cmd c(HDF4Cmd::SDsetdatastrs);
360 
361  c.m_args.resize(5);
362  c.m_args[0].asInt32 = sds_id;
363  c.m_args[1].asCharP = const_cast<char*>(label);
364  c.m_args[2].asCharP = const_cast<char*>(units);
365  c.m_args[3].asCharP = const_cast<char*>(format);
366  c.m_args[4].asCharP = const_cast<char*>(coordsys);
367 
368  PostCommand(&c);
369 
370  return c.m_result.asIntn;
371 #else
372  return ::SDsetdatastrs(sds_id, label, units, format, coordsys);
373 #endif // USE_PTHREADS
374 }
const int HDF_DEBUG
Definition: HDF4.C:37
static intn SDsetrange ( int32  sds_id,
VOIDP  max,
VOIDP  min 
)
static
intn SDsetrange ( int32  sds_id,
VOIDP  max,
VOIDP  min 
)
static

Definition at line 401 of file HDF4.C.

References HDF_DEBUG, max(), and min().

402 {
403  if (HDF_DEBUG)
404  std::cout << "HDF4::SDsetrange" << std::endl;
405 
406 #ifdef USE_PTHREADS
407  HDF4Cmd c(HDF4Cmd::SDsetrange);
408 
409  c.m_args.resize(3);
410  c.m_args[0].asInt32 = sds_id;
411  c.m_args[1].asVOIDP = max;
412  c.m_args[2].asVOIDP = min;
413 
414  PostCommand(&c);
415 
416  return c.m_result.asIntn;
417 #else
418  return ::SDsetrange(sds_id, max, min);
419 #endif // USE_PTHREADS
420 }
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
const int HDF_DEBUG
Definition: HDF4.C:37
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346

Here is the call graph for this function:

static int32 SDstart ( const char *  filename,
int32  accessMode 
)
static
int32 SDstart ( const char *  filename,
int32  accessMode 
)
static

Definition at line 177 of file HDF4.C.

References HDF_DEBUG.

Referenced by FindFirstGeometryDataset(), load_data_HDF4(), and scan_files_HDF4().

178 {
179  if (HDF_DEBUG)
180  std::cout << "HDF4::SDstart( filename == " << filename << ", accessMode == " << accessMode << " )" << std::endl;
181 
182 #ifdef USE_PTHREADS
183  HDF4Cmd c(HDF4Cmd::SDstart);
184 
185  c.m_args.resize(2);
186  c.m_args[0].asCharP = const_cast<char*>(filename);
187  c.m_args[1].asInt32 = accessMode;
188 
189  if (HDF_DEBUG){
190  // std::cout << " Posting Command" << std::endl << " m_args[0] = " << c.m_args[0].asCharP << std::endl << " m_args[1] = " << c.m_args[1].asInt32 << std::endl;
191  }
192  PostCommand(&c);
193 
194  return c.m_result.asInt32;
195 #else
196  return ::SDstart(filename, accessMode);
197 #endif // USE_PTHREADS
198 }
const int HDF_DEBUG
Definition: HDF4.C:37

Here is the caller graph for this function:

static intn SDwritedata ( int32  sds_id,
int32 *  start,
int32 *  stride,
int32 *  end,
VOIDP  data 
)
static
intn SDwritedata ( int32  sds_id,
int32 *  start,
int32 *  stride,
int32 *  end,
VOIDP  data 
)
static

Definition at line 443 of file HDF4.C.

References HDF_DEBUG.

445 {
446  if (HDF_DEBUG)
447  std::cout << "HDF4::SDwritedata" << std::endl;
448 
449 #ifdef USE_PTHREADS
450  HDF4Cmd c(HDF4Cmd::SDwritedata);
451 
452  c.m_args.resize(5);
453  c.m_args[0].asInt32 = sds_id;
454  c.m_args[1].asInt32P = start;
455  c.m_args[2].asInt32P = stripe;
456  c.m_args[3].asInt32P = end;
457  c.m_args[4].asVOIDP = data;
458 
459  PostCommand(&c);
460 
461  return c.m_result.asIntn;
462 #else
463  return ::SDwritedata(sds_id, start, stripe, end, data);
464 #endif // USE_PTHREADS
465 }
const int HDF_DEBUG
Definition: HDF4.C:37
int32 Select ( int32  sd_id,
int32 &  index,
char *  name,
int32 *  rank,
int32 *  size,
int32 *  dType,
int32 *  nAttrs,
int32  dsCount = -1 
)
static

"Open" and "close" HDF files efficiently.

The "single file" SD routines add several "fake" datasets, which severely clutter up the file and complicate searches.

Select the first non-"fakeDim" dataset, starting at index.

This more powerful version of SDselect adds the functionality of SDgetinfo and ignores fake datasets.

Parameters
indexThe index of the dataset to select. The difference from SDselect is that this parameter will be assigned the index of the first non-"fake" dataset (possibly the initial value).
dsCountThe number of datasets in the file. If this isn't provided, the number of datasets is determined by calling SDfileinfo.
Returns
An HDF4 dataset id on success, or FAIL on failure.
Note
See the documentation for SDselect and SDgetinfo for the descriptions of the other parameters.

Definition at line 675 of file HDF4.C.

References HDF_DEBUG, MAX_NC_VARS, SDendaccess(), SDfileinfo(), SDgetinfo(), and SDselect().

Referenced by FindFirstGeometryDataset(), and scan_files_HDF4().

677 {
678  if (HDF_DEBUG)
679  std::cout << "HDF4::Select" << std::endl;
680  int32 sds_id;
681  intn status;
682 
683  // If the caller didn't specify the number of datasets in the file, then
684  // we have to call SDfileinfo(). <sigh>
685  if (dsCount == -1) {
686  int32 numAttrs;
687  status = HDF4::SDfileinfo(sd_id, &dsCount, &numAttrs);
688  if (status == FAIL)
689  dsCount = MAX_NC_VARS;
690  }
691 
692  while (index < dsCount) {
693  // Open the next dataset.
694  sds_id = HDF4::SDselect(sd_id, index);
695  if (sds_id == FAIL) {
696  std::cerr << "HDF4::Select(): unable to select dataset " << index
697  << '.' << std::endl;
698  return FAIL;
699  }
700 
701  // Get the dataset info.
702  status = HDF4::SDgetinfo(sds_id, name, rank, size, dType, nAttrs);
703  if (status == FAIL) {
704  std::cerr << "HDF4::Select(): SDgetinfo() failed for dataset "
705  << index << '.' << std::endl;
706  return FAIL;
707  }
708 
709  // Make sure that this isn't a "fakeDim" dataset (they're so annoying).
710  if (strncmp(name, "fakeDim", 7) != 0)
711  return sds_id;
712 
713  // If we got this far, then it was a "fakeDim" dataset. Close it and
714  // try the next one.
715  HDF4::SDendaccess(sds_id);
716  ++index;
717  }
718 
719  // Whoops, we're fresh out of datasets. Sorry.
720  return FAIL;
721 }
static int32 SDselect(int32 sd_id, int32 index)
Definition: HDF4.C:268
#define MAX_NC_VARS
static intn SDgetinfo(int32 sds_id, char *name, int32 *rank, int32 *size, int32 *dType, int32 *nAttrs)
Definition: HDF4.C:327
static intn SDendaccess(int32 sds_id)
Definition: HDF4.C:288
const int HDF_DEBUG
Definition: HDF4.C:37
static intn SDfileinfo(int32 id, int32 *dsCount, int32 *nAttrs)
Definition: HDF4.C:219
static int rank
Definition: advectest.C:66

Here is the call graph for this function:

Here is the caller graph for this function:

static int32 Select ( int32  sd_id,
int32 &  index,
char *  name,
int32 *  rank,
int32 *  size,
int32 *  dType,
int32 *  nAttrs,
int32  dsCount = -1 
)
static

"Open" and "close" HDF files efficiently.

Select the first non-"fakeDim" dataset, starting at index.

static int SizeOf ( int32  dType)
static

Get the size in bytes of an HDF data type.

int SizeOf ( int32  dType)
static

Get the size in bytes of an HDF data type.

Like the "sizeof" operator, except that this takes a HDF4 datatype id.

Parameters
dTypeThe HDF4 datatype id.
Returns
The size, in bytes, of the datatype.

Definition at line 730 of file HDF4.C.

References HDF_DEBUG.

731 {
732  if (HDF_DEBUG)
733  std::cout << "HDF4::SIZEOF" << std::endl;
734  switch (dType) {
735  case DFNT_CHAR8:
736  case DFNT_UCHAR8:
737  case DFNT_INT8:
738  case DFNT_NINT8:
739  case DFNT_LINT8:
740  case DFNT_UINT8:
741  case DFNT_NUINT8:
742  case DFNT_LUINT8:
743  return 1;
744 
745  case DFNT_INT16:
746  case DFNT_NINT16:
747  case DFNT_LINT16:
748  case DFNT_UINT16:
749  case DFNT_NUINT16:
750  case DFNT_LUINT16:
751  return 2;
752 
753  case DFNT_INT32:
754  case DFNT_NINT32:
755  case DFNT_LINT32:
756  case DFNT_UINT32:
757  case DFNT_NUINT32:
758  case DFNT_LUINT32:
759  case DFNT_FLOAT32:
760  case DFNT_NFLOAT32:
761  case DFNT_LFLOAT32:
762  return 4;
763 
764  case DFNT_FLOAT64:
765  case DFNT_NFLOAT64:
766  case DFNT_LFLOAT64:
767  return 8;
768  }
769 
770  return 0;
771 }
const int HDF_DEBUG
Definition: HDF4.C:37
void Terminate ( )
static

Terminate the I/O thread.

This adds a "Terminate" request to the command queue.

Any commands already in the queue will be acted on, but any commands added afterward will be ignored.

Definition at line 625 of file HDF4.C.

References HDF_DEBUG.

Referenced by finalize().

626 {
627  if (HDF_DEBUG)
628  std::cout << "HDF4::Terminate()" << std::endl;
629 
630 #ifdef USE_PTHREADS
631  if (sm_counter > 0)
632  return;
633 
634  HDF4Cmd c(HDF4Cmd::Terminate);
635 
636  c.m_args.clear();
637 
638  PostCommand(&c);
639 #endif // USE_PTHREADS
640 }
const int HDF_DEBUG
Definition: HDF4.C:37

Here is the caller graph for this function:

static void Terminate ( )
static

Terminate the I/O thread.


The documentation for this class was generated from the following files: