| 9 |
|
#include "SRI.hpp" |
| 10 |
|
|
| 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 |
| 19 |
+ |
|
| 20 |
+ |
typedef struct{ |
| 21 |
+ |
char name[15]; |
| 22 |
+ |
double mass; |
| 23 |
+ |
double epslon; |
| 24 |
+ |
double sigma; |
| 25 |
+ |
double dipole; |
| 26 |
+ |
int isDipole; |
| 27 |
+ |
int last; // 0 -> default |
| 28 |
+ |
// 1 -> tells nodes to stop listening |
| 29 |
+ |
// -1 -> an error has occured. (handled in mpiForceField) |
| 30 |
+ |
} atomStruct; |
| 31 |
+ |
MPI_Datatype mpiAtomStructType; |
| 32 |
+ |
|
| 33 |
+ |
typedef struct{ |
| 34 |
+ |
char nameA[15]; |
| 35 |
+ |
char nameB[15]; |
| 36 |
+ |
char type[30]; |
| 37 |
+ |
double d0; |
| 38 |
+ |
int last; // 0 -> default |
| 39 |
+ |
// 1 -> tells nodes to stop listening |
| 40 |
+ |
// -1 -> an error has occured. (handled in mpiForceField) |
| 41 |
+ |
} bondStruct; |
| 42 |
+ |
MPI_Datatype mpiBondStructType; |
| 43 |
+ |
|
| 44 |
+ |
typedef struct{ |
| 45 |
+ |
char nameA[15]; |
| 46 |
+ |
char nameB[15]; |
| 47 |
+ |
char nameC[15]; |
| 48 |
+ |
char type[30]; |
| 49 |
+ |
double k1, k2, k3, t0; |
| 50 |
+ |
int last; // 0 -> default |
| 51 |
+ |
// 1 -> tells nodes to stop listening |
| 52 |
+ |
// -1 -> an error has occured. (handled in mpiForceField) |
| 53 |
+ |
} bendStruct; |
| 54 |
+ |
MPI_Datatype mpiBendStructType; |
| 55 |
+ |
|
| 56 |
+ |
typedef struct{ |
| 57 |
+ |
char nameA[15]; |
| 58 |
+ |
char nameB[15]; |
| 59 |
+ |
char nameC[15]; |
| 60 |
+ |
char nameD[15]; |
| 61 |
+ |
char type[30]; |
| 62 |
+ |
double k1, k2, k3, k4; |
| 63 |
+ |
int last; // 0 -> default |
| 64 |
+ |
// 1 -> tells nodes to stop listening |
| 65 |
+ |
// -1 -> an error has occured. (handled in mpiForceField) |
| 66 |
+ |
} TorsionStruct; |
| 67 |
+ |
MPI_Datatype mpiTorsionStructType; |
| 68 |
+ |
|
| 69 |
+ |
#endif |
| 70 |
+ |
|
| 71 |
+ |
|
| 72 |
+ |
|
| 73 |
|
TraPPE_ExFF::TraPPE_ExFF(){ |
| 74 |
|
|
| 75 |
|
char fileName[200]; |
| 76 |
|
char* ffPath_env = "FORCE_PARAM_PATH"; |
| 77 |
|
char* ffPath; |
| 78 |
|
char temp[200]; |
| 79 |
+ |
char errMsg[1000]; |
| 80 |
|
|
| 81 |
< |
// generate the force file name |
| 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 |
> |
|
| 88 |
> |
// ********************************************************************** |
| 89 |
> |
// Init the atomStruct mpi type |
| 90 |
|
|
| 91 |
< |
strcpy( fileName, "TraPPE_Ex.frc" ); |
| 91 |
> |
atomStruct atomProto; // mpiPrototype |
| 92 |
> |
int atomBC[3] = {15,4,2}; // block counts |
| 93 |
> |
MPI_Aint atomDspls[3]; // displacements |
| 94 |
> |
MPI_Datatype atomMbrTypes[3]; // member mpi types |
| 95 |
|
|
| 23 |
– |
// attempt to open the file in the current directory first. |
| 96 |
|
|
| 25 |
– |
frcFile = fopen( fileName, "r" ); |
| 97 |
|
|
| 98 |
< |
if( frcFile == NULL ){ |
| 98 |
> |
MPI_Address(&atomProto.name, &atomDspls[0]); |
| 99 |
> |
MPI_Address(&atomProto.mass, &atomDspls[1]); |
| 100 |
> |
MPI_Address(&atomProto.isDipole, &atomDspls[2]); |
| 101 |
> |
|
| 102 |
> |
atomMbrTypes[0] = MPI_CHAR; |
| 103 |
> |
atomMbrTypes[1] = MPI_DOUBLE; |
| 104 |
> |
atomMbrTypes[2] = MPI_INT; |
| 105 |
> |
|
| 106 |
> |
for (i=2; i >= 0; i--) atomDspls[i] -= atomDspls[0]; |
| 107 |
> |
|
| 108 |
> |
MPI_Type_struct(3, atomBC, atomDspls, atomMbrTypes, &mpiAtomStructType); |
| 109 |
> |
MPI_Type_commit(&mpiAtomStructType); |
| 110 |
|
|
| 29 |
– |
// next see if the force path enviorment variable is set |
| 30 |
– |
|
| 31 |
– |
ffPath = getenv( ffPath_env ); |
| 32 |
– |
strcpy( temp, ffPath ); |
| 33 |
– |
strcat( temp, "/" ); |
| 34 |
– |
strcat( temp, fileName ); |
| 35 |
– |
strcpy( fileName, temp ); |
| 111 |
|
|
| 112 |
+ |
// ********************************************************************** |
| 113 |
+ |
// Init the bondStruct mpi type |
| 114 |
+ |
|
| 115 |
+ |
bondStruct bondProto; // mpiPrototype |
| 116 |
+ |
int bondBC[3] = {60,1,1}; // block counts |
| 117 |
+ |
MPI_Aint bondDspls[3]; // displacements |
| 118 |
+ |
MPI_Datatype bondMbrTypes[3]; // member mpi types |
| 119 |
+ |
|
| 120 |
+ |
MPI_Address(&bondProto.nameA, &bondDspls[0]); |
| 121 |
+ |
MPI_Address(&bondProto.d0, &bondDspls[1]); |
| 122 |
+ |
MPI_Address(&bondProto.last, &bondDspls[2]); |
| 123 |
+ |
|
| 124 |
+ |
bondMbrTypes[0] = MPI_CHAR; |
| 125 |
+ |
bondMbrTypes[1] = MPI_DOUBLE; |
| 126 |
+ |
bondMbrTypes[2] = MPI_INT; |
| 127 |
+ |
|
| 128 |
+ |
for (i=2; i >= 0; i--) bondDspls[i] -= bondDspls[0]; |
| 129 |
+ |
|
| 130 |
+ |
MPI_Type_struct(3, bondBC, bondDspls, bondMbrTypes, &mpiBondStructType); |
| 131 |
+ |
MPI_Type_commit(&mpiBondStructType); |
| 132 |
+ |
|
| 133 |
+ |
|
| 134 |
+ |
// ********************************************************************** |
| 135 |
+ |
// Init the bendStruct mpi type |
| 136 |
+ |
|
| 137 |
+ |
bendStruct bendProto; // mpiPrototype |
| 138 |
+ |
int bendBC[3] = {75,4,1}; // block counts |
| 139 |
+ |
MPI_Aint bendDspls[3]; // displacements |
| 140 |
+ |
MPI_Datatype bendMbrTypes[3]; // member mpi types |
| 141 |
+ |
|
| 142 |
+ |
MPI_Address(&bendProto.nameA, &bendDspls[0]); |
| 143 |
+ |
MPI_Address(&bendProto.k1, &bendDspls[1]); |
| 144 |
+ |
MPI_Address(&bendProto.last, &bendDspls[2]); |
| 145 |
+ |
|
| 146 |
+ |
bendMbrTypes[0] = MPI_CHAR; |
| 147 |
+ |
bendMbrTypes[1] = MPI_DOUBLE; |
| 148 |
+ |
bendMbrTypes[2] = MPI_INT; |
| 149 |
+ |
|
| 150 |
+ |
for (i=2; i >= 0; i--) bendDspls[i] -= bendDspls[0]; |
| 151 |
+ |
|
| 152 |
+ |
MPI_Type_struct(3, bendBC, bendDspls, bendMbrTypes, &mpiBendStructType); |
| 153 |
+ |
MPI_Type_commit(&mpiBendStructType); |
| 154 |
+ |
|
| 155 |
+ |
|
| 156 |
+ |
// ********************************************************************** |
| 157 |
+ |
// Init the torsionStruct mpi type |
| 158 |
+ |
|
| 159 |
+ |
torsionStruct torsionProto; // mpiPrototype |
| 160 |
+ |
int torsionBC[3] = {90,4,1}; // block counts |
| 161 |
+ |
MPI_Aint torsionDspls[3]; // displacements |
| 162 |
+ |
MPI_Datatype torsionMbrTypes[3]; // member mpi types |
| 163 |
+ |
|
| 164 |
+ |
MPI_Address(&torsionProto.nameA, &torsionDspls[0]); |
| 165 |
+ |
MPI_Address(&torsionProto.k1, &torsionDspls[1]); |
| 166 |
+ |
MPI_Address(&torsionProto.last, &torsionDspls[2]); |
| 167 |
+ |
|
| 168 |
+ |
torsionMbrTypes[0] = MPI_CHAR; |
| 169 |
+ |
torsionMbrTypes[1] = MPI_DOUBLE; |
| 170 |
+ |
torsionMbrTypes[2] = MPI_INT; |
| 171 |
+ |
|
| 172 |
+ |
for (i=2; i >= 0; i--) torsionDspls[i] -= torsionDspls[0]; |
| 173 |
+ |
|
| 174 |
+ |
MPI_Type_struct(3, torsionBC, torsionDspls, torsionMbrTypes, |
| 175 |
+ |
&mpiTorsionStructType); |
| 176 |
+ |
MPI_Type_commit(&mpiTorsionStructType); |
| 177 |
+ |
|
| 178 |
+ |
// *********************************************************************** |
| 179 |
+ |
|
| 180 |
+ |
if( myNode == 0 ){ |
| 181 |
+ |
#endif |
| 182 |
+ |
|
| 183 |
+ |
// generate the force file name |
| 184 |
+ |
|
| 185 |
+ |
strcpy( fileName, "TraPPE_Ex.frc" ); |
| 186 |
+ |
// fprintf( stderr,"Trying to open %s\n", fileName ); |
| 187 |
+ |
|
| 188 |
+ |
// attempt to open the file in the current directory first. |
| 189 |
+ |
|
| 190 |
|
frcFile = fopen( fileName, "r" ); |
| 191 |
|
|
| 192 |
|
if( frcFile == NULL ){ |
| 193 |
|
|
| 194 |
< |
fprintf( stderr, |
| 195 |
< |
"Error opening the force field parameter file: %s\n" |
| 196 |
< |
"Have you tried setting the FORCE_PARAM_PATH environment " |
| 197 |
< |
"vairable?\n", |
| 198 |
< |
fileName ); |
| 199 |
< |
exit( 8 ); |
| 194 |
> |
// next see if the force path enviorment variable is set |
| 195 |
> |
|
| 196 |
> |
ffPath = getenv( ffPath_env ); |
| 197 |
> |
if( ffPath == NULL ) { |
| 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 |
> |
#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 |
> |
|
| 211 |
> |
strcpy( temp, ffPath ); |
| 212 |
> |
strcat( temp, "/" ); |
| 213 |
> |
strcat( temp, fileName ); |
| 214 |
> |
strcpy( fileName, temp ); |
| 215 |
> |
|
| 216 |
> |
frcFile = fopen( fileName, "r" ); |
| 217 |
> |
|
| 218 |
> |
if( frcFile == NULL ){ |
| 219 |
> |
|
| 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 |
> |
#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 |
|
|
| 241 |
+ |
|
| 242 |
|
TraPPE_ExFF::~TraPPE_ExFF(){ |
| 243 |
|
|
| 244 |
|
fclose( frcFile ); |
| 260 |
|
return NULL; |
| 261 |
|
} |
| 262 |
|
|
| 263 |
+ |
#ifdef IS_MPI |
| 264 |
+ |
void add( atomStruct &info ){ |
| 265 |
+ |
if( next != NULL ) next->add(info); |
| 266 |
+ |
else{ |
| 267 |
+ |
next = new LinkedType(); |
| 268 |
+ |
strcpy(next->name, info.name); |
| 269 |
+ |
next->isDipole = info.dipole; |
| 270 |
+ |
next->mass = info.mass; |
| 271 |
+ |
next->epslon = info.epslon; |
| 272 |
+ |
next->sigma = info.sigma; |
| 273 |
+ |
next->dipole = info.dipole; |
| 274 |
+ |
} |
| 275 |
+ |
} |
| 276 |
+ |
|
| 277 |
+ |
void duplicate( atomStruct &info ){ |
| 278 |
+ |
strcpy(info.name, name); |
| 279 |
+ |
info.isDipole = dipole; |
| 280 |
+ |
info.mass = mass; |
| 281 |
+ |
info.epslon = epslon; |
| 282 |
+ |
info.sigma = sigma; |
| 283 |
+ |
info.dipole = dipole; |
| 284 |
+ |
info.last = 0; |
| 285 |
+ |
} |
| 286 |
+ |
|
| 287 |
+ |
|
| 288 |
+ |
#endif |
| 289 |
+ |
|
| 290 |
|
char name[15]; |
| 291 |
|
int isDipole; |
| 292 |
|
double mass; |
| 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 |
| 355 |
|
the_atoms = entry_plug->atoms; |
| 356 |
|
nAtoms = entry_plug->n_atoms; |
| 357 |
|
|
| 131 |
– |
// read in the atom types. |
| 132 |
– |
|
| 133 |
– |
rewind( frcFile ); |
| 134 |
– |
headAtomType = new LinkedType; |
| 135 |
– |
currentAtomType = headAtomType; |
| 358 |
|
|
| 359 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 360 |
< |
lineNum++; |
| 361 |
< |
if( eof_test == NULL ){ |
| 362 |
< |
fprintf( stderr, "Error in reading Atoms from force file.\n" ); |
| 363 |
< |
exit(8); |
| 364 |
< |
} |
| 365 |
< |
|
| 366 |
< |
|
| 367 |
< |
while( !foundAtom ){ |
| 368 |
< |
while( eof_test != NULL && readLine[0] != '#' ){ |
| 369 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 370 |
< |
lineNum++; |
| 149 |
< |
} |
| 359 |
> |
#ifdef IS_MPI |
| 360 |
> |
if( myNode == 0 ){ |
| 361 |
> |
#endif |
| 362 |
> |
|
| 363 |
> |
// read in the atom types. |
| 364 |
> |
|
| 365 |
> |
rewind( frcFile ); |
| 366 |
> |
headAtomType = new LinkedType; |
| 367 |
> |
currentAtomType = headAtomType; |
| 368 |
> |
|
| 369 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 370 |
> |
lineNum++; |
| 371 |
|
if( eof_test == NULL ){ |
| 372 |
< |
fprintf( stderr, |
| 373 |
< |
"Error in reading Atoms from force file at line %d.\n", |
| 374 |
< |
lineNum ); |
| 375 |
< |
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 |
|
} |
| 156 |
– |
|
| 157 |
– |
the_token = strtok( readLine, " ,;\t#\n" ); |
| 158 |
– |
foundAtom = !strcmp( "AtomTypes", the_token ); |
| 378 |
|
|
| 379 |
< |
if( !foundAtom ){ |
| 380 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 381 |
< |
lineNum++; |
| 382 |
< |
|
| 379 |
> |
|
| 380 |
> |
while( !foundAtom ){ |
| 381 |
> |
while( eof_test != NULL && readLine[0] != '#' ){ |
| 382 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 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); |
| 390 |
< |
} |
| 389 |
> |
#ifdef IS_MPI |
| 390 |
> |
sendFrcStruct( &info, mpiAtomStructType ); |
| 391 |
> |
#endif |
| 392 |
> |
ffError(errMsg); |
| 393 |
> |
} |
| 394 |
> |
|
| 395 |
> |
the_token = strtok( readLine, " ,;\t#\n" ); |
| 396 |
> |
foundAtom = !strcmp( "AtomTypes", the_token ); |
| 397 |
> |
|
| 398 |
> |
if( !foundAtom ){ |
| 399 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 400 |
> |
lineNum++; |
| 401 |
> |
|
| 402 |
> |
if( eof_test == NULL ){ |
| 403 |
> |
sprintf( errMsg, |
| 404 |
> |
"Error in reading Atoms from force file at line %d.\n", |
| 405 |
> |
lineNum ); |
| 406 |
> |
#ifdef IS_MPI |
| 407 |
> |
sendFrcStruct( &info, mpiAtomStructType ); |
| 408 |
> |
#endif |
| 409 |
> |
ffError(errMsg); |
| 410 |
> |
} |
| 411 |
> |
} |
| 412 |
|
} |
| 171 |
– |
} |
| 172 |
– |
|
| 173 |
– |
// we are now at the AtomTypes section. |
| 174 |
– |
|
| 175 |
– |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 176 |
– |
lineNum++; |
| 177 |
– |
|
| 178 |
– |
if( eof_test == NULL ){ |
| 179 |
– |
fprintf( stderr, |
| 180 |
– |
"Error in reading Atoms from force file at line %d.\n", |
| 181 |
– |
lineNum ); |
| 182 |
– |
exit(8); |
| 183 |
– |
} |
| 184 |
– |
|
| 185 |
– |
while( readLine[0] != '#' && eof_test != NULL ){ |
| 413 |
|
|
| 414 |
< |
if( readLine[0] != '!' ){ |
| 414 |
> |
// we are now at the AtomTypes section. |
| 415 |
> |
|
| 416 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 417 |
> |
lineNum++; |
| 418 |
> |
|
| 419 |
> |
if( eof_test == NULL ){ |
| 420 |
> |
sprintf( errMsg, |
| 421 |
> |
"Error in reading Atoms from force file at line %d.\n", |
| 422 |
> |
lineNum ); |
| 423 |
> |
#ifdef IS_MPI |
| 424 |
> |
sendFrcStruct( &info, mpiAtomStructType ); |
| 425 |
> |
#endif |
| 426 |
> |
ffError(errMsg); |
| 427 |
> |
} |
| 428 |
> |
|
| 429 |
> |
while( readLine[0] != '#' && eof_test != NULL ){ |
| 430 |
|
|
| 431 |
< |
the_token = strtok( readLine, " \n\t,;" ); |
| 190 |
< |
if( the_token != NULL ){ |
| 431 |
> |
if( readLine[0] != '!' ){ |
| 432 |
|
|
| 433 |
< |
strcpy( currentAtomType->name, the_token ); |
| 434 |
< |
|
| 435 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 436 |
< |
fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum ); |
| 437 |
< |
exit(8); |
| 197 |
< |
} |
| 198 |
< |
|
| 199 |
< |
sscanf( the_token, "%d", ¤tAtomType->isDipole ); |
| 200 |
< |
|
| 201 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 202 |
< |
fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum ); |
| 203 |
< |
exit(8); |
| 204 |
< |
} |
| 205 |
< |
|
| 206 |
< |
sscanf( the_token, "%lf", ¤tAtomType->mass ); |
| 207 |
< |
|
| 208 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 209 |
< |
fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum ); |
| 210 |
< |
exit(8); |
| 211 |
< |
} |
| 212 |
< |
|
| 213 |
< |
sscanf( the_token, "%lf", ¤tAtomType->epslon ); |
| 214 |
< |
|
| 215 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 216 |
< |
fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum ); |
| 217 |
< |
exit(8); |
| 218 |
< |
} |
| 219 |
< |
|
| 220 |
< |
sscanf( the_token, "%lf", ¤tAtomType->sigma ); |
| 221 |
< |
|
| 222 |
< |
if( currentAtomType->isDipole ){ |
| 433 |
> |
the_token = strtok( readLine, " \n\t,;" ); |
| 434 |
> |
if( the_token != NULL ){ |
| 435 |
> |
|
| 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, "%lf", ¤tAtomType->dipole ); |
| 446 |
> |
sscanf( the_token, "%d", ¤tAtomType->isDipole ); |
| 447 |
> |
|
| 448 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 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 |
> |
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 |
> |
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 |
> |
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 ); |
| 489 |
> |
} |
| 490 |
|
} |
| 491 |
|
} |
| 492 |
+ |
|
| 493 |
+ |
tempAtomType = new LinkedType; |
| 494 |
+ |
currentAtomType->next = tempAtomType; |
| 495 |
+ |
currentAtomType = tempAtomType; |
| 496 |
+ |
|
| 497 |
+ |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 498 |
+ |
lineNum++; |
| 499 |
|
} |
| 500 |
+ |
|
| 501 |
+ |
#ifdef IS_MPI |
| 502 |
|
|
| 503 |
< |
tempAtomType = new LinkedType; |
| 234 |
< |
currentAtomType->next = tempAtomType; |
| 235 |
< |
currentAtomType = tempAtomType; |
| 503 |
> |
// send out the linked list to all the other processes |
| 504 |
|
|
| 505 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 506 |
< |
lineNum++; |
| 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 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 |
| 533 |
+ |
|
| 534 |
|
|
| 535 |
|
// initialize the atoms |
| 536 |
|
|
| 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 |
|
} |
| 620 |
|
if( !strcmp(nameA, key2 ) && !strcmp( nameB, key1 ) ) return this; |
| 621 |
|
if( next != NULL ) return next->find(key1, key2); |
| 622 |
|
return NULL; |
| 623 |
+ |
} |
| 624 |
+ |
|
| 625 |
+ |
#ifdef IS_MPI |
| 626 |
+ |
void add( bondStruct &info ){ |
| 627 |
+ |
if( next != NULL ) next->add(info); |
| 628 |
+ |
else{ |
| 629 |
+ |
next = new LinkedType(); |
| 630 |
+ |
strcpy(next->nameA, info.nameA); |
| 631 |
+ |
strcpy(next->nameB, info.nameB); |
| 632 |
+ |
strcpy(next->type, info.type); |
| 633 |
+ |
next->d0 = info.d0; |
| 634 |
+ |
} |
| 635 |
|
} |
| 636 |
|
|
| 637 |
+ |
void duplicate( bondStruct &info ){ |
| 638 |
+ |
strcpy(info.nameA, nameA); |
| 639 |
+ |
strcpy(info.nameB, nameB); |
| 640 |
+ |
strcpy(info.type, type); |
| 641 |
+ |
info.d0 = d0; |
| 642 |
+ |
info.last = 0; |
| 643 |
+ |
} |
| 644 |
+ |
|
| 645 |
+ |
|
| 646 |
+ |
#endif |
| 647 |
+ |
|
| 648 |
|
char nameA[15]; |
| 649 |
|
char nameB[15]; |
| 650 |
|
char type[30]; |
| 835 |
|
return NULL; |
| 836 |
|
} |
| 837 |
|
|
| 838 |
+ |
#ifdef IS_MPI |
| 839 |
+ |
|
| 840 |
+ |
void add( bendStruct &info ){ |
| 841 |
+ |
if( next != NULL ) next->add(info); |
| 842 |
+ |
else{ |
| 843 |
+ |
next = new LinkedType(); |
| 844 |
+ |
strcpy(next->nameA, info.nameA); |
| 845 |
+ |
strcpy(next->nameB, info.nameB); |
| 846 |
+ |
strcpy(next->nameC, info.nameC); |
| 847 |
+ |
strcpy(next->type, info.type); |
| 848 |
+ |
next->k1 = info.k1; |
| 849 |
+ |
next->k2 = info.k2; |
| 850 |
+ |
next->k3 = info.k3; |
| 851 |
+ |
next->t0 = info.t0; |
| 852 |
+ |
} |
| 853 |
+ |
} |
| 854 |
+ |
|
| 855 |
+ |
void duplicate( bendStruct &info ){ |
| 856 |
+ |
strcpy(info.nameA, nameA); |
| 857 |
+ |
strcpy(info.nameB, nameB); |
| 858 |
+ |
strcpy(info.nameC, nameC); |
| 859 |
+ |
strcpy(info.type, type); |
| 860 |
+ |
info.k1 = k1; |
| 861 |
+ |
info.k2 = k2; |
| 862 |
+ |
info.k3 = k3; |
| 863 |
+ |
info.t0 = t0; |
| 864 |
+ |
info.last = 0; |
| 865 |
+ |
} |
| 866 |
+ |
|
| 867 |
+ |
#endif |
| 868 |
+ |
|
| 869 |
|
char nameA[15]; |
| 870 |
|
char nameB[15]; |
| 871 |
|
char nameC[15]; |
| 1092 |
|
|
| 1093 |
|
if( next != NULL ) return next->find(key1, key2, key3, key4); |
| 1094 |
|
return NULL; |
| 1095 |
+ |
} |
| 1096 |
+ |
|
| 1097 |
+ |
#ifdef IS_MPI |
| 1098 |
+ |
|
| 1099 |
+ |
void add( torsionStruct &info ){ |
| 1100 |
+ |
if( next != NULL ) next->add(info); |
| 1101 |
+ |
else{ |
| 1102 |
+ |
next = new LinkedType(); |
| 1103 |
+ |
strcpy(next->nameA, info.nameA); |
| 1104 |
+ |
strcpy(next->nameB, info.nameB); |
| 1105 |
+ |
strcpy(next->nameC, info.nameC); |
| 1106 |
+ |
strcpy(next->type, info.type); |
| 1107 |
+ |
next->k1 = info.k1; |
| 1108 |
+ |
next->k2 = info.k2; |
| 1109 |
+ |
next->k3 = info.k3; |
| 1110 |
+ |
next->k4 = info.k4; |
| 1111 |
+ |
} |
| 1112 |
|
} |
| 1113 |
|
|
| 1114 |
+ |
void duplicate( torsionStruct &info ){ |
| 1115 |
+ |
strcpy(info.nameA, nameA); |
| 1116 |
+ |
strcpy(info.nameB, nameB); |
| 1117 |
+ |
strcpy(info.nameC, nameC); |
| 1118 |
+ |
strcpy(info.nameD, nameD); |
| 1119 |
+ |
strcpy(info.type, type); |
| 1120 |
+ |
info.k1 = k1; |
| 1121 |
+ |
info.k2 = k2; |
| 1122 |
+ |
info.k3 = k3; |
| 1123 |
+ |
info.k4 = k4; |
| 1124 |
+ |
info.last = 0; |
| 1125 |
+ |
} |
| 1126 |
+ |
|
| 1127 |
+ |
#endif |
| 1128 |
+ |
|
| 1129 |
|
char nameA[15]; |
| 1130 |
|
char nameB[15]; |
| 1131 |
|
char nameC[15]; |