AMReX-Astro / AMReX-Astro/Castro
`read_particle_params` unconditionally creates `particles::timestamp_dir` even when timestamping is disabled/empty
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 340
- Forks
- 105
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 8
Description
Summary
Castro::read_particle_params() always calls UtilCreateDirectory(particles::timestamp_dir, 0755) on IO rank, without checking whether timestamp_dir is non-empty or whether tracer timestamping is enabled. If timestamp_dir is empty, this can fail during startup before any particle work is done.
Location
Source/particles/CastroParticles.cpp:29
Problem Details
Current code:
if (ParallelDescriptor::IOProcessor())
if (!amrex::UtilCreateDirectory(particles::timestamp_dir, 0755))
amrex::CreateDirectoryFailed(particles::timestamp_dir);
ParallelDescriptor::Barrier();
But later timestamp writes are guarded with !particles::timestamp_dir.empty(), so directory creation is inconsistent with usage.
Impact
- Possible startup abort when
particles::timestamp_diris empty or unset. - Unnecessary filesystem operations when timestamp output is not requested.
Suggested Patch
diff --git a/Source/particles/CastroParticles.cpp b/Source/particles/CastroParticles.cpp
--- a/Source/particles/CastroParticles.cpp
+++ b/Source/particles/CastroParticles.cpp
@@
- if (ParallelDescriptor::IOProcessor())
- if (!amrex::UtilCreateDirectory(particles::timestamp_dir, 0755))
- amrex::CreateDirectoryFailed(particles::timestamp_dir);
- //
- // Force other processors to wait till directory is built.
- //
- ParallelDescriptor::Barrier();
+ if (!particles::timestamp_dir.empty()) {
+ if (ParallelDescriptor::IOProcessor()) {
+ if (!amrex::UtilCreateDirectory(particles::timestamp_dir, 0755)) {
+ amrex::CreateDirectoryFailed(particles::timestamp_dir);
+ }
+ }
+ //
+ // Force other processors to wait till directory is built.
+ //
+ ParallelDescriptor::Barrier();
+ }
Prepared by Codex
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Source/particles/CastroParticles.cpp:29 and read Castro::read_particle_params(), including the existing timestamp-directory checks described in the issue. Verify that startup with an empty timestamp_dir avoids directory creation and that configured timestamp output still creates its directory before the barrier.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- hpc
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100