76 |
|
char* ffPath_env = "FORCE_PARAM_PATH"; |
77 |
|
char* ffPath; |
78 |
|
char temp[200]; |
79 |
+ |
char errMsg[1000]; |
80 |
|
|
81 |
|
#ifdef IS_MPI |
82 |
|
int i; |
83 |
|
int mpiError; |
84 |
+ |
int cleanOpen = 0; |
85 |
|
|
86 |
|
mpiError = MPI_Comm_rank(MPI_COMM_WORLD,&myNode); |
87 |
|
|
183 |
|
// generate the force file name |
184 |
|
|
185 |
|
strcpy( fileName, "TraPPE_Ex.frc" ); |
186 |
< |
fprintf( stderr,"Trying to open %s\n", fileName ); |
186 |
> |
// fprintf( stderr,"Trying to open %s\n", fileName ); |
187 |
|
|
188 |
|
// attempt to open the file in the current directory first. |
189 |
|
|
195 |
|
|
196 |
|
ffPath = getenv( ffPath_env ); |
197 |
|
if( ffPath == NULL ) { |
198 |
< |
fprintf( stderr, |
198 |
> |
sprintf( errMsg, |
199 |
|
"Error opening the force field parameter file: %s\n" |
200 |
|
"Have you tried setting the FORCE_PARAM_PATH environment " |
201 |
|
"vairable?\n", |
202 |
|
fileName ); |
203 |
< |
exit( 8 ); |
203 |
> |
#ifdef IS_MPI |
204 |
> |
cleanOpen = 0; |
205 |
> |
mpiError = MPI_Bcast(cleanOpen,1,MPI_INT,0,MPI_COMM_WORLD); |
206 |
> |
#endif |
207 |
> |
ffError( errMsg ); |
208 |
|
} |
209 |
|
|
210 |
|
|
217 |
|
|
218 |
|
if( frcFile == NULL ){ |
219 |
|
|
220 |
< |
fprintf( stderr, |
220 |
> |
sprintf( errMsg, |
221 |
|
"Error opening the force field parameter file: %s\n" |
222 |
|
"Have you tried setting the FORCE_PARAM_PATH environment " |
223 |
|
"vairable?\n", |
224 |
|
fileName ); |
225 |
< |
exit( 8 ); |
225 |
> |
#ifdef IS_MPI |
226 |
> |
cleanOpen = 0; |
227 |
> |
mpiError = MPI_Bcast(cleanOpen,1,MPI_INT,0,MPI_COMM_WORLD); |
228 |
> |
#endif |
229 |
> |
ffError( errMsg ); |
230 |
|
} |
231 |
|
} |
232 |
+ |
cleanOpen = 1; |
233 |
|
#ifdef IS_MPI |
234 |
|
} |
235 |
+ |
|
236 |
+ |
mpiError = MPI_Bcast(cleanOpen,1,MPI_INT,0,MPI_COMM_WORLD); |
237 |
+ |
if( !cleanOpen ) fferror( NULL ); |
238 |
|
#endif |
239 |
|
} |
240 |
|
|
300 |
|
LinkedType* currentAtomType; |
301 |
|
LinkedType* tempAtomType; |
302 |
|
|
303 |
+ |
#ifdef IS_MPI |
304 |
+ |
atomStruct info; |
305 |
+ |
info.last = -1; // initialize last to have the error set. |
306 |
+ |
// if things go well, last will be set to 0 |
307 |
+ |
#endif |
308 |
+ |
|
309 |
+ |
|
310 |
|
char readLine[500]; |
311 |
|
char* the_token; |
312 |
|
char* eof_test; |
313 |
|
int foundAtom = 0; |
314 |
|
int lineNum = 0; |
315 |
|
int i; |
316 |
+ |
char errMsg[1000]; |
317 |
+ |
|
318 |
|
|
319 |
|
////////////////////////////////////////////////// |
320 |
|
// a quick water fix |
369 |
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
370 |
|
lineNum++; |
371 |
|
if( eof_test == NULL ){ |
372 |
< |
fprintf( stderr, "Error in reading Atoms from force file.\n" ); |
373 |
< |
exit(8); |
372 |
> |
sprintf( errMsg, "Error in reading Atoms from force file.\n" ); |
373 |
> |
#ifdef IS_MPI |
374 |
> |
sendFrcStruct( &info, mpiAtomStructType ); |
375 |
> |
#endif |
376 |
> |
ffError(errMsg); |
377 |
|
} |
378 |
|
|
379 |
|
|
383 |
|
lineNum++; |
384 |
|
} |
385 |
|
if( eof_test == NULL ){ |
386 |
< |
fprintf( stderr, |
386 |
> |
sprintf( errMsg, |
387 |
|
"Error in reading Atoms from force file at line %d.\n", |
388 |
|
lineNum ); |
389 |
< |
exit(8); |
389 |
> |
#ifdef IS_MPI |
390 |
> |
sendFrcStruct( &info, mpiAtomStructType ); |
391 |
> |
#endif |
392 |
> |
ffError(errMsg); |
393 |
|
} |
394 |
|
|
395 |
|
the_token = strtok( readLine, " ,;\t#\n" ); |
400 |
|
lineNum++; |
401 |
|
|
402 |
|
if( eof_test == NULL ){ |
403 |
< |
fprintf( stderr, |
403 |
> |
sprintf( errMsg, |
404 |
|
"Error in reading Atoms from force file at line %d.\n", |
405 |
|
lineNum ); |
406 |
< |
exit(8); |
406 |
> |
#ifdef IS_MPI |
407 |
> |
sendFrcStruct( &info, mpiAtomStructType ); |
408 |
> |
#endif |
409 |
> |
ffError(errMsg); |
410 |
|
} |
411 |
|
} |
412 |
|
} |
417 |
|
lineNum++; |
418 |
|
|
419 |
|
if( eof_test == NULL ){ |
420 |
< |
fprintf( stderr, |
420 |
> |
sprintf( errMsg, |
421 |
|
"Error in reading Atoms from force file at line %d.\n", |
422 |
|
lineNum ); |
423 |
< |
exit(8); |
423 |
> |
#ifdef IS_MPI |
424 |
> |
sendFrcStruct( &info, mpiAtomStructType ); |
425 |
> |
#endif |
426 |
> |
ffError(errMsg); |
427 |
|
} |
428 |
|
|
429 |
|
while( readLine[0] != '#' && eof_test != NULL ){ |
436 |
|
strcpy( currentAtomType->name, the_token ); |
437 |
|
|
438 |
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
439 |
< |
fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum ); |
440 |
< |
exit(8); |
439 |
> |
sprintf( errMsg, "Error parseing AtomTypes: line %d\n", lineNum ); |
440 |
> |
#ifdef IS_MPI |
441 |
> |
sendFrcStruct( &info, mpiAtomStructType ); |
442 |
> |
#endif |
443 |
> |
ffError(errMsg); |
444 |
|
} |
445 |
|
|
446 |
|
sscanf( the_token, "%d", ¤tAtomType->isDipole ); |
447 |
|
|
448 |
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
449 |
< |
fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum ); |
450 |
< |
exit(8); |
449 |
> |
sprintf( errMsg, "Error parseing AtomTypes: line %d\n", lineNum ); |
450 |
> |
#ifdef IS_MPI |
451 |
> |
sendFrcStruct( &info, mpiAtomStructType ); |
452 |
> |
#endif |
453 |
> |
ffError(errMsg); |
454 |
|
} |
455 |
|
|
456 |
|
sscanf( the_token, "%lf", ¤tAtomType->mass ); |
457 |
|
|
458 |
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
459 |
< |
fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum ); |
460 |
< |
exit(8); |
459 |
> |
sprintf( errMsg, "Error parseing AtomTypes: line %d\n", lineNum ); |
460 |
> |
#ifdef IS_MPI |
461 |
> |
sendFrcStruct( &info, mpiAtomStructType ); |
462 |
> |
#endif |
463 |
> |
ffError(errMsg); |
464 |
|
} |
465 |
|
|
466 |
|
sscanf( the_token, "%lf", ¤tAtomType->epslon ); |
467 |
|
|
468 |
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
469 |
< |
fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum ); |
470 |
< |
exit(8); |
469 |
> |
sprintf( errMsg, "Error parseing AtomTypes: line %d\n", lineNum ); |
470 |
> |
#ifdef IS_MPI |
471 |
> |
sendFrcStruct( &info, mpiAtomStructType ); |
472 |
> |
#endif |
473 |
> |
ffError(errMsg); |
474 |
|
} |
475 |
|
|
476 |
|
sscanf( the_token, "%lf", ¤tAtomType->sigma ); |
477 |
|
|
478 |
|
if( currentAtomType->isDipole ){ |
479 |
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
480 |
< |
fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum ); |
481 |
< |
exit(8); |
480 |
> |
sprintf( errMsg, "Error parseing AtomTypes: line %d\n", |
481 |
> |
lineNum ); |
482 |
> |
#ifdef IS_MPI |
483 |
> |
sendFrcStruct( &info, mpiAtomStructType ); |
484 |
> |
#endif |
485 |
> |
ffError(errMsg); |
486 |
|
} |
487 |
|
|
488 |
|
sscanf( the_token, "%lf", ¤tAtomType->dipole ); |
499 |
|
} |
500 |
|
|
501 |
|
#ifdef IS_MPI |
502 |
+ |
|
503 |
+ |
// send out the linked list to all the other processes |
504 |
+ |
|
505 |
+ |
currentAtomType = headAtomType; |
506 |
+ |
while( currentAtomType != NULL ){ |
507 |
+ |
currentAtomType->duplicate( info ); |
508 |
+ |
sendFrcStruct( &info, mpiAtomStructType ); |
509 |
+ |
currentAtomType = currentAtomType->next; |
510 |
+ |
} |
511 |
+ |
info.last = 1; |
512 |
+ |
sendFrcStruct( &info, mpiAtomStructType ); |
513 |
+ |
|
514 |
|
} |
515 |
|
|
516 |
|
else{ |
517 |
|
|
518 |
< |
// listen for the structs |
518 |
> |
// listen for node 0 to send out the force params |
519 |
> |
|
520 |
> |
headAtomType = new LinkedType; |
521 |
> |
recieveFrcStruct( &info, mpiAtomStructType ); |
522 |
> |
while( !info.last ){ |
523 |
> |
|
524 |
> |
headAtomType->add( info ); |
525 |
> |
recieveFrcStruct( &info, mpiAtomStructType ); |
526 |
> |
} |
527 |
> |
|
528 |
> |
if( info.last < 0 ) ffError( NULL ); // an error has occured, exit quietly. |
529 |
> |
|
530 |
|
|
531 |
|
} |
532 |
|
#endif |
540 |
|
|
541 |
|
currentAtomType = headAtomType->find( the_atoms[i]->getType() ); |
542 |
|
if( currentAtomType == NULL ){ |
543 |
< |
fprintf( stderr, "AtomType error, %s not found in force file.\n", |
543 |
> |
sprintf( errMsg, "AtomType error, %s not found in force file.\n", |
544 |
|
the_atoms[i]->getType() ); |
545 |
< |
exit(8); |
545 |
> |
ffError(errMsg); |
546 |
|
} |
547 |
|
|
548 |
|
the_atoms[i]->setMass( currentAtomType->mass ); |
569 |
|
dAtom->setSSD( 0 ); |
570 |
|
} |
571 |
|
else{ |
572 |
< |
fprintf(stderr, |
572 |
> |
sprintf(errMsg, |
573 |
|
"AtmType error, %s does not have a moment of inertia set.\n", |
574 |
|
the_atoms[i]->getType() ); |
575 |
< |
exit(8); |
575 |
> |
ffError(errMsg); |
576 |
|
} |
577 |
|
entry_plug->n_dipoles++; |
578 |
|
} |
579 |
|
else{ |
580 |
< |
std::cerr |
581 |
< |
<< "TraPPE_ExFF error: Atom \"" |
582 |
< |
<< currentAtomType->name << "\" is a dipole, yet no standard" |
583 |
< |
<< " orientation was specifed in the BASS file.\n"; |
584 |
< |
exit(8); |
580 |
> |
|
581 |
> |
sprintf( errMsg, |
582 |
> |
"TraPPE_ExFF error: Atom \"%s\" is a dipole, yet no standard" |
583 |
> |
" orientation was specifed in the BASS file.\n", |
584 |
> |
currentAtomType->name ); |
585 |
> |
|
586 |
> |
ffError(errMsg); |
587 |
|
} |
588 |
|
} |
589 |
|
else{ |
590 |
|
if( the_atoms[i]->isDirectional() ){ |
591 |
< |
std::cerr |
592 |
< |
<< "TraPPE_ExFF error: Atom \"" |
593 |
< |
<< currentAtomType->name << "\" was given a standard orientation" |
594 |
< |
<< " in the BASS file, yet it is not a dipole.\n"; |
595 |
< |
exit(8); |
591 |
> |
sprintf( errMsg, |
592 |
> |
"TraPPE_ExFF error: Atom \"%s\" was given a standard" |
593 |
> |
"orientation in the BASS file, yet it is not a dipole.\n", |
594 |
> |
currentAtomType->name); |
595 |
> |
ffError(errMsg); |
596 |
|
} |
597 |
|
} |
598 |
|
} |