Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only permit rank0 to mkdir when -d flag specified #955

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- [[PR 885]](https://github.com/parthenon-hpc-lab/parthenon/pull/885) Expose PackDescriptor and use uids in SparsePacks

### Fixed (not changing behavior/API/variables/...)
- [[PR 955]](https://github.com/parthenon-hpc-lab/parthenon/pull/955) Only permit rank0 to mkdir when -d flag specified
- [[PR 952]](https://github.com/parthenon-hpc-lab/parthenon/pull/954) Fix format string in sparse advection example
- [[PR 947]](https://github.com/parthenon-hpc-lab/parthenon/pull/947) Add missing ForceRemeshComm dependencies
- [[PR 928]](https://github.com/parthenon-hpc-lab/parthenon/pull/928) Fix boundary comms during refinement next to refined blocks
Expand Down
30 changes: 19 additions & 11 deletions src/utils/change_rundir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright(C) 2014 James M. Stone <[email protected]> and other code contributors
// Licensed under the 3-clause BSD License, see LICENSE file for details
//========================================================================================
// (C) (or copyright) 2020. Triad National Security, LLC. All rights reserved.
// (C) (or copyright) 2023. Triad National Security, LLC. All rights reserved.
//
// This program was produced under U.S. Government contract 89233218CNA000001 for Los
// Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC
Expand All @@ -27,6 +27,8 @@
#include <stdexcept>

#include "defs.hpp"
#include "globals.hpp"
#include "parthenon_mpi.hpp"
#include "utils/error_checking.hpp"

namespace fs = FS_NAMESPACE;
Expand All @@ -42,19 +44,25 @@ void ChangeRunDir(const char *pdir) {

if (pdir == nullptr || *pdir == '\0') return;

if (!fs::exists(pdir)) {
if (!fs::create_directories(pdir)) {
msg << "### FATAL ERROR in function [ChangeToRunDir]" << std::endl
<< "Cannot create directory '" << pdir << "'";
PARTHENON_THROW(msg);
}
if (parthenon::Globals::my_rank == 0) {
if (!fs::exists(pdir)) {
if (!fs::create_directories(pdir)) {
msg << "### FATAL ERROR in function [ChangeToRunDir]" << std::endl
<< "Cannot create directory '" << pdir << "'";
PARTHENON_THROW(msg);
}

// in POSIX, this is 0755 permission, rwxr-xr-x
auto perms = fs::perms::owner_all | fs::perms::group_read | fs::perms::group_exec |
fs::perms::others_read | fs::perms::others_exec;
fs::permissions(pdir, perms);
// in POSIX, this is 0755 permission, rwxr-xr-x
auto perms = fs::perms::owner_all | fs::perms::group_read | fs::perms::group_exec |
fs::perms::others_read | fs::perms::others_exec;
fs::permissions(pdir, perms);
}
}

#ifdef MPI_PARALLEL
MPI_Barrier(MPI_COMM_WORLD);
#endif

if (chdir(pdir)) {
msg << "### FATAL ERROR in function [ChangeToRunDir]" << std::endl
<< "Cannot cd to directory '" << pdir << "'";
Expand Down
Loading