apply safe file pointer
This commit is contained in:
@ -26,6 +26,7 @@
|
||||
#include "force.h"
|
||||
#include "input.h"
|
||||
#include "math_const.h"
|
||||
#include "safe_pointers.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cmath>
|
||||
@ -79,13 +80,13 @@ void AngleWrite::command(int narg, char **arg)
|
||||
// otherwise make certain that units are consistent
|
||||
// print header in format used by angle_style table
|
||||
|
||||
FILE *fp = nullptr;
|
||||
SafeFilePtr fp;
|
||||
std::string coeffs_file = table_file + ".tmp.coeffs";
|
||||
if (comm->me == 0) {
|
||||
|
||||
fp = fopen(coeffs_file.c_str(), "w");
|
||||
force->angle->write_data(fp);
|
||||
fclose(fp);
|
||||
FILE *coeffs = fopen(coeffs_file.c_str(), "w");
|
||||
force->angle->write_data(coeffs);
|
||||
fclose(coeffs);
|
||||
|
||||
// units sanity check:
|
||||
// - if this is the first time we write to this potential file,
|
||||
@ -221,7 +222,6 @@ void AngleWrite::command(int narg, char **arg)
|
||||
|
||||
// clean up
|
||||
delete writer;
|
||||
fclose(fp);
|
||||
}
|
||||
MPI_Comm_free(&singlecomm);
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include "force.h"
|
||||
#include "memory.h"
|
||||
#include "neighbor.h"
|
||||
#include "safe_pointers.h"
|
||||
#include "suffix.h"
|
||||
#include "update.h"
|
||||
|
||||
@ -365,7 +366,7 @@ void Bond::write_file(int narg, char **arg)
|
||||
// add line with DATE: and UNITS: tag when creating new file
|
||||
// print header in format used by bond_style table
|
||||
|
||||
FILE *fp = nullptr;
|
||||
SafeFilePtr fp;
|
||||
if (comm->me == 0) {
|
||||
std::string table_file = arg[4];
|
||||
|
||||
@ -419,7 +420,6 @@ void Bond::write_file(int narg, char **arg)
|
||||
e = single(btype, r * r, itype, jtype, f);
|
||||
fprintf(fp, "%8d %- 22.15g %- 22.15g %- 22.15g\n", i + 1, r, e, f * r);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user