forked from lijiext/lammps
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12630 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
parent
af3992fb05
commit
13ebe937e2
|
@ -45,7 +45,7 @@ char Read_Force_Field( char *ffield_file, reax_interaction *reax,
|
|||
comm = MPI_COMM_WORLD;
|
||||
|
||||
/* open force field file */
|
||||
if ( (fp = fopen( ffield_file, "r" ) ) == NULL ) {
|
||||
if ( (fp = lmp_open_potential( ffield_file ) ) == NULL ) {
|
||||
fprintf( stderr, "error opening the force field file! terminating...\n" );
|
||||
MPI_Abort( comm, FILE_NOT_FOUND );
|
||||
}
|
||||
|
|
|
@ -238,3 +238,76 @@ void sfree( void *ptr, const char *name )
|
|||
free( ptr );
|
||||
ptr = NULL;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
strip off leading part of path, return just the filename
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
static const char *potname(const char *path)
|
||||
{
|
||||
const char *pot;
|
||||
|
||||
if (path == NULL) return NULL;
|
||||
|
||||
#if defined(_WIN32)
|
||||
// skip over the disk drive part of windows pathnames
|
||||
if (isalpha(path[0]) && path[1] == ':')
|
||||
path += 2;
|
||||
#endif
|
||||
|
||||
for (pot = path; *path != '\0'; ++path) {
|
||||
#if defined(_WIN32)
|
||||
if ((*path == '\\') || (*path == '/')) pot = path + 1;
|
||||
#else
|
||||
if (*path == '/') pot = path + 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
return pot;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
open a potential file as specified by name; failing that,
|
||||
search in dir specified by env variable LAMMPS_POTENTIALS
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
FILE *lmp_open_potential(const char *name)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if (name == NULL) return NULL;
|
||||
|
||||
// attempt to open file directly
|
||||
// if successful, return ptr
|
||||
|
||||
fp = fopen(name,"r");
|
||||
if (fp) return fp;
|
||||
|
||||
// try the environment variable directory
|
||||
|
||||
const char *path = getenv("LAMMPS_POTENTIALS");
|
||||
if (path == NULL) return NULL;
|
||||
|
||||
const char *pot = potname(name);
|
||||
if (pot == NULL) return NULL;
|
||||
|
||||
size_t len1 = strlen(path);
|
||||
size_t len2 = strlen(pot);
|
||||
char *newpath = new char[len1+len2+2];
|
||||
|
||||
strcpy(newpath,path);
|
||||
#if defined(_WIN32)
|
||||
newpath[len1] = '\\';
|
||||
newpath[len1+1] = 0;
|
||||
#else
|
||||
newpath[len1] = '/';
|
||||
newpath[len1+1] = 0;
|
||||
#endif
|
||||
strcat(newpath,pot);
|
||||
|
||||
fp = fopen(newpath,"r");
|
||||
delete[] newpath;
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -64,5 +64,5 @@ int Tokenize( char*, char*** );
|
|||
void *smalloc( long, const char*, MPI_Comm );
|
||||
void *scalloc( int, int, const char*, MPI_Comm );
|
||||
void sfree( void*, const char* );
|
||||
|
||||
FILE *lmp_open_potential(const char *);
|
||||
#endif
|
||||
|
|
|
@ -836,12 +836,13 @@ void FixNH::final_integrate()
|
|||
nve_v();
|
||||
|
||||
// re-compute temp before nh_v_press()
|
||||
// only needed for temperature computes with BIAS:
|
||||
// only needed for temperature computes with BIAS on reneighboring steps:
|
||||
// b/c some biases store per-atom values (e.g. temp/profile)
|
||||
// per-atom values are invalid if reneigh/comm occurred
|
||||
// since temp->compute() in initial_integrate()
|
||||
|
||||
if (which == BIAS) t_current = temperature->compute_scalar();
|
||||
if (which == BIAS && neighbor->ago == 0)
|
||||
t_current = temperature->compute_scalar();
|
||||
|
||||
if (pstat_flag) nh_v_press();
|
||||
|
||||
|
|
Loading…
Reference in New Issue