Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
readhdf.cpp File Reference
#include <stdio.h>
#include "gridutil.h"
#include "mfhdf.h"
Include dependency graph for readhdf.cpp:

Go to the source code of this file.

Macros

#define chk(x)   checkHDFerr(x,__FILE__,__LINE__)
 

Functions

static int checkHDFerr (int errCode, const char *fName, int lineNo)
 
const char * read_hdf (const char *filename, blockConsumer &dest)
 

Macro Definition Documentation

#define chk (   x)    checkHDFerr(x,__FILE__,__LINE__)

Definition at line 66 of file readhdf.cpp.

Referenced by read_hdf().

Function Documentation

static int checkHDFerr ( int  errCode,
const char *  fName,
int  lineNo 
)
static

Definition at line 67 of file readhdf.cpp.

67  {
68  if (errCode==-1) {
69  fprintf(stderr,"HDF I/O Error in (%s:%d)\n",
70  fName,lineNo);
71  exit(23);
72  }
73  return errCode;
74 }
void int int int REAL REAL REAL const char * fName
Definition: write.cpp:76
const char* read_hdf ( const char *  filename,
blockConsumer dest 
)

Definition at line 76 of file readhdf.cpp.

References blockConsumer::allocateBlock(), chk, blockConsumer::consume(), coord, d, blockConsumer::freeBlock(), blockDim::getSize(), i, and rank.

Referenced by read_file().

77 {
78  int32 i, d;
79  //Open the input file
80  int32 sd_id = SDstart(filename, DFACC_READ);
81  if (sd_id==-1) return "Couldn't open HDF input file!";
82 
83  //Select the X, Y, and Z components
84  int32 sds_id[3];
85  for (i=0;i<3;i++) sds_id[i]=chk(SDselect(sd_id,5+4*i));
86 
87  //Determine the ni, nj, and nk dimensions
88  blockDim dim;
89  /* This doesn't work.
90  for (d=0;d<3;d++) {
91  int32 dim_id = chk(SDgetdimid(sds_id[0],d));
92  char dim_name[200];
93  int32 dim_size, data_type, n_attrs;
94  chk(SDdiminfo(dim_id, dim_name, &dim_size, &data_type, &n_attrs));
95  dim[2-d]=dim_size;
96  }
97  */
98  char name[200];
99  int32 rank, size[3], data_type, n_attrs;
100  chk(SDgetinfo(sds_id[0], name, &rank, size, &data_type, &n_attrs));
101  dim[0]=size[2];
102  dim[1]=size[1];
103  dim[2]=size[0];
104 
105  //Allocate storage for the X, Y, and Z output
106  vector3d *locs=dest.allocateBlock(dim);
107 
108  //Read each of X, Y, and Z
109  int nLocs=dim.getSize();
110  double *coord=new double[nLocs];
111  for (i=0;i<3;i++)
112  {
113  int32 start[3]={0,0,0};
114  int32 edges[3];
115  for (d=0;d<3;d++) edges[d]=dim[2-d];
116  chk(SDreaddata(sds_id[i], start, NULL, edges, coord));
117  //Copy this coordinate into locs
118  for (int l=0;l<nLocs;l++) locs[l][i]=coord[l];
119  }
120  delete[] coord;
121 
122  //Pass locations to consumer
123  dest.consume(dim,locs);
124  dest.freeBlock(locs);
125 
126  //Close the file and return
127  for (i=0;i<3;i++) chk(SDendaccess(sds_id[i]));
128  chk(SDend(sd_id));
129  return NULL;
130 }
const NT & d
int coord[NPANE][NROW *NCOL][3]
Definition: blastest.C:86
#define chk(x)
Definition: readhdf.cpp:66
virtual vector3d * allocateBlock(blockDim &dim)
Definition: read.cpp:146
virtual void freeBlock(vector3d *blk)
Definition: read.cpp:150
blockLoc i
Definition: read.cpp:79
static int rank
Definition: advectest.C:66
int getSize(void) const
Definition: gridutil.h:126
virtual const char * consume(const blockDim &dim, vector3d *locs)=0

Here is the call graph for this function:

Here is the caller graph for this function: