diff --git a/CHANGELOG.md b/CHANGELOG.md index aaa484b3fc7a..81b98d2ebc09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,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 diff --git a/src/utils/change_rundir.cpp b/src/utils/change_rundir.cpp index 761873d058c6..4c616d61f68c 100644 --- a/src/utils/change_rundir.cpp +++ b/src/utils/change_rundir.cpp @@ -3,7 +3,7 @@ // Copyright(C) 2014 James M. Stone 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 @@ -27,6 +27,8 @@ #include #include "defs.hpp" +#include "globals.hpp" +#include "parthenon_mpi.hpp" #include "utils/error_checking.hpp" namespace fs = FS_NAMESPACE; @@ -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 << "'";