ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ReadWrite.hpp
Revision: 1078
Committed: Tue Mar 2 20:32:40 2004 UTC (20 years, 4 months ago) by tim
File size: 2501 byte(s)
Log Message:
add LARGEFILE_SOURCE64 macro to support large file

File Contents

# Content
1 #ifndef __READWRITE_H__
2 #define __READWRITE_H__
3 #define _LARGEFILE_SOURCE64
4 #define _FILE_OFFSET_BITS 64
5 #include <iostream>
6 #include <fstream>
7
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>
14
15
16 #include "Atom.hpp"
17 #include "SimInfo.hpp"
18 #include "Thermo.hpp"
19
20 using namespace std;
21
22 class FilePos{
23
24 public:
25 FilePos(){
26 myPos = NULL;
27 next = NULL;
28 }
29 FilePos( fpos_t* thePos ) {
30 myPos = thePos;
31 next = NULL;
32 }
33 ~FilePos(){
34 if( next != NULL ) delete next;
35 if( myPos != NULL ) delete myPos;
36 }
37
38 void add( fpos_t *thePos ){
39 if( next != NULL )
40 next->add( thePos );
41 else
42 next = new FilePos( thePos );
43 }
44
45 FilePos &operator=(fpos_t *thePos){ myPos = thePos; return *this; }
46
47 void setPos( fpos_t *thePos ){ myPos = thePos; }
48 fpos_t *getPos( void ){ return myPos; }
49
50 FilePos* getNext( void ) { return next; }
51 private:
52
53 fpos_t *myPos;
54 FilePos* next;
55
56 };
57
58 class DumpWriter{
59
60 public:
61 DumpWriter( SimInfo* the_entry_plug );
62 ~DumpWriter();
63
64 void writeDump( double currentTime );
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 dumpFile;
80
81 #ifdef IS_MPI
82 vector<pair<int, int> > indexArray;
83 #endif
84 };
85
86 class StatWriter{
87
88 public:
89 StatWriter( SimInfo* the_entry_plug );
90 ~StatWriter();
91
92 void writeStat( double currentTime );
93
94 private:
95
96 SimInfo* entry_plug;
97 ofstream outFile;
98 char outName[500];
99 Thermo* tStats;
100
101 };
102
103 class InitializeFromFile{
104
105 public:
106 InitializeFromFile( char *in_name );
107 ~InitializeFromFile();
108
109 void readInit( SimInfo* the_entry_plug );
110
111 private:
112 char* parseDumpLine(char* line, int atomIndex);
113 char* parseCommentLine(char* line, SimInfo* entry_plug);
114 FILE *c_in_file;
115 char c_in_name[500];
116 SimInfo* simnfo;
117 };
118
119 class DumpReader{
120
121 public:
122 DumpReader(const char *in_name );
123 ~DumpReader();
124
125 int getNframes();
126 void scanFile( void );
127
128 void getNextFrame() {}
129 void readFrame(SimInfo* the_simnfo, int whichFrame);
130
131 private:
132
133 void readSet( int whichFrame );
134 char* parseDumpLine(char* line, int atomIndex);
135 char* parseCommentLine(char* line, double &time, double boxMat[9] );
136 FILE *inFile;
137 char inName[500];
138 bool isScanned;
139 int nFrames;
140
141 FilePos** frameStart;
142 FilePos* headFP;
143
144 SimInfo *simnfo;
145 };
146
147
148
149 #endif