Added DATE reporting for parameter file
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13534 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -279,7 +279,16 @@ void PairReaxC::coeff( int nargs, char **args )
|
||||
|
||||
// read ffield file
|
||||
|
||||
Read_Force_Field(args[2], &(system->reax_param), control);
|
||||
char *file = args[2];
|
||||
FILE *fp;
|
||||
fp = force->open_potential(file);
|
||||
if (fp != NULL)
|
||||
Read_Force_Field(fp, &(system->reax_param), control);
|
||||
else if (comm->me == 0) {
|
||||
char str[128];
|
||||
sprintf(str,"Cannot open ReaxFF potential file %s",file);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
|
||||
// read args that map atom types to elements in potential file
|
||||
// map[i] = which element the Ith atom type is, -1 if NULL
|
||||
|
||||
@ -29,10 +29,9 @@
|
||||
#include "reaxc_ffield.h"
|
||||
#include "reaxc_tool_box.h"
|
||||
|
||||
char Read_Force_Field( char *ffield_file, reax_interaction *reax,
|
||||
char Read_Force_Field( FILE *fp, reax_interaction *reax,
|
||||
control_params *control )
|
||||
{
|
||||
FILE *fp;
|
||||
char *s;
|
||||
char **tmp;
|
||||
char ****tor_flag;
|
||||
@ -44,18 +43,11 @@ char Read_Force_Field( char *ffield_file, reax_interaction *reax,
|
||||
|
||||
comm = MPI_COMM_WORLD;
|
||||
|
||||
/* open force field file */
|
||||
if ( (fp = lmp_open_potential( ffield_file ) ) == NULL ) {
|
||||
fprintf( stderr, "error opening the force field file! terminating...\n" );
|
||||
MPI_Abort( comm, FILE_NOT_FOUND );
|
||||
}
|
||||
|
||||
s = (char*) malloc(sizeof(char)*MAX_LINE);
|
||||
tmp = (char**) malloc(sizeof(char*)*MAX_TOKENS);
|
||||
for (i=0; i < MAX_TOKENS; i++)
|
||||
tmp[i] = (char*) malloc(sizeof(char)*MAX_TOKEN_LEN);
|
||||
|
||||
|
||||
/* reading first header comment */
|
||||
fgets( s, MAX_LINE, fp );
|
||||
|
||||
|
||||
@ -29,6 +29,6 @@
|
||||
|
||||
#include "reaxc_types.h"
|
||||
|
||||
char Read_Force_Field( char*, reax_interaction*, control_params* );
|
||||
char Read_Force_Field( FILE*, reax_interaction*, control_params* );
|
||||
|
||||
#endif
|
||||
|
||||
@ -239,75 +239,3 @@ void sfree( void *ptr, const char *name )
|
||||
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,4 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user