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

Comparing trunk/mdtools/interface_implementation/TraPPE_ExFF.cpp (file contents):
Revision 146 by mmeineke, Fri Oct 18 16:15:05 2002 UTC vs.
Revision 147 by mmeineke, Fri Oct 18 20:35:33 2002 UTC

# Line 11 | Line 11 | int myNode;
11  
12   #ifdef IS_MPI
13  
14 + #include "mpiForceField.h"
15 +
16   int myNode;
17  
18   // Declare the structures that will be passed by MPI
# Line 78 | Line 80 | TraPPE_ExFF::TraPPE_ExFF(){
80   #ifdef IS_MPI
81    int i;
82    int mpiError;
83 <
83 >  
84    mpiError = MPI_Comm_rank(MPI_COMM_WORLD,&myNode);
85 +  
86 +  // **********************************************************************
87 +  // Init the atomStruct mpi type
88  
89    atomStruct atomProto; // mpiPrototype
90    int atomBC[3] = {15,4,2};  // block counts
# Line 102 | Line 107 | TraPPE_ExFF::TraPPE_ExFF(){
107    MPI_Type_commit(&mpiAtomStructType);
108  
109  
110 +  // **********************************************************************
111 +  // Init the bondStruct mpi type
112 +  
113 +  bondStruct bondProto; // mpiPrototype
114 +  int bondBC[3] = {60,1,1};  // block counts
115 +  MPI_Aint bondDspls[3];           // displacements
116 +  MPI_Datatype bondMbrTypes[3];    // member mpi types
117 +  
118 +  MPI_Address(&bondProto.nameA, &bondDspls[0]);
119 +  MPI_Address(&bondProto.d0,    &bondDspls[1]);
120 +  MPI_Address(&bondProto.last,  &bondDspls[2]);
121 +  
122 +  bondMbrTypes[0] = MPI_CHAR;
123 +  bondMbrTypes[1] = MPI_DOUBLE;
124 +  bondMbrTypes[2] = MPI_INT;
125 +  
126 +  for (i=2; i >= 0; i--) bondDspls[i] -= bondDspls[0];
127 +  
128 +  MPI_Type_struct(3, bondBC, bondDspls, bondMbrTypes, &mpiBondStructType);
129 +  MPI_Type_commit(&mpiBondStructType);
130  
131  
132 +  // **********************************************************************
133 +  // Init the bendStruct mpi type
134 +  
135 +  bendStruct bendProto; // mpiPrototype
136 +  int bendBC[3] = {75,4,1};  // block counts
137 +  MPI_Aint bendDspls[3];           // displacements
138 +  MPI_Datatype bendMbrTypes[3];    // member mpi types
139 +  
140 +  MPI_Address(&bendProto.nameA, &bendDspls[0]);
141 +  MPI_Address(&bendProto.k1,    &bendDspls[1]);
142 +  MPI_Address(&bendProto.last,  &bendDspls[2]);
143 +  
144 +  bendMbrTypes[0] = MPI_CHAR;
145 +  bendMbrTypes[1] = MPI_DOUBLE;
146 +  bendMbrTypes[2] = MPI_INT;
147 +  
148 +  for (i=2; i >= 0; i--) bendDspls[i] -= bendDspls[0];
149 +  
150 +  MPI_Type_struct(3, bendBC, bendDspls, bendMbrTypes, &mpiBendStructType);
151 +  MPI_Type_commit(&mpiBendStructType);
152 +
153 +
154 +  // **********************************************************************
155 +  // Init the torsionStruct mpi type
156 +  
157 +  torsionStruct torsionProto; // mpiPrototype
158 +  int torsionBC[3] = {90,4,1};  // block counts
159 +  MPI_Aint torsionDspls[3];           // displacements
160 +  MPI_Datatype torsionMbrTypes[3];    // member mpi types
161 +  
162 +  MPI_Address(&torsionProto.nameA, &torsionDspls[0]);
163 +  MPI_Address(&torsionProto.k1,    &torsionDspls[1]);
164 +  MPI_Address(&torsionProto.last,  &torsionDspls[2]);
165 +  
166 +  torsionMbrTypes[0] = MPI_CHAR;
167 +  torsionMbrTypes[1] = MPI_DOUBLE;
168 +  torsionMbrTypes[2] = MPI_INT;
169 +  
170 +  for (i=2; i >= 0; i--) torsionDspls[i] -= torsionDspls[0];
171 +  
172 +  MPI_Type_struct(3, torsionBC, torsionDspls, torsionMbrTypes,
173 +                  &mpiTorsionStructType);
174 +  MPI_Type_commit(&mpiTorsionStructType);
175 +
176 +  // ***********************************************************************
177 +  
178    if( myNode == 0 ){
179   #endif
180      
# Line 261 | Line 332 | void TraPPE_ExFF::initializeAtoms( void ){
332    the_atoms = entry_plug->atoms;
333    nAtoms = entry_plug->n_atoms;
334    
264  // read in the atom types.
265
266  rewind( frcFile );
267  headAtomType = new LinkedType;
268  currentAtomType = headAtomType;
335    
336 <  eof_test = fgets( readLine, sizeof(readLine), frcFile );
337 <  lineNum++;
338 <  if( eof_test == NULL ){
339 <    fprintf( stderr, "Error in reading Atoms from force file.\n" );
340 <    exit(8);
341 <  }
342 <
343 <  
344 <  while( !foundAtom ){
345 <    while( eof_test != NULL && readLine[0] != '#' ){
346 <      eof_test = fgets( readLine, sizeof(readLine), frcFile );
347 <      lineNum++;
282 <    }
336 > #ifdef IS_MPI
337 >  if( myNode == 0 ){
338 > #endif
339 >    
340 >    // read in the atom types.
341 >    
342 >    rewind( frcFile );
343 >    headAtomType = new LinkedType;
344 >    currentAtomType = headAtomType;
345 >    
346 >    eof_test = fgets( readLine, sizeof(readLine), frcFile );
347 >    lineNum++;
348      if( eof_test == NULL ){
349 <      fprintf( stderr,
285 <               "Error in reading Atoms from force file at line %d.\n",
286 <               lineNum );
349 >      fprintf( stderr, "Error in reading Atoms from force file.\n" );
350        exit(8);
351      }
289
290    the_token = strtok( readLine, " ,;\t#\n" );
291    foundAtom = !strcmp( "AtomTypes", the_token );
352      
353 <    if( !foundAtom ){
354 <      eof_test = fgets( readLine, sizeof(readLine), frcFile );
355 <      lineNum++;
356 <
353 >    
354 >    while( !foundAtom ){
355 >      while( eof_test != NULL && readLine[0] != '#' ){
356 >        eof_test = fgets( readLine, sizeof(readLine), frcFile );
357 >        lineNum++;
358 >      }
359        if( eof_test == NULL ){
360          fprintf( stderr,
361                   "Error in reading Atoms from force file at line %d.\n",
362                   lineNum );
363          exit(8);
364 <      }
364 >      }
365 >      
366 >      the_token = strtok( readLine, " ,;\t#\n" );
367 >      foundAtom = !strcmp( "AtomTypes", the_token );
368 >      
369 >      if( !foundAtom ){
370 >        eof_test = fgets( readLine, sizeof(readLine), frcFile );
371 >        lineNum++;
372 >        
373 >        if( eof_test == NULL ){
374 >          fprintf( stderr,
375 >                   "Error in reading Atoms from force file at line %d.\n",
376 >                   lineNum );
377 >          exit(8);
378 >        }
379 >      }
380      }
304  }
305
306  // we are now at the AtomTypes section.
307
308  eof_test = fgets( readLine, sizeof(readLine), frcFile );
309  lineNum++;
310  
311  if( eof_test == NULL ){
312    fprintf( stderr,
313             "Error in reading Atoms from force file at line %d.\n",
314             lineNum );
315    exit(8);
316  }
317
318  while( readLine[0] != '#' && eof_test != NULL ){
381      
382 <    if( readLine[0] != '!' ){
382 >    // we are now at the AtomTypes section.
383 >    
384 >    eof_test = fgets( readLine, sizeof(readLine), frcFile );
385 >    lineNum++;
386 >    
387 >    if( eof_test == NULL ){
388 >      fprintf( stderr,
389 >               "Error in reading Atoms from force file at line %d.\n",
390 >               lineNum );
391 >      exit(8);
392 >    }
393 >    
394 >    while( readLine[0] != '#' && eof_test != NULL ){
395        
396 <      the_token = strtok( readLine, " \n\t,;" );
323 <      if( the_token != NULL ){
396 >      if( readLine[0] != '!' ){
397          
398 <        strcpy( currentAtomType->name, the_token );
399 <
400 <        if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
401 <          fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum );
402 <          exit(8);
330 <        }
331 <
332 <        sscanf( the_token, "%d", &currentAtomType->isDipole );
333 <
334 <        if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
335 <          fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum );
336 <          exit(8);
337 <        }
338 <
339 <        sscanf( the_token, "%lf", &currentAtomType->mass );
340 <
341 <        if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
342 <          fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum );
343 <          exit(8);
344 <        }
345 <        
346 <        sscanf( the_token, "%lf", &currentAtomType->epslon );
347 <        
348 <        if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
349 <          fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum );
350 <          exit(8);
351 <        }
352 <
353 <        sscanf( the_token, "%lf", &currentAtomType->sigma );
354 <        
355 <        if( currentAtomType->isDipole ){
398 >        the_token = strtok( readLine, " \n\t,;" );
399 >        if( the_token != NULL ){
400 >          
401 >          strcpy( currentAtomType->name, the_token );
402 >          
403            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
404              fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum );
405              exit(8);
406            }
407            
408 <          sscanf( the_token, "%lf", &currentAtomType->dipole );
408 >          sscanf( the_token, "%d", &currentAtomType->isDipole );
409 >          
410 >          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
411 >            fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum );
412 >            exit(8);
413 >          }
414 >          
415 >          sscanf( the_token, "%lf", &currentAtomType->mass );
416 >          
417 >          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
418 >            fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum );
419 >            exit(8);
420 >          }
421 >          
422 >          sscanf( the_token, "%lf", &currentAtomType->epslon );
423 >          
424 >          if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
425 >            fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum );
426 >            exit(8);
427 >          }
428 >          
429 >          sscanf( the_token, "%lf", &currentAtomType->sigma );
430 >          
431 >          if( currentAtomType->isDipole ){
432 >            if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
433 >              fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum );
434 >              exit(8);
435 >            }
436 >            
437 >            sscanf( the_token, "%lf", &currentAtomType->dipole );
438 >          }
439          }
440        }
441 +      
442 +      tempAtomType = new LinkedType;
443 +      currentAtomType->next = tempAtomType;
444 +      currentAtomType = tempAtomType;
445 +      
446 +      eof_test = fgets( readLine, sizeof(readLine), frcFile );
447 +      lineNum++;
448      }
449 +
450 + #ifdef IS_MPI
451 +  }
452 +
453 +  else{
454      
455 <    tempAtomType = new LinkedType;
367 <    currentAtomType->next = tempAtomType;
368 <    currentAtomType = tempAtomType;
455 >    // listen for the structs
456      
370    eof_test = fgets( readLine, sizeof(readLine), frcFile );
371    lineNum++;
457    }
458 + #endif
459  
460    
461    // initialize the atoms

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines