33 |
|
#endif |
34 |
|
|
35 |
|
|
36 |
+ |
// declaration of functions needed to wrap the fortran module |
37 |
+ |
|
38 |
+ |
extern "C" { |
39 |
+ |
void forcefactory_( char* forceName, |
40 |
+ |
int* status, |
41 |
+ |
void (*wrapFunction)( void (*p1)( int* ident, |
42 |
+ |
double* mass, |
43 |
+ |
double* epslon, |
44 |
+ |
double* sigma, |
45 |
+ |
int* status ), |
46 |
+ |
void (*p2)( void ), |
47 |
+ |
void (*p3)( double* positionArray, |
48 |
+ |
double* forceArray, |
49 |
+ |
double* potentialEnergy, |
50 |
+ |
short int* doPotentialCalc )), |
51 |
+ |
int forceNameLength ); |
52 |
+ |
} |
53 |
+ |
|
54 |
+ |
|
55 |
+ |
void LJfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon, |
56 |
+ |
double* sigma, int* status ), |
57 |
+ |
void (*p2)( void ), |
58 |
+ |
void (*p3)( double* positionArray,double* forceArray, |
59 |
+ |
double* potentialEnergy, |
60 |
+ |
short int* doPotentialCalc ) ); |
61 |
+ |
|
62 |
+ |
void (*newLJtype)( int* ident, double* mass, double* epslon, double* sigma, |
63 |
+ |
int* status ); |
64 |
+ |
|
65 |
+ |
void (*initLJfortran)( void ); |
66 |
+ |
|
67 |
+ |
LJ_FF* currentLJwrap; |
68 |
+ |
|
69 |
+ |
|
70 |
+ |
//**************************************************************** |
71 |
+ |
// begins the actual forcefield stuff. |
72 |
+ |
//**************************************************************** |
73 |
+ |
|
74 |
|
LJ_FF::LJ_FF(){ |
75 |
|
|
76 |
|
char fileName[200]; |
79 |
|
char temp[200]; |
80 |
|
char errMsg[1000]; |
81 |
|
|
82 |
+ |
// do the funtion wrapping |
83 |
+ |
currentLJwrap = this; |
84 |
+ |
wrapMe(); |
85 |
+ |
|
86 |
|
#ifdef IS_MPI |
87 |
|
int i; |
88 |
|
|
179 |
|
#endif // is_mpi |
180 |
|
} |
181 |
|
|
182 |
+ |
|
183 |
+ |
void LJ_FF::wrapMe( void ){ |
184 |
+ |
|
185 |
+ |
char* currentFF = "LJ"; |
186 |
+ |
int isError = 0; |
187 |
+ |
|
188 |
+ |
forcefactory_( currentFF, &isError, LJfunctionWrapper, strlen(currentFF) ); |
189 |
+ |
|
190 |
+ |
if( isError ){ |
191 |
+ |
|
192 |
+ |
sprintf( painCave.errMsg, |
193 |
+ |
"LJ_FF error: an error was returned from fortran when the " |
194 |
+ |
"the functions were being wrapped.\n" ); |
195 |
+ |
painCave.isFatal = 1; |
196 |
+ |
simError(); |
197 |
+ |
} |
198 |
+ |
|
199 |
+ |
#ifdef IS_MPI |
200 |
+ |
sprintf( checkPointMsg, "LJ_FF functions succesfully wrapped." ); |
201 |
+ |
MPIcheckPoint(); |
202 |
+ |
#endif // is_mpi |
203 |
+ |
} |
204 |
+ |
|
205 |
+ |
|
206 |
+ |
void LJfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon, |
207 |
+ |
double* sigma, int* status ), |
208 |
+ |
void (*p2)( void ), |
209 |
+ |
void (*p3)( double* positionArray,double* forceArray, |
210 |
+ |
double* potentialEnergy, |
211 |
+ |
short int* doPotentialCalc ) ){ |
212 |
+ |
|
213 |
+ |
|
214 |
+ |
p1 = newLJtype; |
215 |
+ |
p2 = initLJfortran; |
216 |
+ |
this->setLJfortran( p3 ); |
217 |
+ |
} |
218 |
+ |
|
219 |
+ |
|
220 |
+ |
|
221 |
|
void LJ_FF::initializeAtoms( void ){ |
222 |
|
|
223 |
|
class LinkedType { |
376 |
|
} |
377 |
|
#endif // is_mpi |
378 |
|
|
379 |
< |
|
379 |
> |
// call new A_types in fortran |
380 |
> |
|
381 |
> |
|
382 |
|
// initialize the atoms |
383 |
|
|
384 |
|
Atom* thisAtom; |