Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Rocin/include/HDF4.h
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
29 #if !defined(_HDF4_H)
30 # define _HDF4_H
31 
32 # include <list>
33 # include <string>
34 # ifdef USE_PTHREADS
35 # include <pthread.h>
36 # include "Sync.h"
37 # endif // USE_PTHREADS
38 # include <time.h>
39 # include <hdf.h>
40 
41 #ifndef MAX_NC_NAME
42 #define MAX_NC_NAME H4_MAX_NC_NAME
43 #define MAX_NC_VARS H4_MAX_NC_VARS
44 #endif
45 
46 class HDF4Cmd;
47 
56 class HDF4
57 {
58  public:
59  virtual ~HDF4() = 0;
60 
62  static void init();
63 
65  static void finalize();
66 
68  static intn Hishdf(const char* filename);
71  static int32 SDstart(const char* filename, int32 accessMode);
72  static intn SDend(int32 sd_id);
73  static intn SDfileinfo(int32 id, int32* dsCount, int32* nAttrs);
74  static int32 SDcreate(int32 sd_id, const char* name, int32 dType,
75  int32 rank, int32* size);
76  static int32 SDselect(int32 sd_id, int32 index);
77  static intn SDendaccess(int32 sds_id);
78  static int32 SDfindattr(int32 id, const char* attrName);
79  static intn SDgetinfo(int32 sds_id, char* name, int32* rank, int32* size,
80  int32* dType, int32* nAttrs);
81  static intn SDsetdatastrs(int32 sds_id, const char* label,
82  const char* units, const char* format,
83  const char* coordsys);
84  static intn SDgetdatastrs(int32 sds_id, char* label, char* units,
85  char* format, char* coordsys, intn length);
86  static intn SDsetrange(int32 sds_id, VOIDP max, VOIDP min);
87  static intn SDgetrange(int32 sds_id, VOIDP max, VOIDP min);
88  static intn SDwritedata(int32 sds_id, int32* start, int32* stride,
89  int32* end, VOIDP data);
90  static intn SDreaddata(int32 sds_id, int32* start, int32* stride,
91  int32* end, VOIDP data);
92 
94  static intn DFSDsetdims(intn rank, int32 dimsizes[]);
95  static intn DFSDsetNT(int32 numbertype);
96  static intn DFSDsetdatastrs(const char* label, const char* unit,
97  const char* format, const char* coordsys);
98  static intn DFSDsetrange(VOIDP maxi, VOIDP mini);
99  static intn DFSDadddata(const char* filename, intn rank, int32 dimsizes[],
100  VOIDP data);
101  static intn DFSDputdata(const char* filename, intn rank, int32 dimsizes[],
102  VOIDP data);
104 
106  // static int32 Start(const std::string& pathname);
108  // static intn End(int32 sd_id);
110 
112  static int32 Select(int32 sd_id, int32& index, char* name, int32* rank,
113  int32* size, int32* dType, int32* nAttrs,
114  int32 dsCount = -1);
115 
117  static int SizeOf(int32 dType);
118 
120  static void Terminate();
121 
123  static std::string error_msg();
124 
125 # if USE_PTHREADS
126  private:
128  static void* Entry(void* arg);
129 
131  static void PostCommand(HDF4Cmd* pCmd);
132 
133  static Semaphore sm_pending;
134  static std::list<HDF4Cmd*> sm_cmdQueue;
135  static Mutex sm_cs;
136  static pthread_t sm_id;
137  static int sm_counter;
138 # endif // USE_PTHREADS
139 };
140 
141 #endif // !defined(_HDF4_H)
142 
143 
144 
145 
146 
147 
static int32 SDselect(int32 sd_id, int32 index)
Definition: HDF4.C:268
static int32 SDfindattr(int32 id, const char *attrName)
Definition: HDF4.C:307
static intn SDwritedata(int32 sds_id, int32 *start, int32 *stride, int32 *end, VOIDP data)
Definition: HDF4.C:443
virtual ~HDF4()=0
static intn SDgetinfo(int32 sds_id, char *name, int32 *rank, int32 *size, int32 *dType, int32 *nAttrs)
Definition: HDF4.C:327
A class to serialize HDF calls for multithreaded apps.
static intn SDend(int32 sd_id)
Definition: HDF4.C:200
static intn SDendaccess(int32 sds_id)
Definition: HDF4.C:288
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
static intn DFSDsetdims(intn rank, int32 dimsizes[])
Single file interface.
Definition: HDF4.C:491
static int32 SDcreate(int32 sd_id, const char *name, int32 dType, int32 rank, int32 *size)
Definition: HDF4.C:244
static intn DFSDadddata(const char *filename, intn rank, int32 dimsizes[], VOIDP data)
Definition: HDF4.C:573
Definition: Sync.h:65
static intn SDgetrange(int32 sds_id, VOIDP max, VOIDP min)
Definition: HDF4.C:422
Definition: Sync.h:28
static int SizeOf(int32 dType)
Get the size in bytes of an HDF data type.
Definition: HDF4.C:730
double length(Vector3D *const v, int n)
static intn SDsetrange(int32 sds_id, VOIDP max, VOIDP min)
Definition: HDF4.C:401
static std::string error_msg()
return error message
Definition: HDF4.C:961
static void init()
Create and start the I/O thread.
Definition: HDF4.C:108
static intn DFSDsetNT(int32 numbertype)
Definition: HDF4.C:511
static intn SDsetdatastrs(int32 sds_id, const char *label, const char *units, const char *format, const char *coordsys)
Definition: HDF4.C:352
static int32 Select(int32 sd_id, int32 &index, char *name, int32 *rank, int32 *size, int32 *dType, int32 *nAttrs, int32 dsCount=-1)
&quot;Open&quot; and &quot;close&quot; HDF files efficiently.
Definition: HDF4.C:675
static intn SDreaddata(int32 sds_id, int32 *start, int32 *stride, int32 *end, VOIDP data)
Definition: HDF4.C:467
static void Terminate()
Terminate the I/O thread.
Definition: HDF4.C:625
static intn Hishdf(const char *filename)
HDF4 wrapper functions.
Definition: HDF4.C:154
static intn SDfileinfo(int32 id, int32 *dsCount, int32 *nAttrs)
Definition: HDF4.C:219
static intn DFSDputdata(const char *filename, intn rank, int32 dimsizes[], VOIDP data)
Definition: HDF4.C:596
static void finalize()
Destroy the I/O thread.
Definition: HDF4.C:128
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
static int32 SDstart(const char *filename, int32 accessMode)
Definition: HDF4.C:177
static intn DFSDsetrange(VOIDP maxi, VOIDP mini)
Definition: HDF4.C:553
static intn SDgetdatastrs(int32 sds_id, char *label, char *units, char *format, char *coordsys, intn length)
Definition: HDF4.C:376
static intn DFSDsetdatastrs(const char *label, const char *unit, const char *format, const char *coordsys)
Definition: HDF4.C:530
static int rank
Definition: advectest.C:66