ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ZConsReader.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/ZConsReader.cpp (file contents):
Revision 1097 by gezelter, Mon Apr 12 20:32:20 2004 UTC vs.
Revision 1252 by gezelter, Mon Jun 7 14:26:33 2004 UTC

# Line 6 | Line 6 | ZConsReader::ZConsReader(SimInfo* info)
6  
7    GenericData* data;
8    StringData* filename;
9
10  assert(info != NULL);
11
9    this->info = info;
10  
11   //retrieve output filename of z force
# Line 51 | Line 48 | ZConsReader::~ZConsReader(){
48    readHeader();  
49   }
50  
51 + ZConsReader::ZConsReader(const string& filename){
52 +  istream = new ifstream(zconsFileName.c_str());
53 +
54 +  if (!istream){
55 +    cerr << "open " << filename << "error" << endl;
56 +    exit(1);
57 +  }
58 +  
59 +  readHeader();  
60 + }
61 +
62   ZConsReader::~ZConsReader(){
63    istream->close();
64   }
# Line 118 | Line 126 | void ZConsReader::readHeader(){
126      zconsPos.push_back(zmolPos);
127    }
128  
129 +  curZPos.resize(nZMol);
130 +  curFZ.resize(nZMol);
131   }
132  
133   void ZConsReader::readNextFrame(){
134    const int MAXBUFFERSIZE = 2000;
135    char line[MAXBUFFERSIZE];  
136    int tempNZMol;
127  int zmolIndex;
128  float zmolPos;
129  float zmolForce;
137    int sscanfCount;
138 <
138 >  int tempIndex;
139 >  float tempCurTime;
140 >  float tempFZ;
141 >  float tempCurZPos;
142 >  float tempZconsPos;
143 >  
144    istream->getline(line, MAXBUFFERSIZE);
145 <  sscanfCount = sscanf(line, "%lf", &curTime);
145 >  sscanfCount = sscanf(line, "%f", &tempCurTime);
146    if (sscanfCount != 1){
147      cerr << "ZConsReader Error : reading file error" << endl;
148      exit(1);
149    }
150 +  curTime = tempCurTime;
151    
152    istream->getline(line, MAXBUFFERSIZE);
153    sscanfCount = sscanf(line, "%d", &tempNZMol);
# Line 150 | Line 163 | void ZConsReader::readNextFrame(){
163  
164    for(int i = 0; i < nZMol; i++){
165      istream->getline(line, MAXBUFFERSIZE);
166 <    sscanfCount = sscanf(line, "%d\t%f\t%f", &zmolIndex, &zmolForce, &zmolPos);
167 <    if (sscanfCount != 3){
166 >    sscanfCount = sscanf(line, "%d\t%f\t%f\t%f", &tempIndex, &tempFZ, &tempCurZPos,&tempZconsPos);
167 >    if (sscanfCount != 4){
168        cerr << "ZConsReader Error : reading file error" << endl;
169        exit(1);
170      }
171 +
172 +    index[i] = tempIndex;
173 +    curFZ[i] = tempFZ;
174 +    curZPos[i]= tempCurZPos;
175 +    zconsPos[i] = tempZconsPos;
176    }
177  
178   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines