Main Page | Class List | File List | Class Members | File Members

H5Part.h

Go to the documentation of this file.
00001 #ifndef _H5Part_H_
00002 #define _H5Part_H_
00003 
00004 #include <hdf5.h>
00005 #ifdef PARALLEL_IO
00006 #include <mpi.h>
00007 #endif
00008 
00016 typedef struct H5PartFile {
00017   hid_t file;
00018   int timestep;
00019 
00020   hid_t timegroup;
00021   hid_t properties;
00022   hsize_t nparticles;
00023   hid_t shape;
00024   unsigned mode;
00025   int maxstep;
00026   hid_t xfer_prop,create_prop,access_prop;
00027   hid_t diskshape,memshape; /* for parallel I/O (this is on-disk) H5S_ALL 
00028                     if serial I/O */
00029   long long viewstart,viewend; /* -1 if no view is available: A "view" looks at a subset of the data. */
00030   
00031 #ifdef PARALLEL_IO
00032   long long *pnparticles; /* the number of particles in each processor.
00033                              With respect to the "VIEW", these numbers
00034                              can be regarded as non-overlapping subsections
00035                              of the particle array stored in the file.
00036                              So they can be used to compute the offset of
00037                              the view for each processor */
00038   MPI_Comm comm;
00039   int nprocs,myproc;
00040 #endif
00041 }H5PartFile;
00042 
00043 #define H5PART_READ 0x01
00044 #define H5PART_WRITE 0x02
00045 
00046 /*========== File Opening/Closing ===============*/
00047 #ifdef PARALLEL_IO
00048 #include <mpi.h>
00049 H5PartFile *H5PartOpenFileParallel(const char *filename,
00050                                    unsigned flags,
00051                                    MPI_Comm communicator);
00052 #endif
00053 #define H5PartOpenFileSerial(x,y) H5PartOpenFile(x,y)
00054 
00055 H5PartFile *H5PartOpenFile(const char *filename, /* name of datafile */
00056                                  unsigned flags); /* H5PART_READ | H5PART_WRITE */
00057 int H5PartFileIsValid(H5PartFile *f);
00058 void H5PartCloseFile(H5PartFile *f);
00059 
00060 
00061 /*============== File Writing Functions ==================== */
00062 void H5PartSetNumParticles(H5PartFile *f,long long nparticles);
00063 int H5PartWriteDataFloat64(H5PartFile *f,char *name,double *array);
00064 int H5PartWriteDataInt64(H5PartFile *f,char *name,long long *array);
00065 
00066 /*================== File Reading Routines =================*/
00067 void H5PartSetStep(H5PartFile *f, /* file handle */
00068                    int step); /* current timestep to select (0 to n-1) */
00069 int H5PartGetNumSteps(H5PartFile *f);
00070 int H5PartGetNumDatasets(H5PartFile *f);
00071 int H5PartGetDatasetName(H5PartFile *f,int index,char *name,int maxlen);
00072 long long H5PartGetNumParticles(H5PartFile *f);
00073 void H5PartSetView(H5PartFile *f,long long start,long long end);
00074 #define H5PartResetView(f) H5PartSetView(f,-1,-1)
00075 #define H5PartHasView(f) ((f->viewstart<0||f->viewend<0)?0:1)
00076 int H5PartGetView(H5PartFile *f,long long *start,long long *end);
00077 void H5PartSetCanonicalView(H5PartFile *f);
00078 
00079 int H5PartReadDataFloat64(H5PartFile *f,
00080                           char *name, /* name of the array to read
00081                                          "x"=position in x direction (y,z)
00082                                          "vx"=velocity in x directio (y,z)
00083                                          "px"=position in x dir (y,z) */
00084                           double *array); /* array to read data into */
00085 int H5PartReadDataInt64(H5PartFile *f,
00086                           char *name, /* name of the array to read
00087                                          "x"=position in x direction (y,z)
00088                                          "vx"=velocity in x directio (y,z)
00089                                          "px"=position in x dir (y,z) */
00090                           long long *array); /* array to read data into */
00091 
00092 /* the following is a back-door for extensions to the data writing */
00093 #if 0
00094 int H5PartReadData(H5PartFile *f,char *name,void *array,hid_t type);
00095 int H5PartWriteData(H5PartFile *f,char *name,void *array,hid_t type);
00096 #endif
00097 int H5PartReadParticleStep(H5PartFile *f, /* filehandle */
00098                            int step, /* selects timestep to read from*/
00099                            double *x,double *y,double *z, /* particle positions */
00100                            double *px,double *py,double *pz, /* particle momenta */
00101                            long long *id); /* and phase */
00102 /**********==============Attributes Interface============***************/
00103 /* currently there is file attributes:  Attributes bound to the file
00104    and step attributes which are bound to the current timestep.  You 
00105    must set the timestep explicitly before writing the attributes (just
00106    as you must do when you write a new dataset.  Currently there are no
00107    attributes that are bound to a particular data array, but this could
00108    easily be done if required.
00109 */
00110 int H5PartWriteStepAttrib(H5PartFile *f,char *name,
00111     hid_t type,void *attrib,int nelem);
00112 int H5PartWriteFileAttrib(H5PartFile *f,char *name,
00113     hid_t type,void *attrib,int nelem);
00114 int H5PartWriteAttrib(H5PartFile *f,char *name,
00115                       hid_t type,void *attrib,int nelem); /* this should be deprecated */
00116 
00117 int H5PartWriteFileAttribString(H5PartFile *f,char *name,
00118     char *attrib);
00119 int H5PartWriteStepAttribString(H5PartFile *f,char *name,
00120     char *attrib);
00121 int H5PartGetNumStepAttribs(H5PartFile *f); /* for current filestep */
00122 int H5PartGetNumFileAttribs(H5PartFile *f);
00123 void H5PartGetStepAttribInfo(H5PartFile *f,int idx,
00124     char *name,size_t maxnamelen,
00125                          hid_t *type,int *nelem);
00126 void H5PartGetFileAttribInfo(H5PartFile *f,int idx,
00127     char *name,size_t maxnamelen,
00128     hid_t *type,int *nelem);
00129 int H5PartReadStepAttrib(H5PartFile *f,char *name,void *data);
00130 void H5PartReadAttrib(H5PartFile *f,char *name,void *data);
00131 int H5PartReadFileAttrib(H5PartFile *f,char *name,void *data);
00132 
00133 
00134 /**************** File Stashing Interfaces *************************/
00135 int H5PartStashFile(H5PartFile *f,char *filename);
00136 int H5PartUnstashFile(H5PartFile *f, char *filename, char *outputpath); /* outputpath can be null for cwd */
00137 int H5PartGetNumStashFiles(H5PartFile *f);
00138 int H5PartFileGetStashFileName(H5PartFile *f,int nameindex,char *filename,int maxnamelen);
00139 
00140 
00141 #endif

Generated on Tue Jan 31 11:52:45 2006 for H5Part by  doxygen 1.4.4