Skip to content

Commit

Permalink
Make copy and run commands more robust for parallel launches
Browse files Browse the repository at this point in the history
  • Loading branch information
permcody authored and grmnptr committed Mar 28, 2022
1 parent 1968a2e commit 18b992c
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions framework/src/base/MooseApp.C
Expand Up @@ -1450,8 +1450,14 @@ MooseApp::copyInputs()
"\".");

std::string cmd = "cp -R " + src_dir + " " + dst_dir;
int ret = system(cmd.c_str());
if (WIFEXITED(ret) && WEXITSTATUS(ret) != 0)

// Only perform the copy on the root processor
int return_value = 0;
if (processor_id() == 0)
return_value = system(cmd.c_str());
_communicator.broadcast(return_value);

if (WIFEXITED(return_value) && WEXITSTATUS(return_value) != 0)
mooseError("Failed to copy the requested directory.");
Moose::out << "Directory successfully copied into ./" << dst_dir << '\n';
return true;
Expand Down Expand Up @@ -1510,9 +1516,15 @@ MooseApp::runInputs()
if (ret != 0)
mooseError("Failed to change directory into ", working_dir);
}

// Only launch the tests on the root processor
Moose::out << "Working Directory: " << working_dir << "\nRunning Command: " << cmd << std::endl;
int ret = system(cmd.c_str());
if (WIFEXITED(ret) && WEXITSTATUS(ret) != 0)
int return_value = 0;
if (processor_id() == 0)
return_value = system(cmd.c_str());
_communicator.broadcast(return_value);

if (WIFEXITED(return_value) && WEXITSTATUS(return_value) != 0)
mooseError("Run failed");
return true;
}
Expand Down

0 comments on commit 18b992c

Please sign in to comment.