ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/md_code/InitializeFromFile.cpp
(Generate patch)

Comparing trunk/mdtools/md_code/InitializeFromFile.cpp (file contents):
Revision 212 by chuckv, Fri Dec 13 21:17:00 2002 UTC vs.
Revision 260 by chuckv, Fri Jan 31 21:04:27 2003 UTC

# Line 11 | Line 11
11   #include "ReadWrite.hpp"
12   #include "simError.h"
13  
14 + #ifdef IS_MPI
15 + #include "mpiSimulation.hpp"
16  
17 + #define TAKE_THIS_TAG 0
18 + #endif // is_mpi
19 +
20   InitializeFromFile :: InitializeFromFile( char *in_name ){
21   #ifdef IS_MPI
22    if (worldRank == 0) {
# Line 68 | Line 73 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
73  
74    char *eof_test; // ptr to see when we reach the end of the file
75    char *parseErr;
76 +  int procIndex;
77  
78 +  entry_plug = the_entry_plug;
79  
73  entry_plug = the_entry_plug
80  
75
81   #ifndef IS_MPI
82    eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file);
83    if( eof_test == NULL ){
# Line 158 | Line 163 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
163      // Check to see that the number of atoms in the intial configuration file is the
164      // same as declared in simBass.
165      
166 <    if( n_atoms != entry_plug->mpiSim->getTotAtoms() ){
166 >    if( n_atoms != mpiSim->getTotAtoms() ){
167        sprintf( painCave.errMsg,
168                 "Initialize from File error. %s n_atoms, %d, "
169                 "does not match the BASS file's n_atoms, %d.\n",
# Line 179 | Line 184 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
184    
185      // Read Proc 0 share of the xyz file...
186      masterIndex = 0;
187 <    for( i=0; i <= entry_plug->mpiSim->getMyAtomEnd(); i++){
187 >    for( i=0; i <= mpiSim->getMyAtomEnd(); i++){
188      
189        eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file);
190        if(eof_test == NULL){
# Line 204 | Line 209 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
209  
210    sprintf(checkPointMsg,
211            "Node 0 has successfully read positions from input file.");
212 <  mpiCheckPoint();
212 >  MPIcheckPoint();
213  
214 <  for (procIndex = 1; procIndex < entryPlug->mpiSim->getNumberProcessors();
214 >  for (procIndex = 1; procIndex < mpiSim->getNumberProcessors();
215           procIndex++){
216      if (worldRank == 0) {
217  
218 <      mpiErr = MPI_Recv(&nodeAtomsStart,1,MPI_INT,procIndex,MPI_ANY_TAG,MPI_COMM_WORLD,
218 >      mpiErr = MPI_Recv(&nodeAtomsStart,1,MPI_INT,procIndex,TAKE_THIS_TAG,MPI_COMM_WORLD,
219                 istatus);
220  
221 <      mpiErr = MPI_Recv(&nodeAtomsEnd,1,MPI_INT,procIndex,MPI_ANY_TAG,MPI_COMM_WORLD,
221 >      mpiErr = MPI_Recv(&nodeAtomsEnd,1,MPI_INT,procIndex,TAKE_THIS_TAG,MPI_COMM_WORLD,
222                 istatus);
223        // Make sure where node 0 is reading from, matches where the receiving node
224        // expects it to be.
225  
226        if (masterIndex != nodeAtomsStart){
227          sendError = 1;
228 <        mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,MPI_ANY_TAG,MPI_COMM_WORLD);
228 >        mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,TAKE_THIS_TAG,MPI_COMM_WORLD);
229          sprintf(painCave.errMsg,
230                  "Initialize from file error: atoms start index (%d) for "
231                  "node %d not equal to master index (%d)",nodeAtomsStart,procIndex,masterIndex );
# Line 228 | Line 233 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
233          simError();
234        }
235        sendError = 0;
236 <      mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,MPI_ANY_TAG,MPI_COMM_WORLD);
236 >      mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,TAKE_THIS_TAG,MPI_COMM_WORLD);
237        
238 <      for ( i = nodeAtomStart; i <= nodeAtomEnd, i++){
238 >      for ( i = nodeAtomsStart; i <= nodeAtomsEnd; i++){
239          eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file);
240          if(eof_test == NULL){
241            
242            sprintf(read_buffer,"ERROR");
243 <          mpiErr = MPI_Send(read_buffer,BUFFERSIZE,MPI_CHAR,procIndex,MPI_ANY_TAG,MPI_COMM_WORLD);
243 >          mpiErr = MPI_Send(read_buffer,BUFFERSIZE,MPI_CHAR,procIndex,TAKE_THIS_TAG,MPI_COMM_WORLD);
244            
245            sprintf(painCave.errMsg,
246                    "error in reading file %s\n"
# Line 246 | Line 251 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
251            simError();
252          }
253          
254 <        mpiErr = MPI_Send(read_buffer,BUFFERSIZE,MPI_CHAR,procIndex,MPI_ANY_TAG,MPI_COMM_WORLD);
255 <        mpiErr = MPI_Recv(&sendError,1,MPI_INT,procIndex,MPI_ANY_TAG,MPI_COMM_WORLD,
254 >        mpiErr = MPI_Send(read_buffer,BUFFERSIZE,MPI_CHAR,procIndex,TAKE_THIS_TAG,MPI_COMM_WORLD);
255 >        mpiErr = MPI_Recv(&sendError,1,MPI_INT,procIndex,TAKE_THIS_TAG,MPI_COMM_WORLD,
256                            istatus);
257 <        if (sendError) mpiCheckpoint();
257 >        if (sendError) MPIcheckPoint();
258  
259          masterIndex++;
260        }
# Line 257 | Line 262 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
262  
263  
264      else if(worldRank == procIndex){
265 <      nodeAtomStart = entry_plug->mpiSim->getMyAtomStart();
266 <      nodeAtomEnd = entry_plug->mpiSim->getMyAtomEnd();
267 <      mpiErr = MPI_Send(&nodeAtomsStart,1,MPI_INT,0,MPI_ANY_TAG,MPI_COMM_WORLD);
268 <      mpiErr = MPI_Send(&nodeAtomsEnd,1,MPI_INT,0,MPI_ANY_TAG,MPI_COMM_WORLD);
265 >      nodeAtomsStart = mpiSim->getMyAtomStart();
266 >      nodeAtomsEnd = mpiSim->getMyAtomEnd();
267 >      mpiErr = MPI_Send(&nodeAtomsStart,1,MPI_INT,0,TAKE_THIS_TAG,MPI_COMM_WORLD);
268 >      mpiErr = MPI_Send(&nodeAtomsEnd,1,MPI_INT,0,TAKE_THIS_TAG,MPI_COMM_WORLD);
269        
270 <      mpiErr = MPI_Recv(&sendError,1,MPI_INT,0,MPI_ANY_TAG,MPI_COMM_WORLD,
270 >      mpiErr = MPI_Recv(&sendError,1,MPI_INT,0,TAKE_THIS_TAG,MPI_COMM_WORLD,
271                 istatus);
272 <      if (sendError) mpiCheckpoint();
272 >      if (sendError) MPIcheckPoint();
273  
274 <      for ( i = 0; i < entry_plug->n_atoms, i++){
274 >      for ( i = 0; i < entry_plug->n_atoms; i++){
275  
276 <        mpiErr = MPI_Recv(&read_buffer,BUFFERSIZE,MPI_CHAR,0,MPI_ANY_TAG,MPI_COMM_WORLD,
276 >        mpiErr = MPI_Recv(&read_buffer,BUFFERSIZE,MPI_CHAR,0,TAKE_THIS_TAG,MPI_COMM_WORLD,
277                            istatus);
278          
279 <        if(!strcmp(read_buffer, "ERROR")) mpiCheckPoint();
279 >        if(!strcmp(read_buffer, "ERROR")) MPIcheckPoint();
280          
281          parseErr = parseDumpLine( read_buffer, i );
282          if( parseErr != NULL ){
283            sendError = 1;
284 <          mpiErr = MPI_Send(&sendError,1,MPI_INT,0,MPI_ANY_TAG,MPI_COMM_WORLD);
284 >          mpiErr = MPI_Send(&sendError,1,MPI_INT,0,TAKE_THIS_TAG,MPI_COMM_WORLD);
285  
286  
287            strcpy( painCave.errMsg, parseErr );
# Line 284 | Line 289 | void InitializeFromFile :: read_xyz( SimInfo* the_entr
289            simError();
290          }
291          sendError = 0;
292 <        mpiErr = MPI_Send(&sendError,1,MPI_INT,0,MPI_ANY_TAG,MPI_COMM_WORLD);
292 >        mpiErr = MPI_Send(&sendError,1,MPI_INT,0,TAKE_THIS_TAG,MPI_COMM_WORLD);
293        }
294      }
295      sprintf(checkPointMsg,"Node %d received initial configuration.",procIndex);
296 <    mpiCheckPoint();
296 >    MPIcheckPoint();
297    }
298  
299   #endif
300   }
301  
302  
303 < char* IntitializeFromFile::parseDumpLine(char* readLine, int atomIndex){
303 > char* InitializeFromFile::parseDumpLine(char* readLine, int atomIndex){
304  
305    char *foo; // the pointer to the current string token
306    
# Line 311 | Line 316 | char* IntitializeFromFile::parseDumpLine(char* readLin
316    int n_atoms;
317  
318   #ifdef IS_MPI
319 <  n_atoms = entry_plug->mpiSim->getTotAtoms();
319 >  n_atoms = mpiSim->getTotAtoms();
320   #else
321    n_atoms = entry_plug->n_atoms;
322 < #endi // is_mpi
322 > #endif // is_mpi
323  
324  
325    // set the string tokenizer

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines