Skip to content

Commit e991927

Browse files
committed
Use automatic spack script generation
to set the module and environmental variables commands variable
1 parent 38ca067 commit e991927

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

mache/spack/env.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -232,26 +232,17 @@ def get_modules_env_vars_and_mpi_compilers(
232232
if config.has_option('spack', 'cray_compilers'):
233233
cray_compilers = section.getboolean('cray_compilers')
234234

235-
mod_env_commands = 'module purge\n'
236-
237-
for shell_filename in [
238-
f'{machine}.{shell}',
239-
f'{machine}_{compiler}_{mpi}.{shell}',
240-
]:
241-
path = (
242-
importlib_resources.files('mache.spack.templates') / shell_filename
243-
)
244-
try:
245-
with open(str(path)) as fp:
246-
template = Template(fp.read())
247-
except FileNotFoundError:
248-
# there's nothing to add, which is fine
249-
continue
250-
shell_script = template.render(
251-
e3sm_lapack=include_e3sm_lapack,
252-
e3sm_hdf5_netcdf=include_e3sm_hdf5_netcdf,
253-
)
254-
mod_env_commands = f'{mod_env_commands}\n{shell_script}'
235+
mod_env_commands = get_spack_script(
236+
spack_path=None,
237+
env_name=None,
238+
compiler=compiler,
239+
mpi=mpi,
240+
shell=shell,
241+
machine=machine,
242+
load_spack_env=False,
243+
include_e3sm_lapack=include_e3sm_lapack,
244+
include_e3sm_hdf5_netcdf=include_e3sm_hdf5_netcdf,
245+
)
255246

256247
mpicc, mpicxx, mpifc = _get_mpi_compilers(
257248
machine, compiler, mpi, cray_compilers

0 commit comments

Comments
 (0)