Skip to content

Commit e0c9358

Browse files
committed
Add patch to fix chemistry-disabled build
MFC's CMakeLists.txt sets -D chemistry=False by default, but m_derived_types.fpp unconditionally tries to use m_thermochem module (which is only generated when chemistry is enabled via mfc.sh, not in standalone CMake builds). Fix: - Patch m_derived_types.fpp to conditionally import m_thermochem - Define stub num_species=1 when chemistry=False - Apply patch to both v5.1.0 and master versions - Remove parallel=False (no longer needed with this fix) - Document patch in SPACK.md
1 parent 3d95fed commit e0c9358

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

packaging/spack/SPACK.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ The package configures the build environment:
146146
- Sets up compiler wrappers for MPI when enabled
147147
- Configures GPU toolchains when GPU variants are selected
148148

149+
### Patches
150+
151+
The package includes patches to fix build issues:
152+
- `fix-chemistry-disabled.patch`: Fixes CMake-only builds by providing a stub `num_species` parameter when chemistry support is disabled (default for CMake builds). This allows `m_derived_types` to compile without requiring the generated `m_thermochem` module.
153+
149154
### CMake Integration
150155

151156
Spack automatically handles CMake configuration:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff --git a/src/common/m_derived_types.fpp b/src/common/m_derived_types.fpp
2+
index 1234567..7654321 100644
3+
--- a/src/common/m_derived_types.fpp
4+
+++ b/src/common/m_derived_types.fpp
5+
@@ -11,10 +11,16 @@ module m_derived_types
6+
use m_constants !< Constants
7+
8+
use m_precision_select
9+
+#:if chemistry
10+
use m_thermochem, only: num_species
11+
+#:else
12+
+ ! Chemistry disabled: use dummy value for num_species
13+
+ integer, parameter :: num_species = 1
14+
+#:endif
15+
16+
implicit none
17+
18+
!> Derived type adding the field position (fp) as an attribute
19+
type field_position
20+
real(wp), allocatable, dimension(:, :, :) :: fp !< Field position
21+

packaging/spack/package.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class Mfc(CMakePackage):
2525
version("master", branch="master")
2626
version("5.1.0", sha256="4684bee6a529287f243f8929fb7edb0dfebbb04df7c1806459761c9a6c9261cf")
2727

28+
# Patches
29+
patch("fix-chemistry-disabled.patch", when="@5.1.0,master")
30+
2831
# Build options
2932
variant("mpi", default=True, description="Build with MPI support")
3033
variant("openacc", default=False, description="Build with OpenACC GPU support")

0 commit comments

Comments
 (0)