Fix BSSN-EM runtime crash
This commit is contained in:
@@ -76,8 +76,11 @@ checkpoint::checkpoint(bool checked, const char fname[], int myrank) : filename(
|
||||
|
||||
I_Print = (myrank == 0);
|
||||
|
||||
int i = strlen(fname);
|
||||
filename = new char[i+30];
|
||||
size_t filename_len = out_dir.size() + strlen(fname) + 32;
|
||||
#ifdef CHECKDETAIL
|
||||
filename_len += 32;
|
||||
#endif
|
||||
filename = new char[filename_len];
|
||||
// cout << filename << endl;
|
||||
// cout << i << endl;
|
||||
|
||||
@@ -100,12 +103,12 @@ checkpoint::checkpoint(bool checked, const char fname[], int myrank) : filename(
|
||||
cout << " checkpoint class created " << endl;
|
||||
}
|
||||
}
|
||||
checkpoint::~checkpoint()
|
||||
{
|
||||
CheckList->clearList();
|
||||
if (I_Print)
|
||||
delete[] filename;
|
||||
}
|
||||
checkpoint::~checkpoint()
|
||||
{
|
||||
CheckList->clearList();
|
||||
if (filename)
|
||||
delete[] filename;
|
||||
}
|
||||
|
||||
void checkpoint::addvariable(var *VV)
|
||||
{
|
||||
@@ -136,7 +139,7 @@ void checkpoint::writecheck_cgh(double time, cgh *GH)
|
||||
if (I_Print)
|
||||
{
|
||||
// char fname[50];
|
||||
char fname[50+50];
|
||||
char fname[4096];
|
||||
sprintf(fname, "%s_cgh.CHK", filename);
|
||||
|
||||
outfile.open(fname, ios::out | ios::trunc);
|
||||
@@ -195,7 +198,7 @@ void checkpoint::readcheck_cgh(double &time, cgh *GH, int myrank, int nprocs, in
|
||||
int DIM = dim;
|
||||
ifstream infile;
|
||||
// char fname[50];
|
||||
char fname[50+50];
|
||||
char fname[4096];
|
||||
sprintf(fname, "%s_cgh.CHK", filename);
|
||||
|
||||
infile.open(fname);
|
||||
@@ -297,7 +300,7 @@ void checkpoint::writecheck_sh(double time, ShellPatch *SH)
|
||||
|
||||
if (I_Print)
|
||||
{
|
||||
char fname[50];
|
||||
char fname[4096];
|
||||
sprintf(fname, "%s_sh.CHK", filename);
|
||||
|
||||
outfile.open(fname, ios::out | ios::trunc);
|
||||
@@ -335,7 +338,7 @@ void checkpoint::readcheck_sh(ShellPatch *SH, int myrank)
|
||||
int DIM = dim;
|
||||
ifstream infile;
|
||||
// char fname[50];
|
||||
char fname[50+50];
|
||||
char fname[4096];
|
||||
sprintf(fname, "%s_sh.CHK", filename);
|
||||
|
||||
infile.open(fname);
|
||||
@@ -390,7 +393,7 @@ void checkpoint::write_Black_Hole_position(int BH_num_input, int BH_num, double
|
||||
|
||||
if (I_Print)
|
||||
{
|
||||
char fname[50];
|
||||
char fname[4096];
|
||||
sprintf(fname, "%s_BHp.CHK", filename);
|
||||
|
||||
outfile.open(fname, ios::out | ios::trunc);
|
||||
@@ -417,7 +420,7 @@ void checkpoint::read_Black_Hole_position(int &BH_num_input, int &BH_num, double
|
||||
{
|
||||
ifstream infile;
|
||||
// char fname[50];
|
||||
char fname[50+50];
|
||||
char fname[4096];
|
||||
sprintf(fname, "%s_BHp.CHK", filename);
|
||||
|
||||
infile.open(fname);
|
||||
@@ -461,7 +464,7 @@ void checkpoint::write_bssn(double LastDump, double Last2dDump, double LastAnas)
|
||||
|
||||
if (I_Print)
|
||||
{
|
||||
char fname[50];
|
||||
char fname[4096];
|
||||
sprintf(fname, "%s_bssn.CHK", filename);
|
||||
|
||||
outfile.open(fname, ios::out | ios::trunc);
|
||||
@@ -481,7 +484,7 @@ void checkpoint::read_bssn(double &LastDump, double &Last2dDump, double &LastAna
|
||||
{
|
||||
ifstream infile;
|
||||
// char fname[50];
|
||||
char fname[50+50];
|
||||
char fname[4096];
|
||||
sprintf(fname, "%s_bssn.CHK", filename);
|
||||
|
||||
infile.open(fname);
|
||||
@@ -506,7 +509,7 @@ void checkpoint::write_bssn(double LastDump, double Last2dDump, double LastAnas)
|
||||
ofstream outfile;
|
||||
|
||||
// char fname[50];
|
||||
char fname[50+50];
|
||||
char fname[4096];
|
||||
sprintf(fname, "%s_bssn.CHK", filename);
|
||||
|
||||
outfile.open(fname, ios::out | ios::trunc);
|
||||
@@ -527,7 +530,7 @@ void checkpoint::read_bssn(double &LastDump, double &Last2dDump, double &LastAna
|
||||
{
|
||||
ifstream infile;
|
||||
// char fname[50];
|
||||
char fname[50+50];
|
||||
char fname[4096];
|
||||
sprintf(fname, "%s_bssn.CHK", filename);
|
||||
|
||||
infile.open(fname);
|
||||
@@ -551,7 +554,7 @@ void checkpoint::write_Black_Hole_position(int BH_num_input, int BH_num, double
|
||||
ofstream outfile;
|
||||
|
||||
// char fname[50];
|
||||
char fname[50+50];
|
||||
char fname[4096];
|
||||
sprintf(fname, "%s_BHp.CHK", filename);
|
||||
|
||||
outfile.open(fname, ios::out | ios::trunc);
|
||||
@@ -581,7 +584,7 @@ void checkpoint::read_Black_Hole_position(int &BH_num_input, int &BH_num, double
|
||||
{
|
||||
ifstream infile;
|
||||
// char fname[50];
|
||||
char fname[50+50];
|
||||
char fname[4096];
|
||||
sprintf(fname, "%s_BHp.CHK", filename);
|
||||
|
||||
infile.open(fname);
|
||||
@@ -628,7 +631,7 @@ void checkpoint::writecheck_cgh(double time, cgh *GH)
|
||||
ofstream outfile;
|
||||
|
||||
// char fname[50];
|
||||
char fname[50+50];
|
||||
char fname[4096];
|
||||
sprintf(fname, "%s_cgh.CHK", filename);
|
||||
|
||||
outfile.open(fname, ios::out | ios::trunc);
|
||||
@@ -738,7 +741,7 @@ void checkpoint::readcheck_cgh(double &time, cgh *GH, int myrank, int nprocs, in
|
||||
int DIM = dim;
|
||||
ifstream infile;
|
||||
// char fname[50];
|
||||
char fname[50+50];
|
||||
char fname[4096];
|
||||
sprintf(fname, "%s_cgh.CHK", filename);
|
||||
|
||||
infile.open(fname);
|
||||
|
||||
Reference in New Issue
Block a user