@@ -14,8 +14,11 @@ To enable Spack-based environments for a new machine, you will need to:
1414 supported compiler and MPI library combination.
15152 . Add system-provided (external) packages, saving time and preventing build
1616 failures if Spack attempts to build them from source.
17- 3 . Optionally, provide shell script templates for module/environment setup if
18- needed.
17+ 3 . Prefer automatic shell script generation. Shell snippets used to be
18+ maintained as templates in ` mache.spack.templates ` , but are now derived
19+ primarily from the E3SM CIME machine configuration
20+ (` mache/cime_machine_config/config_machines.xml ` ). Only add a minimal
21+ template override when strictly necessary (see below).
1922
2023## YAML Template Files
2124
82858386` ` `
8487
85- # # Shell Script Templates
88+ # # Automatic shell script generation (preferred)
8689
87- If the machine requires special module loads or environment variables not handled by Spack, add corresponding shell script templates :
90+ When downstream packages call
91+ {py:func}`mache.spack.get_spack_script`, the module loads and
92+ environment-variable setup are constructed as follows :
8893
89- - ` <machine>.sh` and/or `<machine>_<compiler>_<mpilib>.sh` for bash
90- - ` <machine>.csh` and/or `<machine>_<compiler>_<mpilib>.csh` for csh/tcsh
94+ 1. Optional : activate Spack and the requested environment.
95+ 2. Auto-generate a shell snippet from the E3SM CIME machine configuration
96+ stored in `mache/cime_machine_config/config_machines.xml`, filtered for the
97+ requested `(machine, compiler, mpilib)` and rendered for the target shell
98+ (`sh` or `csh`).
99+ 3. Append any Jinja2 template override found in
100+ ` mache/spack/templates/` named either `<machine>.<sh|csh>` or
101+ ` <machine>_<compiler>_<mpilib>.<sh|csh>` .
91102
92- These scripts are also Jinja2 templates and can use the same conditional logic as the YAML files.
103+ This pipeline greatly reduces maintenance and prevents drift between Mache and
104+ E3SM’s authoritative machine configuration. In most cases, you do not need to
105+ author or maintain shell script templates in Mache.
106+
107+ # ## When to add a template override
108+
109+ Only provide a small override in `mache/spack/templates/` if you need to :
110+
111+ - Apply an adjustment that’s not appropriate for the shared E3SM CIME config
112+ (machine-local quirk, temporary workaround, etc.).
113+ - Add conditional behavior toggled by
114+ ` include_e3sm_lapack` or `include_e3sm_hdf5_netcdf` (both exposed as Jinja
115+ booleans in templates) that cannot be expressed in the CIME config.
116+
117+ Templates are Jinja2 files and can use the same conditional logic as YAML
118+ templates.
93119
94120# # Testing
95121
96- After adding or modifying YAML and shell script templates :
122+ After adding or modifying YAML templates (or an exceptional shell override) :
97123
98- 1. Use the `make_spack_env` or `get_spack_script` functions in `mache.spack` to generate and test the environment.
99- 2. Confirm that all modules load and all external packages are correctly detected by Spack.
124+ 1. Use `make_spack_env` or `get_spack_script` in `mache.spack` to generate and
125+ test the environment and load scripts.
126+ 2. Confirm that the generated shell snippet includes the expected module loads
127+ from the CIME machine config and that Spack detects all external packages.
1001283. Build and run a simple test application to verify the environment.
101129
102130# # Further Reading
0 commit comments