| 1 |
|
#ifndef __READWRITE_H__ |
| 2 |
|
#define __READWRITE_H__ |
| 3 |
< |
|
| 3 |
> |
#define _LARGEFILE_SOURCE64 |
| 4 |
|
#define _FILE_OFFSET_BITS 64 |
| 5 |
– |
|
| 5 |
|
#include <iostream> |
| 6 |
|
#include <fstream> |
| 7 |
|
|
| 8 |
< |
#include <cstring> |
| 9 |
< |
#include <cstdio> |
| 10 |
< |
#include <cstdlib> |
| 8 |
> |
#include <string.h> |
| 9 |
> |
#include <stdio.h> |
| 10 |
> |
#include <stdlib.h> |
| 11 |
|
#include <unistd.h> |
| 12 |
|
#include <sys/types.h> |
| 13 |
|
#include <sys/stat.h> |
| 20 |
|
using namespace std; |
| 21 |
|
|
| 22 |
|
class FilePos{ |
| 23 |
< |
|
| 23 |
> |
|
| 24 |
|
public: |
| 25 |
< |
FilePos(){ |
| 25 |
> |
FilePos(){ |
| 26 |
|
myPos = NULL; |
| 27 |
|
next = NULL; |
| 28 |
|
} |
| 29 |
< |
FilePos( fpos_t* thePos ) { |
| 30 |
< |
myPos = thePos; |
| 29 |
> |
FilePos( fpos_t* thePos ) { |
| 30 |
> |
myPos = thePos; |
| 31 |
|
next = NULL; |
| 32 |
|
} |
| 33 |
< |
~FilePos(){ |
| 33 |
> |
~FilePos(){ |
| 34 |
|
if( next != NULL ) delete next; |
| 35 |
|
if( myPos != NULL ) delete myPos; |
| 36 |
|
} |
| 37 |
< |
|
| 37 |
> |
|
| 38 |
|
void add( fpos_t *thePos ){ |
| 39 |
< |
if( next != NULL ) |
| 39 |
> |
if( next != NULL ) |
| 40 |
|
next->add( thePos ); |
| 41 |
|
else |
| 42 |
|
next = new FilePos( thePos ); |
| 43 |
|
} |
| 44 |
< |
|
| 44 |
> |
|
| 45 |
|
FilePos &operator=(fpos_t *thePos){ myPos = thePos; return *this; } |
| 46 |
< |
|
| 46 |
> |
|
| 47 |
|
void setPos( fpos_t *thePos ){ myPos = thePos; } |
| 48 |
|
fpos_t *getPos( void ){ return myPos; } |
| 49 |
< |
|
| 49 |
> |
|
| 50 |
|
FilePos* getNext( void ) { return next; } |
| 51 |
|
private: |
| 52 |
< |
|
| 52 |
> |
|
| 53 |
|
fpos_t *myPos; |
| 54 |
|
FilePos* next; |
| 55 |
< |
|
| 55 |
> |
|
| 56 |
|
}; |
| 57 |
|
|
| 58 |
|
class DumpWriter{ |
| 62 |
|
~DumpWriter(); |
| 63 |
|
|
| 64 |
|
void writeDump( double currentTime ); |
| 65 |
< |
void writeFinal( double finalTime ); |
| 65 |
> |
void writeFinal( double currentTime); |
| 66 |
> |
void writeFrame( vector<ofstream*>& outFile, double finalTime ); |
| 67 |
|
|
| 68 |
+ |
#ifdef IS_MPI |
| 69 |
+ |
void update(); |
| 70 |
+ |
#endif |
| 71 |
+ |
|
| 72 |
|
private: |
| 73 |
+ |
|
| 74 |
+ |
#ifdef IS_MPI |
| 75 |
+ |
void sortByGlobalIndex(); |
| 76 |
+ |
#endif |
| 77 |
+ |
|
| 78 |
|
SimInfo* entry_plug; |
| 79 |
< |
ofstream outFile; |
| 80 |
< |
char outName[500]; |
| 79 |
> |
ofstream dumpFile; |
| 80 |
> |
|
| 81 |
> |
#ifdef IS_MPI |
| 82 |
> |
vector<pair<int, int> > indexArray; |
| 83 |
> |
#endif |
| 84 |
|
}; |
| 85 |
|
|
| 86 |
|
class StatWriter{ |
| 90 |
|
~StatWriter(); |
| 91 |
|
|
| 92 |
|
void writeStat( double currentTime ); |
| 93 |
< |
|
| 93 |
> |
|
| 94 |
|
private: |
| 95 |
< |
|
| 95 |
> |
|
| 96 |
|
SimInfo* entry_plug; |
| 97 |
|
ofstream outFile; |
| 98 |
|
char outName[500]; |
| 107 |
|
~InitializeFromFile(); |
| 108 |
|
|
| 109 |
|
void readInit( SimInfo* the_entry_plug ); |
| 110 |
< |
|
| 110 |
> |
|
| 111 |
|
private: |
| 112 |
|
char* parseDumpLine(char* line, int atomIndex); |
| 113 |
< |
char* parseBoxLine(char* line, double boxMat[9], double &time ); |
| 113 |
> |
char* parseCommentLine(char* line, SimInfo* entry_plug); |
| 114 |
|
FILE *c_in_file; |
| 115 |
|
char c_in_name[500]; |
| 116 |
|
SimInfo* simnfo; |
| 119 |
|
class DumpReader{ |
| 120 |
|
|
| 121 |
|
public: |
| 122 |
< |
DumpReader( char *in_name ); |
| 122 |
> |
DumpReader(const char *in_name ); |
| 123 |
|
~DumpReader(); |
| 124 |
|
|
| 125 |
|
int getNframes(); |
| 137 |
|
char inName[500]; |
| 138 |
|
bool isScanned; |
| 139 |
|
int nFrames; |
| 140 |
< |
|
| 140 |
> |
|
| 141 |
|
FilePos** frameStart; |
| 142 |
|
FilePos* headFP; |
| 143 |
|
|