Skip to content

Commit

Permalink
make amr-wind output files consistent when not using std filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
asharma committed Sep 17, 2023
1 parent a2d3ed6 commit dda66a5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/exawind/exawind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ static std::string usage(std::string name)
"ranks)\n";
}

std::string
replace_extension(const std::string& filepath, const std::string& newExt)
{
size_t lastDotPos = filepath.find_last_of(".");

if (lastDotPos != std::string::npos && lastDotPos != 0) {
return filepath.substr(0, lastDotPos) + newExt;
} else {
return filepath + newExt;
}
}

int main(int argc, char** argv)
{
MPI_Init(&argc, &argv);
Expand Down Expand Up @@ -85,7 +97,7 @@ int main(int argc, char** argv)
const std::string amr_log =
fpath_amr_inp.replace_extension(".log").string();
#else
const std::string amr_log = "amr-wind.log";
const std::string amr_log = replace_extension(amr_inp, ".log");
#endif
std::ofstream out;

Expand Down

0 comments on commit dda66a5

Please sign in to comment.