ESYS13
Revision_
|
00001 00002 /******************************************************* 00003 * 00004 * Copyright (c) 2003-2012 by University of Queensland 00005 * Earth Systems Science Computational Center (ESSCC) 00006 * http://www.uq.edu.au/esscc 00007 * 00008 * Primary Business: Queensland, Australia 00009 * Licensed under the Open Software License version 3.0 00010 * http://www.opensource.org/licenses/osl-3.0.php 00011 * 00012 *******************************************************/ 00013 00014 #ifndef __WEIPA_FILEWRITER_H__ 00015 #define __WEIPA_FILEWRITER_H__ 00016 00017 #include <weipa/weipa.h> 00018 00019 #include <fstream> 00020 00021 namespace weipa { 00022 00023 class FileWriter 00024 { 00025 public: 00026 FileWriter(); 00027 00028 #if HAVE_MPI 00029 FileWriter(MPI_Comm comm); 00030 #endif 00031 00032 bool openFile(std::string filename); 00033 bool writeOrdered(std::ostringstream& oss); 00034 bool writeShared(std::ostringstream& oss); 00035 void close(); 00036 00037 private: 00038 int mpiRank, mpiSize; 00039 #if HAVE_MPI 00040 MPI_Comm mpiComm; 00041 MPI_File fileHandle; 00042 #else 00043 void* mpiComm; 00044 #endif 00045 std::ofstream ofs; 00046 }; 00047 00048 } // namespace weipa 00049 00050 #endif // __WEIPA_FILEWRITER_H__ 00051