AMReX-Astro / AMReX-Astro/Castro
Invalid `rot_source_type` is not handled on GPU, leaving rotation energy source uninitialized
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 340
- Forks
- 105
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 8
Description
Summary
Both rsrc() and corrrsrc() guard the invalid-rot_source_type error with #ifndef AMREX_USE_GPU. On GPU builds, invalid values skip the error path and proceed with uninitialized SrE / SrEcorr, contaminating UEDEN source terms.
Location
Source/rotation/rotation_sources.cpp:117Source/rotation/rotation_sources.cpp:433
Problem Details
Current pattern:
} else {
#ifndef AMREX_USE_GPU
amrex::Error("... invalid rot_source_type");
#endif
}
src[UEDEN] += SrE; // or src[UEDEN] = SrEcorr;
On GPU, the else body does nothing and the code uses undefined values.
Impact
- Undefined behavior and non-physical energy updates when
rot_source_typeis misconfigured. - Silent corruption in GPU runs instead of a clear fatal error.
Suggested Patch
Make invalid configuration fatal in all builds:
diff --git a/Source/rotation/rotation_sources.cpp b/Source/rotation/rotation_sources.cpp
--- a/Source/rotation/rotation_sources.cpp
+++ b/Source/rotation/rotation_sources.cpp
@@
} else {
-#ifndef AMREX_USE_GPU
amrex::Error("Error:: rotation_sources_nd.F90 :: invalid rot_source_type");
-#endif
}
@@
} else {
-#ifndef AMREX_USE_GPU
amrex::Error("Error:: rotation_sources_nd.F90 :: invalid rot_source_type");
-#endif
}
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/rotation/rotation_sources.cpp at lines 117 and 433, reviewing the invalid rot_source_type branches in rsrc() and corrrsrc(). Check the CPU and GPU build behavior, then verify that invalid configuration cannot reach the UEDEN updates with uninitialized rotation energy sources.
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
- 50/100