From 217fdbc36076e051829a8a3cffa580f32e1955e3 Mon Sep 17 00:00:00 2001
From: athomps <athomps@f3b2605a-c512-4ea7-a41b-209d697bcdaa>
Date: Mon, 6 Jul 2015 17:08:35 +0000
Subject: [PATCH] Added DATE reporting for parameter file

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13534 f3b2605a-c512-4ea7-a41b-209d697bcdaa
---
 src/USER-REAXC/pair_reax_c.cpp    | 11 ++++-
 src/USER-REAXC/reaxc_ffield.cpp   | 10 +----
 src/USER-REAXC/reaxc_ffield.h     |  2 +-
 src/USER-REAXC/reaxc_tool_box.cpp | 72 -------------------------------
 src/USER-REAXC/reaxc_tool_box.h   |  1 -
 5 files changed, 12 insertions(+), 84 deletions(-)

diff --git a/src/USER-REAXC/pair_reax_c.cpp b/src/USER-REAXC/pair_reax_c.cpp
index 277d31ccf1..5f49d3b02b 100644
--- a/src/USER-REAXC/pair_reax_c.cpp
+++ b/src/USER-REAXC/pair_reax_c.cpp
@@ -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
diff --git a/src/USER-REAXC/reaxc_ffield.cpp b/src/USER-REAXC/reaxc_ffield.cpp
index 197a2252a1..0292e76320 100644
--- a/src/USER-REAXC/reaxc_ffield.cpp
+++ b/src/USER-REAXC/reaxc_ffield.cpp
@@ -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 );
 
diff --git a/src/USER-REAXC/reaxc_ffield.h b/src/USER-REAXC/reaxc_ffield.h
index 6ccc94d7d0..7cef730f91 100644
--- a/src/USER-REAXC/reaxc_ffield.h
+++ b/src/USER-REAXC/reaxc_ffield.h
@@ -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
diff --git a/src/USER-REAXC/reaxc_tool_box.cpp b/src/USER-REAXC/reaxc_tool_box.cpp
index 92043174e9..84a654fecf 100644
--- a/src/USER-REAXC/reaxc_tool_box.cpp
+++ b/src/USER-REAXC/reaxc_tool_box.cpp
@@ -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;
-}
-
-
diff --git a/src/USER-REAXC/reaxc_tool_box.h b/src/USER-REAXC/reaxc_tool_box.h
index 1c65d362d1..e45b07d000 100644
--- a/src/USER-REAXC/reaxc_tool_box.h
+++ b/src/USER-REAXC/reaxc_tool_box.h
@@ -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
-- 
GitLab