| 7 |
|
|
| 8 |
|
#include "ForceFields.hpp" |
| 9 |
|
#include "SRI.hpp" |
| 10 |
+ |
#include "simError.h" |
| 11 |
|
|
| 12 |
|
|
| 13 |
+ |
#ifdef IS_MPI |
| 14 |
+ |
|
| 15 |
+ |
#include "mpiForceField.h" |
| 16 |
+ |
|
| 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 |
+ |
} atomStruct; |
| 30 |
+ |
MPI_Datatype mpiAtomStructType; |
| 31 |
+ |
|
| 32 |
+ |
typedef struct{ |
| 33 |
+ |
char nameA[15]; |
| 34 |
+ |
char nameB[15]; |
| 35 |
+ |
char type[30]; |
| 36 |
+ |
double d0; |
| 37 |
+ |
int last; // 0 -> default |
| 38 |
+ |
// 1 -> tells nodes to stop listening |
| 39 |
+ |
} bondStruct; |
| 40 |
+ |
MPI_Datatype mpiBondStructType; |
| 41 |
+ |
|
| 42 |
+ |
typedef struct{ |
| 43 |
+ |
char nameA[15]; |
| 44 |
+ |
char nameB[15]; |
| 45 |
+ |
char nameC[15]; |
| 46 |
+ |
char type[30]; |
| 47 |
+ |
double k1, k2, k3, t0; |
| 48 |
+ |
int last; // 0 -> default |
| 49 |
+ |
// 1 -> tells nodes to stop listening |
| 50 |
+ |
} bendStruct; |
| 51 |
+ |
MPI_Datatype mpiBendStructType; |
| 52 |
+ |
|
| 53 |
+ |
typedef struct{ |
| 54 |
+ |
char nameA[15]; |
| 55 |
+ |
char nameB[15]; |
| 56 |
+ |
char nameC[15]; |
| 57 |
+ |
char nameD[15]; |
| 58 |
+ |
char type[30]; |
| 59 |
+ |
double k1, k2, k3, k4; |
| 60 |
+ |
int last; // 0 -> default |
| 61 |
+ |
// 1 -> tells nodes to stop listening |
| 62 |
+ |
} torsionStruct; |
| 63 |
+ |
MPI_Datatype mpiTorsionStructType; |
| 64 |
+ |
|
| 65 |
+ |
#endif |
| 66 |
+ |
|
| 67 |
+ |
|
| 68 |
+ |
|
| 69 |
|
TraPPE_ExFF::TraPPE_ExFF(){ |
| 70 |
|
|
| 71 |
|
char fileName[200]; |
| 72 |
|
char* ffPath_env = "FORCE_PARAM_PATH"; |
| 73 |
|
char* ffPath; |
| 74 |
|
char temp[200]; |
| 75 |
+ |
char errMsg[1000]; |
| 76 |
|
|
| 77 |
< |
// generate the force file name |
| 77 |
> |
#ifdef IS_MPI |
| 78 |
> |
int i; |
| 79 |
> |
|
| 80 |
> |
// ********************************************************************** |
| 81 |
> |
// Init the atomStruct mpi type |
| 82 |
|
|
| 83 |
< |
strcpy( fileName, "TraPPE_Ex.frc" ); |
| 83 |
> |
atomStruct atomProto; // mpiPrototype |
| 84 |
> |
int atomBC[3] = {15,4,2}; // block counts |
| 85 |
> |
MPI_Aint atomDspls[3]; // displacements |
| 86 |
> |
MPI_Datatype atomMbrTypes[3]; // member mpi types |
| 87 |
|
|
| 88 |
< |
// attempt to open the file in the current directory first. |
| 88 |
> |
MPI_Address(&atomProto.name, &atomDspls[0]); |
| 89 |
> |
MPI_Address(&atomProto.mass, &atomDspls[1]); |
| 90 |
> |
MPI_Address(&atomProto.isDipole, &atomDspls[2]); |
| 91 |
|
|
| 92 |
< |
frcFile = fopen( fileName, "r" ); |
| 92 |
> |
atomMbrTypes[0] = MPI_CHAR; |
| 93 |
> |
atomMbrTypes[1] = MPI_DOUBLE; |
| 94 |
> |
atomMbrTypes[2] = MPI_INT; |
| 95 |
|
|
| 96 |
< |
if( frcFile == NULL ){ |
| 96 |
> |
for (i=2; i >= 0; i--) atomDspls[i] -= atomDspls[0]; |
| 97 |
> |
|
| 98 |
> |
MPI_Type_struct(3, atomBC, atomDspls, atomMbrTypes, &mpiAtomStructType); |
| 99 |
> |
MPI_Type_commit(&mpiAtomStructType); |
| 100 |
|
|
| 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 ); |
| 101 |
|
|
| 102 |
+ |
// ********************************************************************** |
| 103 |
+ |
// Init the bondStruct mpi type |
| 104 |
+ |
|
| 105 |
+ |
bondStruct bondProto; // mpiPrototype |
| 106 |
+ |
int bondBC[3] = {60,1,1}; // block counts |
| 107 |
+ |
MPI_Aint bondDspls[3]; // displacements |
| 108 |
+ |
MPI_Datatype bondMbrTypes[3]; // member mpi types |
| 109 |
+ |
|
| 110 |
+ |
MPI_Address(&bondProto.nameA, &bondDspls[0]); |
| 111 |
+ |
MPI_Address(&bondProto.d0, &bondDspls[1]); |
| 112 |
+ |
MPI_Address(&bondProto.last, &bondDspls[2]); |
| 113 |
+ |
|
| 114 |
+ |
bondMbrTypes[0] = MPI_CHAR; |
| 115 |
+ |
bondMbrTypes[1] = MPI_DOUBLE; |
| 116 |
+ |
bondMbrTypes[2] = MPI_INT; |
| 117 |
+ |
|
| 118 |
+ |
for (i=2; i >= 0; i--) bondDspls[i] -= bondDspls[0]; |
| 119 |
+ |
|
| 120 |
+ |
MPI_Type_struct(3, bondBC, bondDspls, bondMbrTypes, &mpiBondStructType); |
| 121 |
+ |
MPI_Type_commit(&mpiBondStructType); |
| 122 |
+ |
|
| 123 |
+ |
|
| 124 |
+ |
// ********************************************************************** |
| 125 |
+ |
// Init the bendStruct mpi type |
| 126 |
+ |
|
| 127 |
+ |
bendStruct bendProto; // mpiPrototype |
| 128 |
+ |
int bendBC[3] = {75,4,1}; // block counts |
| 129 |
+ |
MPI_Aint bendDspls[3]; // displacements |
| 130 |
+ |
MPI_Datatype bendMbrTypes[3]; // member mpi types |
| 131 |
+ |
|
| 132 |
+ |
MPI_Address(&bendProto.nameA, &bendDspls[0]); |
| 133 |
+ |
MPI_Address(&bendProto.k1, &bendDspls[1]); |
| 134 |
+ |
MPI_Address(&bendProto.last, &bendDspls[2]); |
| 135 |
+ |
|
| 136 |
+ |
bendMbrTypes[0] = MPI_CHAR; |
| 137 |
+ |
bendMbrTypes[1] = MPI_DOUBLE; |
| 138 |
+ |
bendMbrTypes[2] = MPI_INT; |
| 139 |
+ |
|
| 140 |
+ |
for (i=2; i >= 0; i--) bendDspls[i] -= bendDspls[0]; |
| 141 |
+ |
|
| 142 |
+ |
MPI_Type_struct(3, bendBC, bendDspls, bendMbrTypes, &mpiBendStructType); |
| 143 |
+ |
MPI_Type_commit(&mpiBendStructType); |
| 144 |
+ |
|
| 145 |
+ |
|
| 146 |
+ |
// ********************************************************************** |
| 147 |
+ |
// Init the torsionStruct mpi type |
| 148 |
+ |
|
| 149 |
+ |
torsionStruct torsionProto; // mpiPrototype |
| 150 |
+ |
int torsionBC[3] = {90,4,1}; // block counts |
| 151 |
+ |
MPI_Aint torsionDspls[3]; // displacements |
| 152 |
+ |
MPI_Datatype torsionMbrTypes[3]; // member mpi types |
| 153 |
+ |
|
| 154 |
+ |
MPI_Address(&torsionProto.nameA, &torsionDspls[0]); |
| 155 |
+ |
MPI_Address(&torsionProto.k1, &torsionDspls[1]); |
| 156 |
+ |
MPI_Address(&torsionProto.last, &torsionDspls[2]); |
| 157 |
+ |
|
| 158 |
+ |
torsionMbrTypes[0] = MPI_CHAR; |
| 159 |
+ |
torsionMbrTypes[1] = MPI_DOUBLE; |
| 160 |
+ |
torsionMbrTypes[2] = MPI_INT; |
| 161 |
+ |
|
| 162 |
+ |
for (i=2; i >= 0; i--) torsionDspls[i] -= torsionDspls[0]; |
| 163 |
+ |
|
| 164 |
+ |
MPI_Type_struct(3, torsionBC, torsionDspls, torsionMbrTypes, |
| 165 |
+ |
&mpiTorsionStructType); |
| 166 |
+ |
MPI_Type_commit(&mpiTorsionStructType); |
| 167 |
+ |
|
| 168 |
+ |
// *********************************************************************** |
| 169 |
+ |
|
| 170 |
+ |
if( worldRank == 0 ){ |
| 171 |
+ |
#endif |
| 172 |
+ |
|
| 173 |
+ |
// generate the force file name |
| 174 |
+ |
|
| 175 |
+ |
strcpy( fileName, "TraPPE_Ex.frc" ); |
| 176 |
+ |
// fprintf( stderr,"Trying to open %s\n", fileName ); |
| 177 |
+ |
|
| 178 |
+ |
// attempt to open the file in the current directory first. |
| 179 |
+ |
|
| 180 |
|
frcFile = fopen( fileName, "r" ); |
| 181 |
|
|
| 182 |
|
if( frcFile == NULL ){ |
| 183 |
|
|
| 184 |
< |
fprintf( stderr, |
| 185 |
< |
"Error opening the force field parameter file: %s\n" |
| 186 |
< |
"Have you tried setting the FORCE_PARAM_PATH environment " |
| 187 |
< |
"vairable?\n", |
| 188 |
< |
fileName ); |
| 189 |
< |
exit( 8 ); |
| 184 |
> |
// next see if the force path enviorment variable is set |
| 185 |
> |
|
| 186 |
> |
ffPath = getenv( ffPath_env ); |
| 187 |
> |
if( ffPath == NULL ) { |
| 188 |
> |
sprintf( painCave.errMsg, |
| 189 |
> |
"Error opening the force field parameter file: %s\n" |
| 190 |
> |
"Have you tried setting the FORCE_PARAM_PATH environment " |
| 191 |
> |
"vairable?\n", |
| 192 |
> |
fileName ); |
| 193 |
> |
painCave.isFatal = 1; |
| 194 |
> |
simError(); |
| 195 |
> |
} |
| 196 |
> |
|
| 197 |
> |
|
| 198 |
> |
strcpy( temp, ffPath ); |
| 199 |
> |
strcat( temp, "/" ); |
| 200 |
> |
strcat( temp, fileName ); |
| 201 |
> |
strcpy( fileName, temp ); |
| 202 |
> |
|
| 203 |
> |
frcFile = fopen( fileName, "r" ); |
| 204 |
> |
|
| 205 |
> |
if( frcFile == NULL ){ |
| 206 |
> |
|
| 207 |
> |
sprintf( painCave.errMsg, |
| 208 |
> |
"Error opening the force field parameter file: %s\n" |
| 209 |
> |
"Have you tried setting the FORCE_PARAM_PATH environment " |
| 210 |
> |
"vairable?\n", |
| 211 |
> |
fileName ); |
| 212 |
> |
painCave.isFatal = 1; |
| 213 |
> |
simError(); |
| 214 |
> |
} |
| 215 |
|
} |
| 216 |
+ |
|
| 217 |
+ |
#ifdef IS_MPI |
| 218 |
|
} |
| 219 |
+ |
|
| 220 |
+ |
sprintf( checkPointMsg, "TraPPE_ExFF file opened sucessfully." ); |
| 221 |
+ |
MPIcheckPoint(); |
| 222 |
+ |
|
| 223 |
+ |
#endif // is_mpi |
| 224 |
|
} |
| 225 |
|
|
| 226 |
+ |
|
| 227 |
|
TraPPE_ExFF::~TraPPE_ExFF(){ |
| 228 |
< |
|
| 229 |
< |
fclose( frcFile ); |
| 228 |
> |
|
| 229 |
> |
#ifdef IS_MPI |
| 230 |
> |
if( worldRank == 0 ){ |
| 231 |
> |
#endif // is_mpi |
| 232 |
> |
|
| 233 |
> |
fclose( frcFile ); |
| 234 |
> |
|
| 235 |
> |
#ifdef IS_MPI |
| 236 |
> |
} |
| 237 |
> |
#endif // is_mpi |
| 238 |
|
} |
| 239 |
|
|
| 240 |
|
void TraPPE_ExFF::initializeAtoms( void ){ |
| 253 |
|
return NULL; |
| 254 |
|
} |
| 255 |
|
|
| 256 |
+ |
#ifdef IS_MPI |
| 257 |
+ |
void add( atomStruct &info ){ |
| 258 |
+ |
if( next != NULL ) next->add(info); |
| 259 |
+ |
else{ |
| 260 |
+ |
next = new LinkedType(); |
| 261 |
+ |
strcpy(next->name, info.name); |
| 262 |
+ |
next->isDipole = info.dipole; |
| 263 |
+ |
next->mass = info.mass; |
| 264 |
+ |
next->epslon = info.epslon; |
| 265 |
+ |
next->sigma = info.sigma; |
| 266 |
+ |
next->dipole = info.dipole; |
| 267 |
+ |
} |
| 268 |
+ |
} |
| 269 |
+ |
|
| 270 |
+ |
void duplicate( atomStruct &info ){ |
| 271 |
+ |
strcpy(info.name, name); |
| 272 |
+ |
info.isDipole = dipole; |
| 273 |
+ |
info.mass = mass; |
| 274 |
+ |
info.epslon = epslon; |
| 275 |
+ |
info.sigma = sigma; |
| 276 |
+ |
info.dipole = dipole; |
| 277 |
+ |
info.last = 0; |
| 278 |
+ |
} |
| 279 |
+ |
|
| 280 |
+ |
|
| 281 |
+ |
#endif |
| 282 |
+ |
|
| 283 |
|
char name[15]; |
| 284 |
|
int isDipole; |
| 285 |
|
double mass; |
| 293 |
|
LinkedType* currentAtomType; |
| 294 |
|
LinkedType* tempAtomType; |
| 295 |
|
|
| 296 |
+ |
#ifdef IS_MPI |
| 297 |
+ |
atomStruct info; |
| 298 |
+ |
info.last = 1; // initialize last to have the last set. |
| 299 |
+ |
// if things go well, last will be set to 0 |
| 300 |
+ |
#endif |
| 301 |
+ |
|
| 302 |
+ |
|
| 303 |
|
char readLine[500]; |
| 304 |
|
char* the_token; |
| 305 |
|
char* eof_test; |
| 306 |
|
int foundAtom = 0; |
| 307 |
|
int lineNum = 0; |
| 308 |
|
int i; |
| 309 |
+ |
|
| 310 |
|
|
| 311 |
|
////////////////////////////////////////////////// |
| 312 |
|
// a quick water fix |
| 347 |
|
the_atoms = entry_plug->atoms; |
| 348 |
|
nAtoms = entry_plug->n_atoms; |
| 349 |
|
|
| 131 |
– |
// read in the atom types. |
| 132 |
– |
|
| 133 |
– |
rewind( frcFile ); |
| 134 |
– |
headAtomType = new LinkedType; |
| 135 |
– |
currentAtomType = headAtomType; |
| 350 |
|
|
| 351 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 352 |
< |
lineNum++; |
| 353 |
< |
if( eof_test == NULL ){ |
| 354 |
< |
fprintf( stderr, "Error in reading Atoms from force file.\n" ); |
| 355 |
< |
exit(8); |
| 356 |
< |
} |
| 357 |
< |
|
| 358 |
< |
|
| 359 |
< |
while( !foundAtom ){ |
| 360 |
< |
while( eof_test != NULL && readLine[0] != '#' ){ |
| 361 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 362 |
< |
lineNum++; |
| 149 |
< |
} |
| 351 |
> |
#ifdef IS_MPI |
| 352 |
> |
if( worldRank == 0 ){ |
| 353 |
> |
#endif |
| 354 |
> |
|
| 355 |
> |
// read in the atom types. |
| 356 |
> |
|
| 357 |
> |
rewind( frcFile ); |
| 358 |
> |
headAtomType = new LinkedType; |
| 359 |
> |
currentAtomType = headAtomType; |
| 360 |
> |
|
| 361 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 362 |
> |
lineNum++; |
| 363 |
|
if( eof_test == NULL ){ |
| 364 |
< |
fprintf( stderr, |
| 365 |
< |
"Error in reading Atoms from force file at line %d.\n", |
| 366 |
< |
lineNum ); |
| 154 |
< |
exit(8); |
| 364 |
> |
sprintf( painCave.errMsg, "Error in reading Atoms from force file.\n" ); |
| 365 |
> |
painCave.isFatal = 1; |
| 366 |
> |
simError(); |
| 367 |
|
} |
| 156 |
– |
|
| 157 |
– |
the_token = strtok( readLine, " ,;\t#\n" ); |
| 158 |
– |
foundAtom = !strcmp( "AtomTypes", the_token ); |
| 368 |
|
|
| 369 |
< |
if( !foundAtom ){ |
| 370 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 371 |
< |
lineNum++; |
| 372 |
< |
|
| 369 |
> |
|
| 370 |
> |
while( !foundAtom ){ |
| 371 |
> |
while( eof_test != NULL && readLine[0] != '#' ){ |
| 372 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 373 |
> |
lineNum++; |
| 374 |
> |
} |
| 375 |
|
if( eof_test == NULL ){ |
| 376 |
< |
fprintf( stderr, |
| 376 |
> |
sprintf( painCave.errMsg, |
| 377 |
|
"Error in reading Atoms from force file at line %d.\n", |
| 378 |
|
lineNum ); |
| 379 |
< |
exit(8); |
| 380 |
< |
} |
| 381 |
< |
} |
| 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 ){ |
| 186 |
< |
|
| 187 |
< |
if( readLine[0] != '!' ){ |
| 379 |
> |
painCave.isFatal = 1; |
| 380 |
> |
simError(); |
| 381 |
> |
} |
| 382 |
|
|
| 383 |
< |
the_token = strtok( readLine, " \n\t,;" ); |
| 384 |
< |
if( the_token != NULL ){ |
| 383 |
> |
the_token = strtok( readLine, " ,;\t#\n" ); |
| 384 |
> |
foundAtom = !strcmp( "AtomTypes", the_token ); |
| 385 |
> |
|
| 386 |
> |
if( !foundAtom ){ |
| 387 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 388 |
> |
lineNum++; |
| 389 |
|
|
| 390 |
< |
strcpy( currentAtomType->name, the_token ); |
| 391 |
< |
|
| 392 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 393 |
< |
fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum ); |
| 394 |
< |
exit(8); |
| 395 |
< |
} |
| 396 |
< |
|
| 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 ){ |
| 223 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 224 |
< |
fprintf( stderr, "Error parseing AtomTypes: line %d\n", lineNum ); |
| 225 |
< |
exit(8); |
| 226 |
< |
} |
| 227 |
< |
|
| 228 |
< |
sscanf( the_token, "%lf", ¤tAtomType->dipole ); |
| 229 |
< |
} |
| 390 |
> |
if( eof_test == NULL ){ |
| 391 |
> |
sprintf( painCave.errMsg, |
| 392 |
> |
"Error in reading Atoms from force file at line %d.\n", |
| 393 |
> |
lineNum ); |
| 394 |
> |
painCave.isFatal = 1; |
| 395 |
> |
simError(); |
| 396 |
> |
} |
| 397 |
|
} |
| 398 |
|
} |
| 399 |
|
|
| 400 |
< |
tempAtomType = new LinkedType; |
| 234 |
< |
currentAtomType->next = tempAtomType; |
| 235 |
< |
currentAtomType = tempAtomType; |
| 400 |
> |
// we are now at the AtomTypes section. |
| 401 |
|
|
| 402 |
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 403 |
|
lineNum++; |
| 404 |
+ |
|
| 405 |
+ |
if( eof_test == NULL ){ |
| 406 |
+ |
sprintf( painCave.errMsg, |
| 407 |
+ |
"Error in reading Atoms from force file at line %d.\n", |
| 408 |
+ |
lineNum ); |
| 409 |
+ |
painCave.isFatal = 1; |
| 410 |
+ |
simError(); |
| 411 |
+ |
} |
| 412 |
+ |
|
| 413 |
+ |
while( readLine[0] != '#' && eof_test != NULL ){ |
| 414 |
+ |
|
| 415 |
+ |
if( readLine[0] != '!' ){ |
| 416 |
+ |
|
| 417 |
+ |
the_token = strtok( readLine, " \n\t,;" ); |
| 418 |
+ |
if( the_token != NULL ){ |
| 419 |
+ |
|
| 420 |
+ |
strcpy( currentAtomType->name, the_token ); |
| 421 |
+ |
|
| 422 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 423 |
+ |
sprintf( painCave.errMsg, |
| 424 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
| 425 |
+ |
painCave.isFatal = 1; |
| 426 |
+ |
simError(); |
| 427 |
+ |
} |
| 428 |
+ |
|
| 429 |
+ |
sscanf( the_token, "%d", ¤tAtomType->isDipole ); |
| 430 |
+ |
|
| 431 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 432 |
+ |
sprintf( painCave.errMsg, |
| 433 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
| 434 |
+ |
painCave.isFatal = 1; |
| 435 |
+ |
simError(); |
| 436 |
+ |
} |
| 437 |
+ |
|
| 438 |
+ |
sscanf( the_token, "%lf", ¤tAtomType->mass ); |
| 439 |
+ |
|
| 440 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 441 |
+ |
sprintf( painCave.errMsg, |
| 442 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
| 443 |
+ |
painCave.isFatal = 1; |
| 444 |
+ |
simError(); |
| 445 |
+ |
} |
| 446 |
+ |
|
| 447 |
+ |
sscanf( the_token, "%lf", ¤tAtomType->epslon ); |
| 448 |
+ |
|
| 449 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 450 |
+ |
sprintf( painCave.errMsg, |
| 451 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
| 452 |
+ |
painCave.isFatal = 1; |
| 453 |
+ |
simError(); |
| 454 |
+ |
} |
| 455 |
+ |
|
| 456 |
+ |
sscanf( the_token, "%lf", ¤tAtomType->sigma ); |
| 457 |
+ |
|
| 458 |
+ |
if( currentAtomType->isDipole ){ |
| 459 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 460 |
+ |
sprintf( painCave.errMsg, |
| 461 |
+ |
"Error parseing AtomTypes: line %d\n", |
| 462 |
+ |
lineNum ); |
| 463 |
+ |
painCave.isFatal = 1; |
| 464 |
+ |
simError(); |
| 465 |
+ |
} |
| 466 |
+ |
|
| 467 |
+ |
sscanf( the_token, "%lf", ¤tAtomType->dipole ); |
| 468 |
+ |
} |
| 469 |
+ |
} |
| 470 |
+ |
} |
| 471 |
+ |
|
| 472 |
+ |
tempAtomType = new LinkedType; |
| 473 |
+ |
currentAtomType->next = tempAtomType; |
| 474 |
+ |
currentAtomType = tempAtomType; |
| 475 |
+ |
|
| 476 |
+ |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 477 |
+ |
lineNum++; |
| 478 |
+ |
} |
| 479 |
+ |
|
| 480 |
+ |
#ifdef IS_MPI |
| 481 |
+ |
|
| 482 |
+ |
// send out the linked list to all the other processes |
| 483 |
+ |
|
| 484 |
+ |
sprintf( checkPointMsg, |
| 485 |
+ |
"TraPPE_Ex atom structures read successfully." ); |
| 486 |
+ |
MPIcheckPoint(); |
| 487 |
+ |
|
| 488 |
+ |
currentAtomType = headAtomType; |
| 489 |
+ |
while( currentAtomType != NULL ){ |
| 490 |
+ |
currentAtomType->duplicate( info ); |
| 491 |
+ |
sendFrcStruct( &info, mpiAtomStructType ); |
| 492 |
+ |
currentAtomType = currentAtomType->next; |
| 493 |
+ |
} |
| 494 |
+ |
info.last = 1; |
| 495 |
+ |
sendFrcStruct( &info, mpiAtomStructType ); |
| 496 |
+ |
|
| 497 |
|
} |
| 498 |
|
|
| 499 |
+ |
else{ |
| 500 |
+ |
|
| 501 |
+ |
// listen for node 0 to send out the force params |
| 502 |
+ |
|
| 503 |
+ |
MPIcheckPoint(); |
| 504 |
+ |
|
| 505 |
+ |
headAtomType = new LinkedType; |
| 506 |
+ |
recieveFrcStruct( &info, mpiAtomStructType ); |
| 507 |
+ |
while( !info.last ){ |
| 508 |
+ |
|
| 509 |
+ |
headAtomType->add( info ); |
| 510 |
+ |
recieveFrcStruct( &info, mpiAtomStructType ); |
| 511 |
+ |
} |
| 512 |
+ |
} |
| 513 |
+ |
#endif // is_mpi |
| 514 |
+ |
|
| 515 |
|
|
| 516 |
|
// initialize the atoms |
| 517 |
|
|
| 521 |
|
|
| 522 |
|
currentAtomType = headAtomType->find( the_atoms[i]->getType() ); |
| 523 |
|
if( currentAtomType == NULL ){ |
| 524 |
< |
fprintf( stderr, "AtomType error, %s not found in force file.\n", |
| 524 |
> |
sprintf( painCave.errMsg, |
| 525 |
> |
"AtomType error, %s not found in force file.\n", |
| 526 |
|
the_atoms[i]->getType() ); |
| 527 |
< |
exit(8); |
| 527 |
> |
painCave.isFatal = 1; |
| 528 |
> |
simError(); |
| 529 |
|
} |
| 530 |
|
|
| 531 |
|
the_atoms[i]->setMass( currentAtomType->mass ); |
| 552 |
|
dAtom->setSSD( 0 ); |
| 553 |
|
} |
| 554 |
|
else{ |
| 555 |
< |
fprintf(stderr, |
| 555 |
> |
sprintf(painCave.errMsg, |
| 556 |
|
"AtmType error, %s does not have a moment of inertia set.\n", |
| 557 |
|
the_atoms[i]->getType() ); |
| 558 |
< |
exit(8); |
| 558 |
> |
painCave.isFatal = 1; |
| 559 |
> |
simError(); |
| 560 |
|
} |
| 561 |
|
entry_plug->n_dipoles++; |
| 562 |
|
} |
| 563 |
|
else{ |
| 564 |
< |
std::cerr |
| 565 |
< |
<< "TraPPE_ExFF error: Atom \"" |
| 566 |
< |
<< currentAtomType->name << "\" is a dipole, yet no standard" |
| 567 |
< |
<< " orientation was specifed in the BASS file.\n"; |
| 568 |
< |
exit(8); |
| 564 |
> |
|
| 565 |
> |
sprintf( painCave.errMsg, |
| 566 |
> |
"TraPPE_ExFF error: Atom \"%s\" is a dipole, yet no standard" |
| 567 |
> |
" orientation was specifed in the BASS file.\n", |
| 568 |
> |
currentAtomType->name ); |
| 569 |
> |
painCave.isFatal = 1; |
| 570 |
> |
simError(); |
| 571 |
|
} |
| 572 |
|
} |
| 573 |
|
else{ |
| 574 |
|
if( the_atoms[i]->isDirectional() ){ |
| 575 |
< |
std::cerr |
| 576 |
< |
<< "TraPPE_ExFF error: Atom \"" |
| 577 |
< |
<< currentAtomType->name << "\" was given a standard orientation" |
| 578 |
< |
<< " in the BASS file, yet it is not a dipole.\n"; |
| 579 |
< |
exit(8); |
| 575 |
> |
sprintf( painCave.errMsg, |
| 576 |
> |
"TraPPE_ExFF error: Atom \"%s\" was given a standard" |
| 577 |
> |
"orientation in the BASS file, yet it is not a dipole.\n", |
| 578 |
> |
currentAtomType->name); |
| 579 |
> |
painCave.isFatal = 1; |
| 580 |
> |
simError(); |
| 581 |
|
} |
| 582 |
|
} |
| 583 |
|
} |
| 586 |
|
// clean up the memory |
| 587 |
|
|
| 588 |
|
delete headAtomType; |
| 589 |
+ |
|
| 590 |
+ |
#ifdef IS_MPI |
| 591 |
+ |
sprintf( checkPointMsg, "TraPPE_Ex atoms initialized succesfully" ); |
| 592 |
+ |
MPIcheckPoint(); |
| 593 |
+ |
#endif // is_mpi |
| 594 |
+ |
|
| 595 |
|
} |
| 596 |
|
|
| 597 |
|
void TraPPE_ExFF::initializeBonds( bond_pair* the_bonds ){ |
| 613 |
|
return NULL; |
| 614 |
|
} |
| 615 |
|
|
| 616 |
+ |
#ifdef IS_MPI |
| 617 |
+ |
void add( bondStruct &info ){ |
| 618 |
+ |
if( next != NULL ) next->add(info); |
| 619 |
+ |
else{ |
| 620 |
+ |
next = new LinkedType(); |
| 621 |
+ |
strcpy(next->nameA, info.nameA); |
| 622 |
+ |
strcpy(next->nameB, info.nameB); |
| 623 |
+ |
strcpy(next->type, info.type); |
| 624 |
+ |
next->d0 = info.d0; |
| 625 |
+ |
} |
| 626 |
+ |
} |
| 627 |
+ |
|
| 628 |
+ |
void duplicate( bondStruct &info ){ |
| 629 |
+ |
strcpy(info.nameA, nameA); |
| 630 |
+ |
strcpy(info.nameB, nameB); |
| 631 |
+ |
strcpy(info.type, type); |
| 632 |
+ |
info.d0 = d0; |
| 633 |
+ |
info.last = 0; |
| 634 |
+ |
} |
| 635 |
+ |
|
| 636 |
+ |
|
| 637 |
+ |
#endif |
| 638 |
+ |
|
| 639 |
|
char nameA[15]; |
| 640 |
|
char nameB[15]; |
| 641 |
|
char type[30]; |
| 650 |
|
LinkedType* currentBondType; |
| 651 |
|
LinkedType* tempBondType; |
| 652 |
|
|
| 653 |
+ |
#ifdef IS_MPI |
| 654 |
+ |
bondStruct info; |
| 655 |
+ |
info.last = 1; // initialize last to have the last set. |
| 656 |
+ |
// if things go well, last will be set to 0 |
| 657 |
+ |
#endif |
| 658 |
+ |
|
| 659 |
|
char readLine[500]; |
| 660 |
|
char* the_token; |
| 661 |
|
char* eof_test; |
| 672 |
|
the_atoms = entry_plug->atoms; |
| 673 |
|
nBonds = entry_plug->n_bonds; |
| 674 |
|
|
| 360 |
– |
// read in the bond types. |
| 361 |
– |
|
| 362 |
– |
rewind( frcFile ); |
| 363 |
– |
headBondType = new LinkedType; |
| 364 |
– |
currentBondType = headBondType; |
| 675 |
|
|
| 676 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 677 |
< |
lineNum++; |
| 678 |
< |
if( eof_test == NULL ){ |
| 679 |
< |
fprintf( stderr, "Error in reading Bonds from force file.\n" ); |
| 680 |
< |
exit(8); |
| 681 |
< |
} |
| 682 |
< |
|
| 683 |
< |
|
| 684 |
< |
while( !foundBond ){ |
| 685 |
< |
while( eof_test != NULL && readLine[0] != '#' ){ |
| 686 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 687 |
< |
lineNum++; |
| 378 |
< |
} |
| 676 |
> |
#ifdef IS_MPI |
| 677 |
> |
if( worldRank == 0 ){ |
| 678 |
> |
#endif |
| 679 |
> |
|
| 680 |
> |
// read in the bond types. |
| 681 |
> |
|
| 682 |
> |
rewind( frcFile ); |
| 683 |
> |
headBondType = new LinkedType; |
| 684 |
> |
currentBondType = headBondType; |
| 685 |
> |
|
| 686 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 687 |
> |
lineNum++; |
| 688 |
|
if( eof_test == NULL ){ |
| 689 |
< |
fprintf( stderr, |
| 690 |
< |
"Error in reading Bonds from force file at line %d.\n", |
| 691 |
< |
lineNum ); |
| 383 |
< |
exit(8); |
| 689 |
> |
sprintf( painCave.errMsg, "Error in reading Bonds from force file.\n" ); |
| 690 |
> |
painCave.isFatal = 1; |
| 691 |
> |
simError(); |
| 692 |
|
} |
| 385 |
– |
|
| 386 |
– |
the_token = strtok( readLine, " ,;\t#\n" ); |
| 387 |
– |
foundBond = !strcmp( "BondTypes", the_token ); |
| 693 |
|
|
| 694 |
< |
if( !foundBond ){ |
| 695 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 696 |
< |
lineNum++; |
| 697 |
< |
|
| 694 |
> |
|
| 695 |
> |
while( !foundBond ){ |
| 696 |
> |
while( eof_test != NULL && readLine[0] != '#' ){ |
| 697 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 698 |
> |
lineNum++; |
| 699 |
> |
} |
| 700 |
|
if( eof_test == NULL ){ |
| 701 |
< |
fprintf( stderr, |
| 701 |
> |
sprintf( painCave.errMsg, |
| 702 |
|
"Error in reading Bonds from force file at line %d.\n", |
| 703 |
|
lineNum ); |
| 704 |
< |
exit(8); |
| 705 |
< |
} |
| 704 |
> |
painCave.isFatal = 1; |
| 705 |
> |
simError(); |
| 706 |
> |
} |
| 707 |
> |
|
| 708 |
> |
the_token = strtok( readLine, " ,;\t#\n" ); |
| 709 |
> |
foundBond = !strcmp( "BondTypes", the_token ); |
| 710 |
> |
|
| 711 |
> |
if( !foundBond ){ |
| 712 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 713 |
> |
lineNum++; |
| 714 |
> |
|
| 715 |
> |
if( eof_test == NULL ){ |
| 716 |
> |
sprintf( painCave.errMsg, |
| 717 |
> |
"Error in reading Bonds from force file at line %d.\n", |
| 718 |
> |
lineNum ); |
| 719 |
> |
painCave.isFatal = 1; |
| 720 |
> |
simError(); |
| 721 |
> |
} |
| 722 |
> |
} |
| 723 |
|
} |
| 400 |
– |
} |
| 401 |
– |
|
| 402 |
– |
// we are now at the BondTypes section. |
| 403 |
– |
|
| 404 |
– |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 405 |
– |
lineNum++; |
| 406 |
– |
|
| 407 |
– |
if( eof_test == NULL ){ |
| 408 |
– |
fprintf( stderr, |
| 409 |
– |
"Error in reading Bonds from force file at line %d.\n", |
| 410 |
– |
lineNum ); |
| 411 |
– |
exit(8); |
| 412 |
– |
} |
| 413 |
– |
|
| 414 |
– |
while( readLine[0] != '#' && eof_test != NULL ){ |
| 724 |
|
|
| 725 |
< |
if( readLine[0] != '!' ){ |
| 725 |
> |
// we are now at the BondTypes section. |
| 726 |
> |
|
| 727 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 728 |
> |
lineNum++; |
| 729 |
> |
|
| 730 |
> |
if( eof_test == NULL ){ |
| 731 |
> |
sprintf( painCave.errMsg, |
| 732 |
> |
"Error in reading Bonds from force file at line %d.\n", |
| 733 |
> |
lineNum ); |
| 734 |
> |
painCave.isFatal = 1; |
| 735 |
> |
simError(); |
| 736 |
> |
} |
| 737 |
> |
|
| 738 |
> |
while( readLine[0] != '#' && eof_test != NULL ){ |
| 739 |
|
|
| 740 |
< |
the_token = strtok( readLine, " \n\t,;" ); |
| 419 |
< |
if( the_token != NULL ){ |
| 740 |
> |
if( readLine[0] != '!' ){ |
| 741 |
|
|
| 742 |
< |
strcpy( currentBondType->nameA, the_token ); |
| 743 |
< |
|
| 744 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 745 |
< |
fprintf( stderr, "Error parseing BondTypes: line %d\n", lineNum ); |
| 746 |
< |
exit(8); |
| 426 |
< |
} |
| 427 |
< |
|
| 428 |
< |
strcpy( currentBondType->nameB, the_token ); |
| 429 |
< |
|
| 430 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 431 |
< |
fprintf( stderr, "Error parseing BondTypes: line %d\n", lineNum ); |
| 432 |
< |
exit(8); |
| 433 |
< |
} |
| 434 |
< |
|
| 435 |
< |
strcpy( currentBondType->type, the_token ); |
| 436 |
< |
|
| 437 |
< |
if( !strcmp( currentBondType->type, "fixed" ) ){ |
| 742 |
> |
the_token = strtok( readLine, " \n\t,;" ); |
| 743 |
> |
if( the_token != NULL ){ |
| 744 |
> |
|
| 745 |
> |
strcpy( currentBondType->nameA, the_token ); |
| 746 |
> |
|
| 747 |
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 748 |
< |
fprintf( stderr, "Error parseing BondTypes: line %d\n", lineNum ); |
| 749 |
< |
exit(8); |
| 748 |
> |
sprintf( painCave.errMsg, |
| 749 |
> |
"Error parseing BondTypes: line %d\n", lineNum ); |
| 750 |
> |
painCave.isFatal = 1; |
| 751 |
> |
simError(); |
| 752 |
|
} |
| 753 |
|
|
| 754 |
< |
sscanf( the_token, "%lf", ¤tBondType->d0 ); |
| 754 |
> |
strcpy( currentBondType->nameB, the_token ); |
| 755 |
> |
|
| 756 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 757 |
> |
sprintf( painCave.errMsg, |
| 758 |
> |
"Error parseing BondTypes: line %d\n", lineNum ); |
| 759 |
> |
painCave.isFatal = 1; |
| 760 |
> |
simError(); |
| 761 |
> |
} |
| 762 |
> |
|
| 763 |
> |
strcpy( currentBondType->type, the_token ); |
| 764 |
> |
|
| 765 |
> |
if( !strcmp( currentBondType->type, "fixed" ) ){ |
| 766 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 767 |
> |
sprintf( painCave.errMsg, |
| 768 |
> |
"Error parseing BondTypes: line %d\n", lineNum ); |
| 769 |
> |
painCave.isFatal = 1; |
| 770 |
> |
simError(); |
| 771 |
> |
} |
| 772 |
> |
|
| 773 |
> |
sscanf( the_token, "%lf", ¤tBondType->d0 ); |
| 774 |
> |
} |
| 775 |
> |
|
| 776 |
> |
else{ |
| 777 |
> |
sprintf( painCave.errMsg, |
| 778 |
> |
"Unknown TraPPE_Ex bond type \"%s\" at line %d\n", |
| 779 |
> |
currentBondType->type, |
| 780 |
> |
lineNum ); |
| 781 |
> |
painCave.isFatal = 1; |
| 782 |
> |
simError(); |
| 783 |
> |
} |
| 784 |
|
} |
| 445 |
– |
|
| 446 |
– |
else{ |
| 447 |
– |
fprintf(stderr, |
| 448 |
– |
"Unknown TraPPE_Ex bond type \"%s\" at line %d\n", |
| 449 |
– |
currentBondType->type, |
| 450 |
– |
lineNum ); |
| 451 |
– |
exit(8); |
| 452 |
– |
} |
| 785 |
|
} |
| 786 |
+ |
|
| 787 |
+ |
tempBondType = new LinkedType; |
| 788 |
+ |
currentBondType->next = tempBondType; |
| 789 |
+ |
currentBondType = tempBondType; |
| 790 |
+ |
|
| 791 |
+ |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 792 |
+ |
lineNum++; |
| 793 |
|
} |
| 794 |
|
|
| 795 |
< |
tempBondType = new LinkedType; |
| 457 |
< |
currentBondType->next = tempBondType; |
| 458 |
< |
currentBondType = tempBondType; |
| 795 |
> |
#ifdef IS_MPI |
| 796 |
|
|
| 797 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 798 |
< |
lineNum++; |
| 797 |
> |
// send out the linked list to all the other processes |
| 798 |
> |
|
| 799 |
> |
sprintf( checkPointMsg, |
| 800 |
> |
"TraPPE_Ex bond structures read successfully." ); |
| 801 |
> |
MPIcheckPoint(); |
| 802 |
> |
|
| 803 |
> |
currentBondType = headBondType; |
| 804 |
> |
while( currentBondType != NULL ){ |
| 805 |
> |
currentBondType->duplicate( info ); |
| 806 |
> |
sendFrcStruct( &info, mpiBondStructType ); |
| 807 |
> |
currentBondType = currentBondType->next; |
| 808 |
> |
} |
| 809 |
> |
info.last = 1; |
| 810 |
> |
sendFrcStruct( &info, mpiBondStructType ); |
| 811 |
> |
|
| 812 |
|
} |
| 813 |
|
|
| 814 |
+ |
else{ |
| 815 |
+ |
|
| 816 |
+ |
// listen for node 0 to send out the force params |
| 817 |
+ |
|
| 818 |
+ |
MPIcheckPoint(); |
| 819 |
+ |
|
| 820 |
+ |
headBondType = new LinkedType; |
| 821 |
+ |
recieveFrcStruct( &info, mpiBondStructType ); |
| 822 |
+ |
while( !info.last ){ |
| 823 |
+ |
|
| 824 |
+ |
headBondType->add( info ); |
| 825 |
+ |
recieveFrcStruct( &info, mpiBondStructType ); |
| 826 |
+ |
} |
| 827 |
+ |
} |
| 828 |
+ |
#endif // is_mpi |
| 829 |
|
|
| 830 |
+ |
|
| 831 |
|
// initialize the Bonds |
| 832 |
|
|
| 833 |
|
|
| 840 |
|
atomB = the_atoms[b]->getType(); |
| 841 |
|
currentBondType = headBondType->find( atomA, atomB ); |
| 842 |
|
if( currentBondType == NULL ){ |
| 843 |
< |
fprintf( stderr, "BondType error, %s - %s not found in force file.\n", |
| 843 |
> |
sprintf( painCave.errMsg, |
| 844 |
> |
"BondType error, %s - %s not found in force file.\n", |
| 845 |
|
atomA, atomB ); |
| 846 |
< |
exit(8); |
| 846 |
> |
painCave.isFatal = 1; |
| 847 |
> |
simError(); |
| 848 |
|
} |
| 849 |
|
|
| 850 |
|
if( !strcmp( currentBondType->type, "fixed" ) ){ |
| 861 |
|
|
| 862 |
|
delete headBondType; |
| 863 |
|
|
| 864 |
+ |
#ifdef IS_MPI |
| 865 |
+ |
sprintf( checkPointMsg, "TraPPE_Ex bonds initialized succesfully" ); |
| 866 |
+ |
MPIcheckPoint(); |
| 867 |
+ |
#endif // is_mpi |
| 868 |
+ |
|
| 869 |
|
} |
| 870 |
|
|
| 871 |
|
void TraPPE_ExFF::initializeBends( bend_set* the_bends ){ |
| 890 |
|
return NULL; |
| 891 |
|
} |
| 892 |
|
|
| 893 |
+ |
#ifdef IS_MPI |
| 894 |
+ |
|
| 895 |
+ |
void add( bendStruct &info ){ |
| 896 |
+ |
if( next != NULL ) next->add(info); |
| 897 |
+ |
else{ |
| 898 |
+ |
next = new LinkedType(); |
| 899 |
+ |
strcpy(next->nameA, info.nameA); |
| 900 |
+ |
strcpy(next->nameB, info.nameB); |
| 901 |
+ |
strcpy(next->nameC, info.nameC); |
| 902 |
+ |
strcpy(next->type, info.type); |
| 903 |
+ |
next->k1 = info.k1; |
| 904 |
+ |
next->k2 = info.k2; |
| 905 |
+ |
next->k3 = info.k3; |
| 906 |
+ |
next->t0 = info.t0; |
| 907 |
+ |
} |
| 908 |
+ |
} |
| 909 |
+ |
|
| 910 |
+ |
void duplicate( bendStruct &info ){ |
| 911 |
+ |
strcpy(info.nameA, nameA); |
| 912 |
+ |
strcpy(info.nameB, nameB); |
| 913 |
+ |
strcpy(info.nameC, nameC); |
| 914 |
+ |
strcpy(info.type, type); |
| 915 |
+ |
info.k1 = k1; |
| 916 |
+ |
info.k2 = k2; |
| 917 |
+ |
info.k3 = k3; |
| 918 |
+ |
info.t0 = t0; |
| 919 |
+ |
info.last = 0; |
| 920 |
+ |
} |
| 921 |
+ |
|
| 922 |
+ |
#endif // is_mpi |
| 923 |
+ |
|
| 924 |
|
char nameA[15]; |
| 925 |
|
char nameB[15]; |
| 926 |
|
char nameC[15]; |
| 934 |
|
LinkedType* currentBendType; |
| 935 |
|
LinkedType* tempBendType; |
| 936 |
|
|
| 937 |
+ |
#ifdef IS_MPI |
| 938 |
+ |
bendStruct info; |
| 939 |
+ |
info.last = 1; // initialize last to have the last set. |
| 940 |
+ |
// if things go well, last will be set to 0 |
| 941 |
+ |
#endif |
| 942 |
+ |
|
| 943 |
|
char readLine[500]; |
| 944 |
|
char* the_token; |
| 945 |
|
char* eof_test; |
| 958 |
|
the_atoms = entry_plug->atoms; |
| 959 |
|
nBends = entry_plug->n_bends; |
| 960 |
|
|
| 551 |
– |
// read in the bend types. |
| 961 |
|
|
| 962 |
< |
rewind( frcFile ); |
| 963 |
< |
headBendType = new LinkedType; |
| 964 |
< |
currentBendType = headBendType; |
| 556 |
< |
|
| 557 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 558 |
< |
lineNum++; |
| 559 |
< |
if( eof_test == NULL ){ |
| 560 |
< |
fprintf( stderr, "Error in reading Bends from force file.\n" ); |
| 561 |
< |
exit(8); |
| 562 |
< |
} |
| 962 |
> |
#ifdef IS_MPI |
| 963 |
> |
if( worldRank == 0 ){ |
| 964 |
> |
#endif |
| 965 |
|
|
| 966 |
+ |
// read in the bend types. |
| 967 |
+ |
|
| 968 |
+ |
rewind( frcFile ); |
| 969 |
+ |
headBendType = new LinkedType; |
| 970 |
+ |
currentBendType = headBendType; |
| 971 |
|
|
| 972 |
< |
while( !foundBend ){ |
| 973 |
< |
while( eof_test != NULL && readLine[0] != '#' ){ |
| 567 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 568 |
< |
lineNum++; |
| 569 |
< |
} |
| 972 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 973 |
> |
lineNum++; |
| 974 |
|
if( eof_test == NULL ){ |
| 975 |
< |
fprintf( stderr, |
| 976 |
< |
"Error in reading Bends from force file at line %d.\n", |
| 977 |
< |
lineNum ); |
| 574 |
< |
exit(8); |
| 975 |
> |
sprintf( painCave.errMsg, "Error in reading Bends from force file.\n" ); |
| 976 |
> |
painCave.isFatal = 1; |
| 977 |
> |
simError(); |
| 978 |
|
} |
| 979 |
|
|
| 980 |
< |
the_token = strtok( readLine, " ,;\t#\n" ); |
| 981 |
< |
foundBend = !strcmp( "BendTypes", the_token ); |
| 982 |
< |
|
| 983 |
< |
if( !foundBend ){ |
| 984 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 985 |
< |
lineNum++; |
| 583 |
< |
|
| 980 |
> |
|
| 981 |
> |
while( !foundBend ){ |
| 982 |
> |
while( eof_test != NULL && readLine[0] != '#' ){ |
| 983 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 984 |
> |
lineNum++; |
| 985 |
> |
} |
| 986 |
|
if( eof_test == NULL ){ |
| 987 |
< |
fprintf( stderr, |
| 987 |
> |
sprintf( painCave.errMsg, |
| 988 |
|
"Error in reading Bends from force file at line %d.\n", |
| 989 |
|
lineNum ); |
| 990 |
< |
exit(8); |
| 991 |
< |
} |
| 990 |
> |
painCave.isFatal = 1; |
| 991 |
> |
simError(); |
| 992 |
> |
} |
| 993 |
> |
|
| 994 |
> |
the_token = strtok( readLine, " ,;\t#\n" ); |
| 995 |
> |
foundBend = !strcmp( "BendTypes", the_token ); |
| 996 |
> |
|
| 997 |
> |
if( !foundBend ){ |
| 998 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 999 |
> |
lineNum++; |
| 1000 |
> |
|
| 1001 |
> |
if( eof_test == NULL ){ |
| 1002 |
> |
sprintf( painCave.errMsg, |
| 1003 |
> |
"Error in reading Bends from force file at line %d.\n", |
| 1004 |
> |
lineNum ); |
| 1005 |
> |
painCave.isFatal = 1; |
| 1006 |
> |
simError(); |
| 1007 |
> |
} |
| 1008 |
> |
} |
| 1009 |
|
} |
| 591 |
– |
} |
| 1010 |
|
|
| 1011 |
< |
// we are now at the BendTypes section. |
| 1011 |
> |
// we are now at the BendTypes section. |
| 1012 |
|
|
| 1013 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1014 |
< |
lineNum++; |
| 1013 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1014 |
> |
lineNum++; |
| 1015 |
|
|
| 1016 |
< |
if( eof_test == NULL ){ |
| 1017 |
< |
fprintf( stderr, |
| 1018 |
< |
"Error in reading Bends from force file at line %d.\n", |
| 1019 |
< |
lineNum ); |
| 1020 |
< |
exit(8); |
| 1021 |
< |
} |
| 1016 |
> |
if( eof_test == NULL ){ |
| 1017 |
> |
sprintf( painCave.errMsg, |
| 1018 |
> |
"Error in reading Bends from force file at line %d.\n", |
| 1019 |
> |
lineNum ); |
| 1020 |
> |
painCave.isFatal = 1; |
| 1021 |
> |
simError(); |
| 1022 |
> |
} |
| 1023 |
|
|
| 1024 |
< |
while( readLine[0] != '#' && eof_test != NULL ){ |
| 1024 |
> |
while( readLine[0] != '#' && eof_test != NULL ){ |
| 1025 |
|
|
| 1026 |
< |
if( readLine[0] != '!' ){ |
| 1026 |
> |
if( readLine[0] != '!' ){ |
| 1027 |
|
|
| 1028 |
< |
the_token = strtok( readLine, " \n\t,;" ); |
| 1029 |
< |
if( the_token != NULL ){ |
| 1028 |
> |
the_token = strtok( readLine, " \n\t,;" ); |
| 1029 |
> |
if( the_token != NULL ){ |
| 1030 |
|
|
| 1031 |
< |
strcpy( currentBendType->nameA, the_token ); |
| 1031 |
> |
strcpy( currentBendType->nameA, the_token ); |
| 1032 |
|
|
| 1033 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1034 |
< |
fprintf( stderr, "Error parseing BendTypes: line %d\n", lineNum ); |
| 1035 |
< |
exit(8); |
| 1036 |
< |
} |
| 1033 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1034 |
> |
sprintf( painCave.errMsg, |
| 1035 |
> |
"Error parseing BendTypes: line %d\n", lineNum ); |
| 1036 |
> |
painCave.isFatal = 1; |
| 1037 |
> |
simError(); |
| 1038 |
> |
} |
| 1039 |
|
|
| 1040 |
< |
strcpy( currentBendType->nameB, the_token ); |
| 1040 |
> |
strcpy( currentBendType->nameB, the_token ); |
| 1041 |
|
|
| 1042 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1043 |
< |
fprintf( stderr, "Error parseing BendTypes: line %d\n", lineNum ); |
| 1044 |
< |
exit(8); |
| 1045 |
< |
} |
| 1042 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1043 |
> |
sprintf( painCave.errMsg, |
| 1044 |
> |
"Error parseing BendTypes: line %d\n", lineNum ); |
| 1045 |
> |
painCave.isFatal = 1; |
| 1046 |
> |
simError(); |
| 1047 |
> |
} |
| 1048 |
|
|
| 1049 |
< |
strcpy( currentBendType->nameC, the_token ); |
| 1049 |
> |
strcpy( currentBendType->nameC, the_token ); |
| 1050 |
|
|
| 628 |
– |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 629 |
– |
fprintf( stderr, "Error parseing BendTypes: line %d\n", lineNum ); |
| 630 |
– |
exit(8); |
| 631 |
– |
} |
| 632 |
– |
|
| 633 |
– |
strcpy( currentBendType->type, the_token ); |
| 634 |
– |
|
| 635 |
– |
if( !strcmp( currentBendType->type, "quadratic" ) ){ |
| 1051 |
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1052 |
< |
fprintf( stderr, "Error parseing BendTypes: line %d\n", lineNum ); |
| 1053 |
< |
exit(8); |
| 1052 |
> |
sprintf( painCave.errMsg, |
| 1053 |
> |
"Error parseing BendTypes: line %d\n", lineNum ); |
| 1054 |
> |
painCave.isFatal = 1; |
| 1055 |
> |
simError(); |
| 1056 |
|
} |
| 1057 |
+ |
|
| 1058 |
+ |
strcpy( currentBendType->type, the_token ); |
| 1059 |
+ |
|
| 1060 |
+ |
if( !strcmp( currentBendType->type, "quadratic" ) ){ |
| 1061 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1062 |
+ |
sprintf( painCave.errMsg, |
| 1063 |
+ |
"Error parseing BendTypes: line %d\n", lineNum ); |
| 1064 |
+ |
painCave.isFatal = 1; |
| 1065 |
+ |
simError(); |
| 1066 |
+ |
} |
| 1067 |
|
|
| 1068 |
< |
sscanf( the_token, "%lf", ¤tBendType->k1 ); |
| 1068 |
> |
sscanf( the_token, "%lf", ¤tBendType->k1 ); |
| 1069 |
|
|
| 1070 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1071 |
< |
fprintf( stderr, "Error parseing BendTypes: line %d\n", lineNum ); |
| 1072 |
< |
exit(8); |
| 1073 |
< |
} |
| 1070 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1071 |
> |
sprintf( painCave.errMsg, |
| 1072 |
> |
"Error parseing BendTypes: line %d\n", lineNum ); |
| 1073 |
> |
painCave.isFatal = 1; |
| 1074 |
> |
simError(); |
| 1075 |
> |
} |
| 1076 |
|
|
| 1077 |
< |
sscanf( the_token, "%lf", ¤tBendType->k2 ); |
| 1077 |
> |
sscanf( the_token, "%lf", ¤tBendType->k2 ); |
| 1078 |
|
|
| 1079 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1080 |
< |
fprintf( stderr, "Error parseing BendTypes: line %d\n", lineNum ); |
| 1081 |
< |
exit(8); |
| 1082 |
< |
} |
| 1079 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1080 |
> |
sprintf( painCave.errMsg, |
| 1081 |
> |
"Error parseing BendTypes: line %d\n", lineNum ); |
| 1082 |
> |
painCave.isFatal = 1; |
| 1083 |
> |
simError(); |
| 1084 |
> |
} |
| 1085 |
|
|
| 1086 |
< |
sscanf( the_token, "%lf", ¤tBendType->k3 ); |
| 1086 |
> |
sscanf( the_token, "%lf", ¤tBendType->k3 ); |
| 1087 |
|
|
| 1088 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1089 |
< |
fprintf( stderr, "Error parseing BendTypes: line %d\n", lineNum ); |
| 1090 |
< |
exit(8); |
| 1091 |
< |
} |
| 1088 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1089 |
> |
sprintf( painCave.errMsg, |
| 1090 |
> |
"Error parseing BendTypes: line %d\n", lineNum ); |
| 1091 |
> |
painCave.isFatal = 1; |
| 1092 |
> |
simError(); |
| 1093 |
> |
} |
| 1094 |
|
|
| 1095 |
< |
sscanf( the_token, "%lf", ¤tBendType->t0 ); |
| 1096 |
< |
} |
| 1095 |
> |
sscanf( the_token, "%lf", ¤tBendType->t0 ); |
| 1096 |
> |
} |
| 1097 |
|
|
| 1098 |
< |
else{ |
| 1099 |
< |
fprintf(stderr, |
| 1100 |
< |
"Unknown TraPPE_Ex bend type \"%s\" at line %d\n", |
| 1101 |
< |
currentBendType->type, |
| 1102 |
< |
lineNum ); |
| 1103 |
< |
exit(8); |
| 1104 |
< |
} |
| 1098 |
> |
else{ |
| 1099 |
> |
sprintf( painCave.errMsg, |
| 1100 |
> |
"Unknown TraPPE_Ex bend type \"%s\" at line %d\n", |
| 1101 |
> |
currentBendType->type, |
| 1102 |
> |
lineNum ); |
| 1103 |
> |
painCave.isFatal = 1; |
| 1104 |
> |
simError(); |
| 1105 |
> |
} |
| 1106 |
> |
} |
| 1107 |
|
} |
| 1108 |
+ |
|
| 1109 |
+ |
tempBendType = new LinkedType; |
| 1110 |
+ |
currentBendType->next = tempBendType; |
| 1111 |
+ |
currentBendType = tempBendType; |
| 1112 |
+ |
|
| 1113 |
+ |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1114 |
+ |
lineNum++; |
| 1115 |
|
} |
| 1116 |
+ |
|
| 1117 |
+ |
#ifdef IS_MPI |
| 1118 |
|
|
| 1119 |
< |
tempBendType = new LinkedType; |
| 1120 |
< |
currentBendType->next = tempBendType; |
| 1121 |
< |
currentBendType = tempBendType; |
| 1119 |
> |
// send out the linked list to all the other processes |
| 1120 |
> |
|
| 1121 |
> |
sprintf( checkPointMsg, |
| 1122 |
> |
"TraPPE_Ex bend structures read successfully." ); |
| 1123 |
> |
MPIcheckPoint(); |
| 1124 |
> |
|
| 1125 |
> |
currentBendType = headBendType; |
| 1126 |
> |
while( currentBendType != NULL ){ |
| 1127 |
> |
currentBendType->duplicate( info ); |
| 1128 |
> |
sendFrcStruct( &info, mpiBendStructType ); |
| 1129 |
> |
currentBendType = currentBendType->next; |
| 1130 |
> |
} |
| 1131 |
> |
info.last = 1; |
| 1132 |
> |
sendFrcStruct( &info, mpiBendStructType ); |
| 1133 |
|
|
| 679 |
– |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 680 |
– |
lineNum++; |
| 1134 |
|
} |
| 1135 |
|
|
| 1136 |
+ |
else{ |
| 1137 |
+ |
|
| 1138 |
+ |
// listen for node 0 to send out the force params |
| 1139 |
+ |
|
| 1140 |
+ |
MPIcheckPoint(); |
| 1141 |
+ |
|
| 1142 |
+ |
headBendType = new LinkedType; |
| 1143 |
+ |
recieveFrcStruct( &info, mpiBendStructType ); |
| 1144 |
+ |
while( !info.last ){ |
| 1145 |
+ |
|
| 1146 |
+ |
headBendType->add( info ); |
| 1147 |
+ |
recieveFrcStruct( &info, mpiBendStructType ); |
| 1148 |
+ |
} |
| 1149 |
+ |
} |
| 1150 |
+ |
#endif // is_mpi |
| 1151 |
|
|
| 1152 |
|
// initialize the Bends |
| 1153 |
|
|
| 1162 |
|
atomC = the_atoms[c]->getType(); |
| 1163 |
|
currentBendType = headBendType->find( atomA, atomB, atomC ); |
| 1164 |
|
if( currentBendType == NULL ){ |
| 1165 |
< |
fprintf( stderr, "BendType error, %s - %s - %s not found" |
| 1165 |
> |
sprintf( painCave.errMsg, "BendType error, %s - %s - %s not found" |
| 1166 |
|
" in force file.\n", |
| 1167 |
|
atomA, atomB, atomC ); |
| 1168 |
< |
exit(8); |
| 1168 |
> |
painCave.isFatal = 1; |
| 1169 |
> |
simError(); |
| 1170 |
|
} |
| 1171 |
|
|
| 1172 |
|
if( !strcmp( currentBendType->type, "quadratic" ) ){ |
| 1188 |
|
|
| 1189 |
|
delete headBendType; |
| 1190 |
|
|
| 1191 |
+ |
#ifdef IS_MPI |
| 1192 |
+ |
sprintf( checkPointMsg, "TraPPE_Ex bends initialized succesfully" ); |
| 1193 |
+ |
MPIcheckPoint(); |
| 1194 |
+ |
#endif // is_mpi |
| 1195 |
+ |
|
| 1196 |
|
} |
| 1197 |
|
|
| 1198 |
|
void TraPPE_ExFF::initializeTorsions( torsion_set* the_torsions ){ |
| 1219 |
|
return NULL; |
| 1220 |
|
} |
| 1221 |
|
|
| 1222 |
+ |
#ifdef IS_MPI |
| 1223 |
+ |
|
| 1224 |
+ |
void add( torsionStruct &info ){ |
| 1225 |
+ |
if( next != NULL ) next->add(info); |
| 1226 |
+ |
else{ |
| 1227 |
+ |
next = new LinkedType(); |
| 1228 |
+ |
strcpy(next->nameA, info.nameA); |
| 1229 |
+ |
strcpy(next->nameB, info.nameB); |
| 1230 |
+ |
strcpy(next->nameC, info.nameC); |
| 1231 |
+ |
strcpy(next->type, info.type); |
| 1232 |
+ |
next->k1 = info.k1; |
| 1233 |
+ |
next->k2 = info.k2; |
| 1234 |
+ |
next->k3 = info.k3; |
| 1235 |
+ |
next->k4 = info.k4; |
| 1236 |
+ |
} |
| 1237 |
+ |
} |
| 1238 |
+ |
|
| 1239 |
+ |
void duplicate( torsionStruct &info ){ |
| 1240 |
+ |
strcpy(info.nameA, nameA); |
| 1241 |
+ |
strcpy(info.nameB, nameB); |
| 1242 |
+ |
strcpy(info.nameC, nameC); |
| 1243 |
+ |
strcpy(info.nameD, nameD); |
| 1244 |
+ |
strcpy(info.type, type); |
| 1245 |
+ |
info.k1 = k1; |
| 1246 |
+ |
info.k2 = k2; |
| 1247 |
+ |
info.k3 = k3; |
| 1248 |
+ |
info.k4 = k4; |
| 1249 |
+ |
info.last = 0; |
| 1250 |
+ |
} |
| 1251 |
+ |
|
| 1252 |
+ |
#endif |
| 1253 |
+ |
|
| 1254 |
|
char nameA[15]; |
| 1255 |
|
char nameB[15]; |
| 1256 |
|
char nameC[15]; |
| 1265 |
|
LinkedType* currentTorsionType; |
| 1266 |
|
LinkedType* tempTorsionType; |
| 1267 |
|
|
| 1268 |
+ |
#ifdef IS_MPI |
| 1269 |
+ |
torsionStruct info; |
| 1270 |
+ |
info.last = 1; // initialize last to have the last set. |
| 1271 |
+ |
// if things go well, last will be set to 0 |
| 1272 |
+ |
#endif |
| 1273 |
+ |
|
| 1274 |
|
char readLine[500]; |
| 1275 |
|
char* the_token; |
| 1276 |
|
char* eof_test; |
| 1290 |
|
the_atoms = entry_plug->atoms; |
| 1291 |
|
nTorsions = entry_plug->n_torsions; |
| 1292 |
|
|
| 1293 |
< |
// read in the torsion types. |
| 1293 |
> |
#ifdef IS_MPI |
| 1294 |
> |
if( worldRank == 0 ){ |
| 1295 |
> |
#endif |
| 1296 |
|
|
| 1297 |
< |
rewind( frcFile ); |
| 784 |
< |
headTorsionType = new LinkedType; |
| 785 |
< |
currentTorsionType = headTorsionType; |
| 786 |
< |
|
| 787 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 788 |
< |
lineNum++; |
| 789 |
< |
if( eof_test == NULL ){ |
| 790 |
< |
fprintf( stderr, "Error in reading Torsions from force file.\n" ); |
| 791 |
< |
exit(8); |
| 792 |
< |
} |
| 1297 |
> |
// read in the torsion types. |
| 1298 |
|
|
| 1299 |
+ |
rewind( frcFile ); |
| 1300 |
+ |
headTorsionType = new LinkedType; |
| 1301 |
+ |
currentTorsionType = headTorsionType; |
| 1302 |
|
|
| 1303 |
< |
while( !foundTorsion ){ |
| 1304 |
< |
while( eof_test != NULL && readLine[0] != '#' ){ |
| 797 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 798 |
< |
lineNum++; |
| 799 |
< |
} |
| 1303 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1304 |
> |
lineNum++; |
| 1305 |
|
if( eof_test == NULL ){ |
| 1306 |
< |
fprintf( stderr, |
| 1307 |
< |
"Error in reading Torsions from force file at line %d.\n", |
| 1308 |
< |
lineNum ); |
| 1309 |
< |
exit(8); |
| 1306 |
> |
sprintf( painCave.errMsg, |
| 1307 |
> |
"Error in reading Torsions from force file.\n" ); |
| 1308 |
> |
painCave.isFatal = 1; |
| 1309 |
> |
simError(); |
| 1310 |
|
} |
| 1311 |
|
|
| 1312 |
< |
the_token = strtok( readLine, " ,;\t#\n" ); |
| 1313 |
< |
foundTorsion = !strcmp( "TorsionTypes", the_token ); |
| 1314 |
< |
|
| 1315 |
< |
if( !foundTorsion ){ |
| 1316 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1317 |
< |
lineNum++; |
| 813 |
< |
|
| 1312 |
> |
|
| 1313 |
> |
while( !foundTorsion ){ |
| 1314 |
> |
while( eof_test != NULL && readLine[0] != '#' ){ |
| 1315 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1316 |
> |
lineNum++; |
| 1317 |
> |
} |
| 1318 |
|
if( eof_test == NULL ){ |
| 1319 |
< |
fprintf( stderr, |
| 1319 |
> |
sprintf( painCave.errMsg, |
| 1320 |
|
"Error in reading Torsions from force file at line %d.\n", |
| 1321 |
|
lineNum ); |
| 1322 |
< |
exit(8); |
| 1323 |
< |
} |
| 1322 |
> |
painCave.isFatal = 1; |
| 1323 |
> |
simError(); |
| 1324 |
> |
} |
| 1325 |
> |
|
| 1326 |
> |
the_token = strtok( readLine, " ,;\t#\n" ); |
| 1327 |
> |
foundTorsion = !strcmp( "TorsionTypes", the_token ); |
| 1328 |
> |
|
| 1329 |
> |
if( !foundTorsion ){ |
| 1330 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1331 |
> |
lineNum++; |
| 1332 |
> |
|
| 1333 |
> |
if( eof_test == NULL ){ |
| 1334 |
> |
sprintf( painCave.errMsg, |
| 1335 |
> |
"Error in reading Torsions from force file at line %d.\n", |
| 1336 |
> |
lineNum ); |
| 1337 |
> |
painCave.isFatal = 1; |
| 1338 |
> |
simError(); |
| 1339 |
> |
} |
| 1340 |
> |
} |
| 1341 |
|
} |
| 821 |
– |
} |
| 1342 |
|
|
| 1343 |
< |
// we are now at the TorsionTypes section. |
| 1343 |
> |
// we are now at the TorsionTypes section. |
| 1344 |
|
|
| 1345 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1346 |
< |
lineNum++; |
| 1345 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1346 |
> |
lineNum++; |
| 1347 |
|
|
| 1348 |
< |
if( eof_test == NULL ){ |
| 1349 |
< |
fprintf( stderr, |
| 1350 |
< |
"Error in reading Torsions from force file at line %d.\n", |
| 1351 |
< |
lineNum ); |
| 1352 |
< |
exit(8); |
| 1353 |
< |
} |
| 1348 |
> |
if( eof_test == NULL ){ |
| 1349 |
> |
sprintf( painCave.errMsg, |
| 1350 |
> |
"Error in reading Torsions from force file at line %d.\n", |
| 1351 |
> |
lineNum ); |
| 1352 |
> |
painCave.isFatal = 1; |
| 1353 |
> |
simError(); |
| 1354 |
> |
} |
| 1355 |
|
|
| 1356 |
< |
while( readLine[0] != '#' && eof_test != NULL ){ |
| 1356 |
> |
while( readLine[0] != '#' && eof_test != NULL ){ |
| 1357 |
|
|
| 1358 |
< |
if( readLine[0] != '!' ){ |
| 1358 |
> |
if( readLine[0] != '!' ){ |
| 1359 |
|
|
| 1360 |
< |
the_token = strtok( readLine, " \n\t,;" ); |
| 1361 |
< |
if( the_token != NULL ){ |
| 1360 |
> |
the_token = strtok( readLine, " \n\t,;" ); |
| 1361 |
> |
if( the_token != NULL ){ |
| 1362 |
|
|
| 1363 |
< |
strcpy( currentTorsionType->nameA, the_token ); |
| 1363 |
> |
strcpy( currentTorsionType->nameA, the_token ); |
| 1364 |
|
|
| 1365 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1366 |
< |
fprintf( stderr, "Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1367 |
< |
exit(8); |
| 1368 |
< |
} |
| 1365 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1366 |
> |
sprintf( painCave.errMsg, |
| 1367 |
> |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1368 |
> |
painCave.isFatal = 1; |
| 1369 |
> |
simError(); |
| 1370 |
> |
} |
| 1371 |
|
|
| 1372 |
< |
strcpy( currentTorsionType->nameB, the_token ); |
| 1372 |
> |
strcpy( currentTorsionType->nameB, the_token ); |
| 1373 |
|
|
| 1374 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1375 |
< |
fprintf( stderr, "Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1376 |
< |
exit(8); |
| 1377 |
< |
} |
| 1374 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1375 |
> |
sprintf( painCave.errMsg, |
| 1376 |
> |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1377 |
> |
painCave.isFatal = 1; |
| 1378 |
> |
simError(); |
| 1379 |
> |
} |
| 1380 |
|
|
| 1381 |
< |
strcpy( currentTorsionType->nameC, the_token ); |
| 1381 |
> |
strcpy( currentTorsionType->nameC, the_token ); |
| 1382 |
|
|
| 1383 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1384 |
< |
fprintf( stderr, "Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1385 |
< |
exit(8); |
| 1386 |
< |
} |
| 1383 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1384 |
> |
sprintf( painCave.errMsg, |
| 1385 |
> |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1386 |
> |
painCave.isFatal = 1; |
| 1387 |
> |
simError(); |
| 1388 |
> |
} |
| 1389 |
|
|
| 1390 |
< |
strcpy( currentTorsionType->nameD, the_token ); |
| 1390 |
> |
strcpy( currentTorsionType->nameD, the_token ); |
| 1391 |
|
|
| 865 |
– |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 866 |
– |
fprintf( stderr, "Error parseing TorsionTypes: line %d\n", lineNum ); |
| 867 |
– |
exit(8); |
| 868 |
– |
} |
| 869 |
– |
|
| 870 |
– |
strcpy( currentTorsionType->type, the_token ); |
| 871 |
– |
|
| 872 |
– |
if( !strcmp( currentTorsionType->type, "cubic" ) ){ |
| 1392 |
|
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1393 |
< |
fprintf(stderr,"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1394 |
< |
exit(8); |
| 1393 |
> |
sprintf( painCave.errMsg, |
| 1394 |
> |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1395 |
> |
painCave.isFatal = 1; |
| 1396 |
> |
simError(); |
| 1397 |
|
} |
| 1398 |
+ |
|
| 1399 |
+ |
strcpy( currentTorsionType->type, the_token ); |
| 1400 |
+ |
|
| 1401 |
+ |
if( !strcmp( currentTorsionType->type, "cubic" ) ){ |
| 1402 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1403 |
+ |
sprintf( painCave.errMsg, |
| 1404 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1405 |
+ |
painCave.isFatal = 1; |
| 1406 |
+ |
simError(); |
| 1407 |
+ |
} |
| 1408 |
|
|
| 1409 |
< |
sscanf( the_token, "%lf", ¤tTorsionType->k1 ); |
| 1409 |
> |
sscanf( the_token, "%lf", ¤tTorsionType->k1 ); |
| 1410 |
|
|
| 1411 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1412 |
< |
fprintf(stderr,"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1413 |
< |
exit(8); |
| 1414 |
< |
} |
| 1411 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1412 |
> |
sprintf( painCave.errMsg, |
| 1413 |
> |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1414 |
> |
painCave.isFatal = 1; |
| 1415 |
> |
simError(); |
| 1416 |
> |
} |
| 1417 |
|
|
| 1418 |
< |
sscanf( the_token, "%lf", ¤tTorsionType->k2 ); |
| 1418 |
> |
sscanf( the_token, "%lf", ¤tTorsionType->k2 ); |
| 1419 |
|
|
| 1420 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1421 |
< |
fprintf(stderr,"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1422 |
< |
exit(8); |
| 1423 |
< |
} |
| 1420 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1421 |
> |
sprintf( painCave.errMsg, |
| 1422 |
> |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1423 |
> |
painCave.isFatal = 1; |
| 1424 |
> |
simError(); |
| 1425 |
> |
} |
| 1426 |
|
|
| 1427 |
< |
sscanf( the_token, "%lf", ¤tTorsionType->k3 ); |
| 1427 |
> |
sscanf( the_token, "%lf", ¤tTorsionType->k3 ); |
| 1428 |
|
|
| 1429 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1430 |
< |
fprintf(stderr,"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1431 |
< |
exit(8); |
| 1432 |
< |
} |
| 1429 |
> |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1430 |
> |
sprintf( painCave.errMsg, |
| 1431 |
> |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1432 |
> |
painCave.isFatal = 1; |
| 1433 |
> |
simError(); |
| 1434 |
> |
} |
| 1435 |
|
|
| 1436 |
< |
sscanf( the_token, "%lf", ¤tTorsionType->k4 ); |
| 1437 |
< |
} |
| 1436 |
> |
sscanf( the_token, "%lf", ¤tTorsionType->k4 ); |
| 1437 |
> |
} |
| 1438 |
|
|
| 1439 |
< |
else{ |
| 1440 |
< |
fprintf(stderr, |
| 1441 |
< |
"Unknown TraPPE_Ex torsion type \"%s\" at line %d\n", |
| 1442 |
< |
currentTorsionType->type, |
| 1443 |
< |
lineNum ); |
| 1444 |
< |
exit(8); |
| 1445 |
< |
} |
| 1439 |
> |
else{ |
| 1440 |
> |
sprintf( painCave.errMsg, |
| 1441 |
> |
"Unknown TraPPE_Ex torsion type \"%s\" at line %d\n", |
| 1442 |
> |
currentTorsionType->type, |
| 1443 |
> |
lineNum ); |
| 1444 |
> |
painCave.isFatal = 1; |
| 1445 |
> |
simError(); |
| 1446 |
> |
} |
| 1447 |
> |
} |
| 1448 |
|
} |
| 1449 |
+ |
|
| 1450 |
+ |
tempTorsionType = new LinkedType; |
| 1451 |
+ |
currentTorsionType->next = tempTorsionType; |
| 1452 |
+ |
currentTorsionType = tempTorsionType; |
| 1453 |
+ |
|
| 1454 |
+ |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1455 |
+ |
lineNum++; |
| 1456 |
|
} |
| 1457 |
+ |
|
| 1458 |
+ |
#ifdef IS_MPI |
| 1459 |
|
|
| 1460 |
< |
tempTorsionType = new LinkedType; |
| 913 |
< |
currentTorsionType->next = tempTorsionType; |
| 914 |
< |
currentTorsionType = tempTorsionType; |
| 1460 |
> |
// send out the linked list to all the other processes |
| 1461 |
|
|
| 1462 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1463 |
< |
lineNum++; |
| 1462 |
> |
sprintf( checkPointMsg, |
| 1463 |
> |
"TraPPE_Ex torsion structures read successfully." ); |
| 1464 |
> |
MPIcheckPoint(); |
| 1465 |
> |
|
| 1466 |
> |
currentTorsionType = headTorsionType; |
| 1467 |
> |
while( currentTorsionType != NULL ){ |
| 1468 |
> |
currentTorsionType->duplicate( info ); |
| 1469 |
> |
sendFrcStruct( &info, mpiTorsionStructType ); |
| 1470 |
> |
currentTorsionType = currentTorsionType->next; |
| 1471 |
> |
} |
| 1472 |
> |
info.last = 1; |
| 1473 |
> |
sendFrcStruct( &info, mpiTorsionStructType ); |
| 1474 |
> |
|
| 1475 |
|
} |
| 1476 |
|
|
| 1477 |
+ |
else{ |
| 1478 |
+ |
|
| 1479 |
+ |
// listen for node 0 to send out the force params |
| 1480 |
+ |
|
| 1481 |
+ |
MPIcheckPoint(); |
| 1482 |
+ |
|
| 1483 |
+ |
headTorsionType = new LinkedType; |
| 1484 |
+ |
recieveFrcStruct( &info, mpiTorsionStructType ); |
| 1485 |
+ |
while( !info.last ){ |
| 1486 |
+ |
|
| 1487 |
+ |
headTorsionType->add( info ); |
| 1488 |
+ |
recieveFrcStruct( &info, mpiTorsionStructType ); |
| 1489 |
+ |
} |
| 1490 |
+ |
} |
| 1491 |
+ |
#endif // is_mpi |
| 1492 |
|
|
| 1493 |
|
// initialize the Torsions |
| 1494 |
|
|
| 1505 |
|
atomD = the_atoms[d]->getType(); |
| 1506 |
|
currentTorsionType = headTorsionType->find( atomA, atomB, atomC, atomD ); |
| 1507 |
|
if( currentTorsionType == NULL ){ |
| 1508 |
< |
fprintf( stderr, "TorsionType error, %s - %s - %s - %s not found" |
| 1508 |
> |
sprintf( painCave.errMsg, |
| 1509 |
> |
"TorsionType error, %s - %s - %s - %s not found" |
| 1510 |
|
" in force file.\n", |
| 1511 |
|
atomA, atomB, atomC, atomD ); |
| 1512 |
< |
exit(8); |
| 1512 |
> |
painCave.isFatal = 1; |
| 1513 |
> |
simError(); |
| 1514 |
|
} |
| 1515 |
|
|
| 1516 |
|
if( !strcmp( currentTorsionType->type, "cubic" ) ){ |
| 1529 |
|
|
| 1530 |
|
delete headTorsionType; |
| 1531 |
|
|
| 1532 |
+ |
#ifdef IS_MPI |
| 1533 |
+ |
sprintf( checkPointMsg, "TraPPE_Ex torsions initialized succesfully" ); |
| 1534 |
+ |
MPIcheckPoint(); |
| 1535 |
+ |
#endif // is_mpi |
| 1536 |
+ |
|
| 1537 |
|
} |