more local buffers removed and file error status added.

This commit is contained in:
Axel Kohlmeyer
2020-06-04 19:46:35 -04:00
parent 62ee8d41f3
commit 54a8b4e08b
15 changed files with 152 additions and 146 deletions

View File

@ -18,6 +18,7 @@
#include "read_data.h"
#include <mpi.h>
#include <cstring>
#include <string>
#include <cctype>
#include "atom.h"
#include "atom_vec.h"
@ -42,6 +43,7 @@
#include "error.h"
#include "memory.h"
#include "utils.h"
#include "fmt/format.h"
using namespace LAMMPS_NS;
@ -709,11 +711,8 @@ void ReadData::command(int narg, char **arg)
if (firstpass) impropercoeffs(1);
else skip_lines(nimpropertypes);
} else {
char str[128];
snprintf(str,128,"Unknown identifier in data file: %s",keyword);
error->all(FLERR,str);
}
} else error->all(FLERR,fmt::format("Unknown identifier in data file: {}",
keyword));
parse_keyword(0);
}
@ -2013,25 +2012,21 @@ void ReadData::open(char *file)
if (!compressed) fp = fopen(file,"r");
else {
#ifdef LAMMPS_GZIP
char gunzip[128];
snprintf(gunzip,128,"gzip -c -d %s",file);
std::string gunzip = fmt::format("gzip -c -d {}",file);
#ifdef _WIN32
fp = _popen(gunzip,"rb");
fp = _popen(gunzip.c_str(),"rb");
#else
fp = popen(gunzip,"r");
fp = popen(gunzip.c_str(),"r");
#endif
#else
error->one(FLERR,"Cannot open gzipped file");
error->one(FLERR,"Cannot open gzipped file: " + utils::getsyserror());
#endif
}
if (fp == NULL) {
char str[128];
snprintf(str,128,"Cannot open file %s",file);
error->one(FLERR,str);
}
if (fp == NULL)
error->one(FLERR,fmt::format("Cannot open file {}: {}",
file, utils::getsyserror()));
}
/* ----------------------------------------------------------------------