Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

hdfFile.hpp

Go to the documentation of this file.
00001 //************************************************************************************//
00002 // Module       : hdfFile.hpp
00003 // Date         : 8/04/02 (RMP)
00004 // Copyright    : 2002-2006 Copyright University Corporation for Atmospheric
00005 //                Research
00006 // Description  : Derived class encapsulating the methods and data associated with
00007 //                an HDF-format Gaspar file.
00008 // Derived From : GasparFile (gasparFile.hpp)
00009 // Modifications:
00010 //************************************************************************************//
00011 
00012 #if !defined(HDFFILE_HPP)
00013 #define HDFFILE_HPP
00014 
00015 #include "mpi.h"
00016 #include "gasparFile.hpp"
00017 #include "hdf5.h"
00018 #include "gtypes.h"
00019 #include <iostream.h>
00020 #include <string.h>
00021 #include <stdlib.h>
00022 
00023 class HDFFile : public GasparFile{
00024 
00025 public:
00026 
00027   //public methods:
00028   HDFFile(const char* fileNameIn, IO_TYPE fType = COLLECTIVE_IO, IO_TYPE dType = INDEPENDENT_IO, MPI_Comm commIn = MPI_COMM_WORLD);
00029   HDFFile(const char* fileNameIn, ISUB** procGrid, ISUB nLists, ISUB* listSizes, IO_TYPE dType = INDEPENDENT_IO, MPI_Comm commIn = MPI_COMM_WORLD);
00030   ~HDFFile();
00031   GBOOL close();
00032   GBOOL open(FILE_ACCESS accessIn, ISUB fileNestDepth = FILE_DEPTH_DEFAULT);
00033   GBOOL openCreate(GBOOL overWriteIn, ISUB fileNestDepth = FILE_DEPTH_DEFAULT);
00034   GBOOL openGroup(const char* groupName);
00035   GBOOL createGroup(const char* groupName, GUSHORT  hint = GROUP_HINT);
00036   GBOOL closeGroup();
00037   GBOOL up();
00038   GBOOL top();
00039   GBOOL writeMeta(const char* metaName, HDFID location, GDOUBLE meta);
00040   GBOOL writeMeta(const char* metaName, HDFID location, GDOUBLE *meta, GSHORT  len);
00041   GBOOL writeMeta(const char* metaName, HDFID location, ISUB meta);
00042   GBOOL readMeta(const char* metaName, HDFID location, GDOUBLE& meta);
00043   GBOOL readMeta(const char* metaName, HDFID location, ISUB& meta);
00044   GBOOL writeVector(const char* dataName, const GDOUBLE* data, ISUB dataSize){ return writeTVector(dataName, data, dataSize); }
00045   GBOOL writeVector(const char* dataName, const ISUB* data, ISUB dataSize){ return writeTVector(dataName, data, dataSize); }
00046   GBOOL readVector(const char* dataName, GDOUBLE*& data, ISUB& dataSize){ return readTVector(dataName, data, dataSize); }
00047   GBOOL readVector(const char* dataName, ISUB*& data, ISUB& dataSize){ return readTVector(dataName, data, dataSize); }
00048   GBOOL writeMatrix(const char* dataName, GDOUBLE* data, ISUB n1, ISUB n2);
00049   GBOOL readMatrix(const char* dataName, GDOUBLE*& data, ISUB& n1, ISUB& n2);
00050   GBOOL checkHDF(HDFID statusIn, char* message = NULL) const;
00051   HDFID getCurrentHDFObj();
00052 
00053 private:
00054 
00055   //private methods:
00056   GBOOL setFilePlist();
00057   GBOOL setDataPlist(IO_TYPE ioType, DATA_OPERATION op);
00058   void cleanPath();
00059   GBOOL gatherNames(const char* name, char*& nameBuffer, ISUB& offset);
00060   template<class T> T max(T* array, ISUB length);
00061   template<class T> GBOOL writeTVector(const char* dataName, const T* data, ISUB dataSize);
00062   template<class T> GBOOL readTVector(const char* dataName, T*& data, ISUB& dataSize);
00063   friend HDFERR stripLinkLayer(HDFID location, const char* memName, void* nada);
00064   friend HDFERR makeLink(HDFID location, const char* memName, void* parentName);
00065 
00066   //private data:
00067   enum DEGREE {ONED=1, TWOD=2, THREED=3};   //Identifies the dimensionality of data set data
00068   HDFID  filePlistID;                       //HDF File property list identifier (access template) 
00069   HDFID  dataPlistID;                       //HDF DataSet property list identifier (access template)
00070   HDFID** path;                             //Array of HDFIDs used to navigate collective-access HDF file hierarchies
00071   HDFID fileID;                             //Handle for the currently-open file.
00072   ISUB cursorD;                             //Offset into path[Depth][] used to record position in the file
00073   HDFERR status;                            //return status flag for HDF5 library function calls
00074   GBOOL pass;                               //general success flag
00075   IO_TYPE dataIO;                           //The data transfer I/O type for this file (independent or collective)
00076   ISUB nProcs, rank, depth, breadth;        //The number of processes, and pid of current process for this file
00077   char* nameBuffer;                         //Buffer used to collect dataset and group names across processes
00078   ISUB nbOffset;                            //Offset size for a single name entry in the buffer
00079   char* errorMsg;                           //The message used to report errors to the user
00080   static const ISUB TOP;                    //The cursorD start position indicating the top of the file
00081   static const char* THIS;                  //The name of this class; used in error reporting
00082 };
00083 #endif
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092 

Generated on Wed Dec 21 16:00:48 2005 for Geophysics & Astrophysics Spectral Element Adaptive Refinement (GASpAR) 2D Code by  doxygen 1.4.4