git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12616 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -38,6 +38,8 @@
|
|||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
#define MAXLINE 1024
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
Force::Force(LAMMPS *lmp) : Pointers(lmp)
|
Force::Force(LAMMPS *lmp) : Pointers(lmp)
|
||||||
@ -888,8 +890,8 @@ tagint Force::tnumeric(const char *file, int line, char *str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
open a potential file as specified by name; failing that,
|
open a potential file as specified by name
|
||||||
search in dir specified by env variable LAMMPS_POTENTIALS
|
if fails, search in dir specified by env variable LAMMPS_POTENTIALS
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
FILE *Force::open_potential(const char *name)
|
FILE *Force::open_potential(const char *name)
|
||||||
@ -902,14 +904,19 @@ FILE *Force::open_potential(const char *name)
|
|||||||
// if successful, return ptr
|
// if successful, return ptr
|
||||||
|
|
||||||
fp = fopen(name,"r");
|
fp = fopen(name,"r");
|
||||||
if (fp) return fp;
|
if (fp) {
|
||||||
|
potential_date(fp,name);
|
||||||
|
fclose(fp);
|
||||||
|
fp = fopen(name,"r");
|
||||||
|
return fp;
|
||||||
|
}
|
||||||
|
|
||||||
// try the environment variable directory
|
// try the environment variable directory
|
||||||
|
|
||||||
const char *path = getenv("LAMMPS_POTENTIALS");
|
const char *path = getenv("LAMMPS_POTENTIALS");
|
||||||
if (path == NULL) return NULL;
|
if (path == NULL) return NULL;
|
||||||
|
|
||||||
const char *pot = potname(name);
|
const char *pot = potential_name(name);
|
||||||
if (pot == NULL) return NULL;
|
if (pot == NULL) return NULL;
|
||||||
|
|
||||||
size_t len1 = strlen(path);
|
size_t len1 = strlen(path);
|
||||||
@ -927,7 +934,11 @@ FILE *Force::open_potential(const char *name)
|
|||||||
strcat(newpath,pot);
|
strcat(newpath,pot);
|
||||||
|
|
||||||
fp = fopen(newpath,"r");
|
fp = fopen(newpath,"r");
|
||||||
delete[] newpath;
|
potential_date(fp,name);
|
||||||
|
fclose(fp);
|
||||||
|
fp = fopen(newpath,"r");
|
||||||
|
|
||||||
|
delete [] newpath;
|
||||||
return fp;
|
return fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -935,7 +946,7 @@ FILE *Force::open_potential(const char *name)
|
|||||||
strip off leading part of path, return just the filename
|
strip off leading part of path, return just the filename
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
const char *Force::potname(const char *path)
|
const char *Force::potential_name(const char *path)
|
||||||
{
|
{
|
||||||
const char *pot;
|
const char *pot;
|
||||||
|
|
||||||
@ -958,6 +969,33 @@ const char *Force::potname(const char *path)
|
|||||||
return pot;
|
return pot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
read first line of potential file
|
||||||
|
if has DATE field, print following word
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void Force::potential_date(FILE *fp, const char *name)
|
||||||
|
{
|
||||||
|
char line[MAXLINE];
|
||||||
|
char *ptr = fgets(line,MAXLINE,fp);
|
||||||
|
if (ptr == NULL) return;
|
||||||
|
|
||||||
|
char *word;
|
||||||
|
word = strtok(line," \t\n\r\f");
|
||||||
|
while (word) {
|
||||||
|
if (strcmp(word,"DATE:") == 0) {
|
||||||
|
word = strtok(NULL," \t\n\r\f");
|
||||||
|
if (word == NULL) return;
|
||||||
|
if (screen)
|
||||||
|
fprintf(screen,"Reading potential file %s with DATE: %s\n",name,word);
|
||||||
|
if (logfile)
|
||||||
|
fprintf(logfile,"Reading potential file %s with DATE: %s\n",name,word);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
word = strtok(NULL," \t\n\r\f");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
memory usage of force classes
|
memory usage of force classes
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
#define LMP_FORCE_H
|
#define LMP_FORCE_H
|
||||||
|
|
||||||
#include "pointers.h"
|
#include "pointers.h"
|
||||||
|
#include "stdio.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -109,7 +110,8 @@ class Force : protected Pointers {
|
|||||||
tagint tnumeric(const char *, int, char *);
|
tagint tnumeric(const char *, int, char *);
|
||||||
|
|
||||||
FILE *open_potential(const char *);
|
FILE *open_potential(const char *);
|
||||||
const char *potname(const char *);
|
const char *potential_name(const char *);
|
||||||
|
void potential_date(FILE *, const char *);
|
||||||
|
|
||||||
bigint memory_usage();
|
bigint memory_usage();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user