Replace localtime() with thread-safe fmt::localtime()
This commit is contained in:
10
src/bond.cpp
10
src/bond.cpp
@ -22,6 +22,7 @@
|
||||
#include "neighbor.h"
|
||||
#include "suffix.h"
|
||||
#include "update.h"
|
||||
#include "fmt/chrono.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
@ -283,14 +284,13 @@ void Bond::write_file(int narg, char **arg)
|
||||
"DATE: {}\n", table_file, date);
|
||||
fp = fopen(table_file.c_str(),"a");
|
||||
} else {
|
||||
char datebuf[16];
|
||||
time_t tv = time(nullptr);
|
||||
strftime(datebuf,15,"%Y-%m-%d",localtime(&tv));
|
||||
std::tm current_date = fmt::localtime(tv);
|
||||
utils::logmesg(lmp,"Creating table file {} with "
|
||||
"DATE: {}\n", table_file, datebuf);
|
||||
"DATE: {:%Y-%m-%d}\n", table_file, current_date);
|
||||
fp = fopen(table_file.c_str(),"w");
|
||||
if (fp) fmt::print(fp,"# DATE: {} UNITS: {} Created by bond_write\n",
|
||||
datebuf, update->unit_style);
|
||||
if (fp) fmt::print(fp,"# DATE: {:%Y-%m-%d} UNITS: {} Created by bond_write\n",
|
||||
current_date, update->unit_style);
|
||||
}
|
||||
if (fp == nullptr)
|
||||
error->one(FLERR,"Cannot open bond_write file {}: {}",
|
||||
|
||||
Reference in New Issue
Block a user