11 #include <athena/globals.hpp>
12 #include <athena/outputs/user_outputs.hpp>
15 #include <configure.hpp>
19 void NetcdfOutput::CombineBlocks() {
23 std::stringstream msg;
25 MPI_Barrier(MPI_COMM_WORLD);
27 if (Globals::my_rank == 0) {
29 snprintf(number,
sizeof(number),
"%05d", output_params.file_number - 1);
32 infile.assign(output_params.file_basename);
33 infile.append(
".block*.");
34 infile.append(output_params.file_id);
36 infile.append(number);
40 int err = glob(infile.c_str(), GLOB_TILDE, NULL, &glob_result);
42 globfree(&glob_result);
43 msg <<
"### FATAL ERROR in function [NetcdfOutput::CombineBlocks]"
45 <<
"glob() failed with error " << err << std::endl;
46 throw std::runtime_error(msg.str().c_str());
50 outfile.assign(output_params.file_basename);
52 outfile.append(output_params.file_id);
54 outfile.append(number);
55 outfile.append(
".nc");
57 int argc = 3 + glob_result.gl_pathc;
60 char **argv =
new char *[argc];
61 for (
int i = 0; i < argc; ++i) argv[i] =
new char[2048];
62 snprintf(argv[0], 2048,
"%s",
"CombineBlocks");
63 snprintf(argv[1], 2048,
"%s",
"-r");
64 snprintf(argv[2], 2048,
"%s", outfile.c_str());
65 for (
int i = 3; i < argc; ++i)
66 snprintf(argv[i], 2048,
"%s", glob_result.gl_pathv[i - 3]);
68 remove(outfile.c_str());
71 std::cerr <<
"### WARNING in function [NetcdfOutput::CombineBlocks]"
73 <<
"mppnccombine returns none zero.";
77 globfree(&glob_result);
78 for (
int i = 0; i < argc; ++i)
delete[] argv[i];
int mppnccombine(int argc, char *argv[])