9 |
|
#include "SRI.hpp" |
10 |
|
|
11 |
|
|
12 |
+ |
#ifdef IS_MPI |
13 |
+ |
|
14 |
+ |
int myNode; |
15 |
+ |
|
16 |
+ |
// Declare the structures that will be passed by MPI |
17 |
+ |
|
18 |
+ |
typedef struct{ |
19 |
+ |
char name[15]; |
20 |
+ |
double mass; |
21 |
+ |
double epslon; |
22 |
+ |
double sigma; |
23 |
+ |
double dipole; |
24 |
+ |
int isDipole; |
25 |
+ |
int last; // 0 -> default |
26 |
+ |
// 1 -> tells nodes to stop listening |
27 |
+ |
// -1 -> an error has occured. (handled in mpiForceField) |
28 |
+ |
} atomStruct; |
29 |
+ |
MPI_Datatype mpiAtomStructType; |
30 |
+ |
|
31 |
+ |
typedef struct{ |
32 |
+ |
char nameA[15]; |
33 |
+ |
char nameB[15]; |
34 |
+ |
char type[30]; |
35 |
+ |
double d0; |
36 |
+ |
int last; // 0 -> default |
37 |
+ |
// 1 -> tells nodes to stop listening |
38 |
+ |
// -1 -> an error has occured. (handled in mpiForceField) |
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 |
+ |
// -1 -> an error has occured. (handled in mpiForceField) |
51 |
+ |
} bendStruct; |
52 |
+ |
MPI_Datatype mpiBendStructType; |
53 |
+ |
|
54 |
+ |
typedef struct{ |
55 |
+ |
char nameA[15]; |
56 |
+ |
char nameB[15]; |
57 |
+ |
char nameC[15]; |
58 |
+ |
char nameD[15]; |
59 |
+ |
char type[30]; |
60 |
+ |
double k1, k2, k3, k4; |
61 |
+ |
int last; // 0 -> default |
62 |
+ |
// 1 -> tells nodes to stop listening |
63 |
+ |
// -1 -> an error has occured. (handled in mpiForceField) |
64 |
+ |
} TorsionStruct; |
65 |
+ |
MPI_Datatype mpiTorsionStructType; |
66 |
+ |
|
67 |
+ |
#endif |
68 |
+ |
|
69 |
+ |
|
70 |
+ |
|
71 |
|
TraPPE_ExFF::TraPPE_ExFF(){ |
72 |
|
|
73 |
|
char fileName[200]; |
75 |
|
char* ffPath; |
76 |
|
char temp[200]; |
77 |
|
|
78 |
< |
// generate the force file name |
78 |
> |
#ifdef IS_MPI |
79 |
> |
int i; |
80 |
> |
int mpiError; |
81 |
|
|
82 |
< |
strcpy( fileName, "TraPPE_Ex.frc" ); |
82 |
> |
mpiError = MPI_Comm_rank(MPI_COMM_WORLD,&myNode); |
83 |
|
|
84 |
< |
// attempt to open the file in the current directory first. |
84 |
> |
atomStruct atomProto; // mpiPrototype |
85 |
> |
int atomBC[3] = {15,4,2}; // block counts |
86 |
> |
MPI_Aint atomDspls[3]; // displacements |
87 |
> |
MPI_Datatype atomMbrTypes[3]; // member mpi types |
88 |
> |
|
89 |
|
|
25 |
– |
frcFile = fopen( fileName, "r" ); |
90 |
|
|
91 |
< |
if( frcFile == NULL ){ |
91 |
> |
MPI_Address(&atomProto.name, &atomDspls[0]); |
92 |
> |
MPI_Address(&atomProto.mass, &atomDspls[1]); |
93 |
> |
MPI_Address(&atomProto.isDipole, &atomDspls[2]); |
94 |
> |
|
95 |
> |
atomMbrTypes[0] = MPI_CHAR; |
96 |
> |
atomMbrTypes[1] = MPI_DOUBLE; |
97 |
> |
atomMbrTypes[2] = MPI_INT; |
98 |
> |
|
99 |
> |
for (i=2; i >= 0; i--) atomDspls[i] -= atomDspls[0]; |
100 |
> |
|
101 |
> |
MPI_Type_struct(3, atomBC, atomDspls, atomMbrTypes, &mpiAtomStructType); |
102 |
> |
MPI_Type_commit(&mpiAtomStructType); |
103 |
|
|
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 ); |
104 |
|
|
105 |
+ |
|
106 |
+ |
|
107 |
+ |
if( myNode == 0 ){ |
108 |
+ |
#endif |
109 |
+ |
|
110 |
+ |
// generate the force file name |
111 |
+ |
|
112 |
+ |
strcpy( fileName, "TraPPE_Ex.frc" ); |
113 |
+ |
fprintf( stderr,"Trying to open %s\n", fileName ); |
114 |
+ |
|
115 |
+ |
// attempt to open the file in the current directory first. |
116 |
+ |
|
117 |
|
frcFile = fopen( fileName, "r" ); |
118 |
|
|
119 |
|
if( frcFile == NULL ){ |
120 |
|
|
121 |
< |
fprintf( stderr, |
122 |
< |
"Error opening the force field parameter file: %s\n" |
123 |
< |
"Have you tried setting the FORCE_PARAM_PATH environment " |
124 |
< |
"vairable?\n", |
125 |
< |
fileName ); |
126 |
< |
exit( 8 ); |
121 |
> |
// next see if the force path enviorment variable is set |
122 |
> |
|
123 |
> |
ffPath = getenv( ffPath_env ); |
124 |
> |
if( ffPath == NULL ) { |
125 |
> |
fprintf( stderr, |
126 |
> |
"Error opening the force field parameter file: %s\n" |
127 |
> |
"Have you tried setting the FORCE_PARAM_PATH environment " |
128 |
> |
"vairable?\n", |
129 |
> |
fileName ); |
130 |
> |
exit( 8 ); |
131 |
> |
} |
132 |
> |
|
133 |
> |
|
134 |
> |
strcpy( temp, ffPath ); |
135 |
> |
strcat( temp, "/" ); |
136 |
> |
strcat( temp, fileName ); |
137 |
> |
strcpy( fileName, temp ); |
138 |
> |
|
139 |
> |
frcFile = fopen( fileName, "r" ); |
140 |
> |
|
141 |
> |
if( frcFile == NULL ){ |
142 |
> |
|
143 |
> |
fprintf( stderr, |
144 |
> |
"Error opening the force field parameter file: %s\n" |
145 |
> |
"Have you tried setting the FORCE_PARAM_PATH environment " |
146 |
> |
"vairable?\n", |
147 |
> |
fileName ); |
148 |
> |
exit( 8 ); |
149 |
> |
} |
150 |
|
} |
151 |
+ |
#ifdef IS_MPI |
152 |
|
} |
153 |
+ |
#endif |
154 |
|
} |
155 |
|
|
156 |
+ |
|
157 |
|
TraPPE_ExFF::~TraPPE_ExFF(){ |
158 |
|
|
159 |
|
fclose( frcFile ); |
175 |
|
return NULL; |
176 |
|
} |
177 |
|
|
178 |
+ |
#ifdef IS_MPI |
179 |
+ |
void add( atomStruct &info ){ |
180 |
+ |
if( next != NULL ) next->add(info); |
181 |
+ |
else{ |
182 |
+ |
next = new LinkedType(); |
183 |
+ |
strcpy(next->name, info.name); |
184 |
+ |
next->isDipole = info.dipole; |
185 |
+ |
next->mass = info.mass; |
186 |
+ |
next->epslon = info.epslon; |
187 |
+ |
next->sigma = info.sigma; |
188 |
+ |
next->dipole = info.dipole; |
189 |
+ |
} |
190 |
+ |
} |
191 |
+ |
|
192 |
+ |
void duplicate( atomStruct &info ){ |
193 |
+ |
strcpy(info.name, name); |
194 |
+ |
info.isDipole = dipole; |
195 |
+ |
info.mass = mass; |
196 |
+ |
info.epslon = epslon; |
197 |
+ |
info.sigma = sigma; |
198 |
+ |
info.dipole = dipole; |
199 |
+ |
info.last = 0; |
200 |
+ |
} |
201 |
+ |
|
202 |
+ |
|
203 |
+ |
#endif |
204 |
+ |
|
205 |
|
char name[15]; |
206 |
|
int isDipole; |
207 |
|
double mass; |
460 |
|
return NULL; |
461 |
|
} |
462 |
|
|
463 |
+ |
#ifdef IS_MPI |
464 |
+ |
void add( bondStruct &info ){ |
465 |
+ |
if( next != NULL ) next->add(info); |
466 |
+ |
else{ |
467 |
+ |
next = new LinkedType(); |
468 |
+ |
strcpy(next->nameA, info.nameA); |
469 |
+ |
strcpy(next->nameB, info.nameB); |
470 |
+ |
strcpy(next->type, info.type); |
471 |
+ |
next->d0 = info.d0; |
472 |
+ |
} |
473 |
+ |
} |
474 |
+ |
|
475 |
+ |
void duplicate( bondStruct &info ){ |
476 |
+ |
strcpy(info.nameA, nameA); |
477 |
+ |
strcpy(info.nameB, nameB); |
478 |
+ |
strcpy(info.type, type); |
479 |
+ |
info.d0 = d0; |
480 |
+ |
info.last = 0; |
481 |
+ |
} |
482 |
+ |
|
483 |
+ |
|
484 |
+ |
#endif |
485 |
+ |
|
486 |
|
char nameA[15]; |
487 |
|
char nameB[15]; |
488 |
|
char type[30]; |
673 |
|
return NULL; |
674 |
|
} |
675 |
|
|
676 |
+ |
#ifdef IS_MPI |
677 |
+ |
|
678 |
+ |
void add( bendStruct &info ){ |
679 |
+ |
if( next != NULL ) next->add(info); |
680 |
+ |
else{ |
681 |
+ |
next = new LinkedType(); |
682 |
+ |
strcpy(next->nameA, info.nameA); |
683 |
+ |
strcpy(next->nameB, info.nameB); |
684 |
+ |
strcpy(next->nameC, info.nameC); |
685 |
+ |
strcpy(next->type, info.type); |
686 |
+ |
next->k1 = info.k1; |
687 |
+ |
next->k2 = info.k2; |
688 |
+ |
next->k3 = info.k3; |
689 |
+ |
next->t0 = info.t0; |
690 |
+ |
} |
691 |
+ |
} |
692 |
+ |
|
693 |
+ |
void duplicate( bendStruct &info ){ |
694 |
+ |
strcpy(info.nameA, nameA); |
695 |
+ |
strcpy(info.nameB, nameB); |
696 |
+ |
strcpy(info.nameC, nameC); |
697 |
+ |
strcpy(info.type, type); |
698 |
+ |
info.k1 = k1; |
699 |
+ |
info.k2 = k2; |
700 |
+ |
info.k3 = k3; |
701 |
+ |
info.t0 = t0; |
702 |
+ |
info.last = 0; |
703 |
+ |
} |
704 |
+ |
|
705 |
+ |
#endif |
706 |
+ |
|
707 |
|
char nameA[15]; |
708 |
|
char nameB[15]; |
709 |
|
char nameC[15]; |
932 |
|
return NULL; |
933 |
|
} |
934 |
|
|
935 |
+ |
#ifdef IS_MPI |
936 |
+ |
|
937 |
+ |
void add( torsionStruct &info ){ |
938 |
+ |
if( next != NULL ) next->add(info); |
939 |
+ |
else{ |
940 |
+ |
next = new LinkedType(); |
941 |
+ |
strcpy(next->nameA, info.nameA); |
942 |
+ |
strcpy(next->nameB, info.nameB); |
943 |
+ |
strcpy(next->nameC, info.nameC); |
944 |
+ |
strcpy(next->type, info.type); |
945 |
+ |
next->k1 = info.k1; |
946 |
+ |
next->k2 = info.k2; |
947 |
+ |
next->k3 = info.k3; |
948 |
+ |
next->k4 = info.k4; |
949 |
+ |
} |
950 |
+ |
} |
951 |
+ |
|
952 |
+ |
void duplicate( torsionStruct &info ){ |
953 |
+ |
strcpy(info.nameA, nameA); |
954 |
+ |
strcpy(info.nameB, nameB); |
955 |
+ |
strcpy(info.nameC, nameC); |
956 |
+ |
strcpy(info.nameD, nameD); |
957 |
+ |
strcpy(info.type, type); |
958 |
+ |
info.k1 = k1; |
959 |
+ |
info.k2 = k2; |
960 |
+ |
info.k3 = k3; |
961 |
+ |
info.k4 = k4; |
962 |
+ |
info.last = 0; |
963 |
+ |
} |
964 |
+ |
|
965 |
+ |
#endif |
966 |
+ |
|
967 |
|
char nameA[15]; |
968 |
|
char nameB[15]; |
969 |
|
char nameC[15]; |