Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/users_guide/spack/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ spack_script = get_spack_script(
config_file=machine_config,
include_e3sm_lapack=include_e3sm_lapack,
include_e3sm_hdf5_netcdf=e3sm_hdf5_netcdf,
yaml_template=yaml_template
)
```

Expand Down Expand Up @@ -161,7 +160,6 @@ mpicc, mpicxx, mpifc, mod_env_commands = get_modules_env_vars_and_mpi_compilers(
shell='sh', # or 'csh'
include_e3sm_lapack=include_e3sm_lapack,
include_e3sm_hdf5_netcdf=e3sm_hdf5_netcdf,
yaml_template=yaml_template
)
```

Expand Down
44 changes: 22 additions & 22 deletions mache/cime_machine_config/config_machines.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,35 +219,35 @@

<modules compiler="gnu">
<command name="load">PrgEnv-gnu/8.5.0</command>
<command name="load">gcc-native/12.3</command>
<command name="load">cray-libsci/23.12.5</command>
<command name="load">gcc-native/13.2</command>
<command name="load">cray-libsci/24.07.0</command>
</modules>

<modules compiler="intel">
<command name="load">PrgEnv-intel/8.5.0</command>
<command name="load">intel/2023.2.0</command>
<command name="load">intel/2024.1.0</command>
</modules>

<modules compiler="nvidia">
<command name="load">PrgEnv-nvidia</command>
<command name="load">nvidia/24.5</command>
<command name="load">cray-libsci/23.12.5</command>
<command name="load">nvidia/25.5</command>
<command name="load">cray-libsci/24.07.0</command>
</modules>

<modules compiler="amdclang">
<command name="load">PrgEnv-aocc</command>
<command name="load">aocc/4.1.0</command>
<command name="load">cray-libsci/23.12.5</command>
<command name="load">cray-libsci/24.07.0</command>
</modules>

<modules>
<command name="load">craype-accel-host</command>
<command name="load">craype/2.7.30</command>
<command name="load">cray-mpich/8.1.28</command>
<command name="load">craype/2.7.32</command>
<command name="load">cray-mpich/8.1.30</command>
<command name="load">cray-hdf5-parallel/1.12.2.9</command>
<command name="load">cray-netcdf-hdf5parallel/4.9.0.9</command>
<command name="load">cray-parallel-netcdf/1.12.3.9</command>
<command name="load">cmake/3.24.3</command>
<command name="load">cray-parallel-netcdf/1.12.3.13</command>
<command name="load">cmake/3.30.2</command>
</modules>
</module_system>

Expand Down Expand Up @@ -406,23 +406,23 @@

<modules compiler="gnu.*">
<command name="load">PrgEnv-gnu/8.5.0</command>
<command name="load">gcc-native/12.3</command>
<command name="load">gcc-native/13.2</command>
</modules>

<modules compiler="nvidia.*">
<command name="load">PrgEnv-nvidia</command>
<command name="load">nvidia/24.5</command>
<command name="load">nvidia/25.5</command>
</modules>

<modules compiler="gnugpu">
<command name="load">cudatoolkit/12.4</command>
<command name="load">cudatoolkit/12.9</command>
<command name="load">craype-accel-nvidia80</command>
</modules>

<modules compiler="nvidiagpu">
<command name="load">cudatoolkit/12.4</command>
<command name="load">cudatoolkit/12.9</command>
<command name="load">craype-accel-nvidia80</command>
<command name="load">gcc-native-mixed/12.3</command>
<command name="load">gcc-native-mixed/13.2</command>
</modules>

<modules compiler="gnu">
Expand All @@ -434,13 +434,13 @@
</modules>

<modules>
<command name="load">cray-libsci/23.12.5</command>
<command name="load">craype/2.7.30</command>
<command name="load">cray-mpich/8.1.28</command>
<command name="load">cray-hdf5-parallel/1.12.2.9</command>
<command name="load">cray-netcdf-hdf5parallel/4.9.0.9</command>
<command name="load">cray-parallel-netcdf/1.12.3.9</command>
<command name="load">cmake/3.24.3</command>
<command name="load">cray-libsci/24.07.0</command>
<command name="load">craype/2.7.32</command>
<command name="load">cray-mpich/8.1.30</command>
<command name="load">cray-hdf5-parallel/1.14.3.1</command>
<command name="load">cray-netcdf-hdf5parallel/4.9.0.13</command>
<command name="load">cray-parallel-netcdf/1.12.3.13</command>
<command name="load">cmake/3.30.2</command>
</modules>
</module_system>

Expand Down
12 changes: 0 additions & 12 deletions mache/machines/anvil.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,6 @@ partitions = acme-small, acme-medium, acme-large
qos = regular, acme_high


# Config options related to spack environments
[spack]

# whether to load modules from the spack yaml file before loading the spack
# environment
modules_before = False

# whether to load modules from the spack yaml file after loading the spack
# environment
modules_after = False


# config options related to synchronizing files
[sync]

Expand Down
12 changes: 0 additions & 12 deletions mache/machines/aurora.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,6 @@ account = E3SM_Dec
# queues (default is the first)
queues = prod, debug

# Config options related to spack environments
[spack]

# whether to load modules from the spack yaml file before loading the spack
# environment
modules_before = False

# whether to load modules from the spack yaml file after loading the spack
# environment
modules_after = False


# config options related to synchronizing files
[sync]

Expand Down
12 changes: 0 additions & 12 deletions mache/machines/chicoma-cpu.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@ partitions = standard, gpu
qos = standard, debug


# Config options related to spack environments
[spack]

# whether to load modules from the spack yaml file before loading the spack
# environment
modules_before = False

# whether to load modules from the spack yaml file after loading the spack
# environment
modules_after = False


# config options related to synchronizing files
[sync]

Expand Down
13 changes: 0 additions & 13 deletions mache/machines/chrysalis.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,6 @@ cores_per_node = 128
# available partition(s) (default is the first)
partitions = compute, debug, Shigh


# Config options related to spack environments
[spack]

# whether to load modules from the spack yaml file before loading the spack
# environment
modules_before = False

# whether to load modules from the spack yaml file after loading the spack
# environment
modules_after = True


# config options related to synchronizing files
[sync]

Expand Down
12 changes: 0 additions & 12 deletions mache/machines/compy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,6 @@ partitions = slurm
qos = regular


# Config options related to spack environments
[spack]

# whether to load modules from the spack yaml file before loading the spack
# environment
modules_before = True

# whether to load modules from the spack yaml file after loading the spack
# environment
modules_after = False


# config options related to synchronizing files
[sync]

Expand Down
12 changes: 0 additions & 12 deletions mache/machines/dane.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@ cores_per_node = 112
partitions = pbatch, pdebug


# Config options related to spack environments
[spack]

# whether to load modules from the spack yaml file before loading the spack
# environment
modules_before = True

# whether to load modules from the spack yaml file after loading the spack
# environment
modules_after = False


# config options related to synchronizing files
[sync]

Expand Down
8 changes: 0 additions & 8 deletions mache/machines/frontier.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ partitions = batch
# Config options related to spack environments
[spack]

# whether to load modules from the spack yaml file before loading the spack
# environment
modules_before = False

# whether to load modules from the spack yaml file after loading the spack
# environment
modules_after = False

# whether the machine uses cray compilers
cray_compilers = True

Expand Down
9 changes: 1 addition & 8 deletions mache/machines/pm-cpu.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,10 @@ constraints = cpu
# quality of service (default is the first)
qos = regular, debug, premium


# Config options related to spack environments
[spack]

# whether to load modules from the spack yaml file before loading the spack
# environment
modules_before = False

# whether to load modules from the spack yaml file after loading the spack
# environment
modules_after = False

# whether the machine uses cray compilers
cray_compilers = True

Expand Down
9 changes: 1 addition & 8 deletions mache/machines/pm-gpu.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,10 @@ constraints = gpu
# quality of service (default is the first)
qos = regular, debug, premium


# Config options related to spack environments
[spack]

# whether to load modules from the spack yaml file before loading the spack
# environment
modules_before = False

# whether to load modules from the spack yaml file after loading the spack
# environment
modules_after = False

# whether the machine uses cray compilers
cray_compilers = True

Expand Down
12 changes: 0 additions & 12 deletions mache/machines/ruby.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@ cores_per_node = 56
partitions = pbatch, pdebug


# Config options related to spack environments
[spack]

# whether to load modules from the spack yaml file before loading the spack
# environment
modules_before = True

# whether to load modules from the spack yaml file after loading the spack
# environment
modules_after = False


# config options related to synchronizing files
[sync]

Expand Down
30 changes: 21 additions & 9 deletions mache/spack/config_machines.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
from collections import defaultdict
from importlib import resources as importlib_resources

from lxml import etree

Expand Down Expand Up @@ -104,13 +105,13 @@ def config_to_shell_script(config, shell_type):
script_lines.append('')

if e3sm_hdf5_netcdf_modules:
script_lines.append('{% if e3sm_hdf5_netcdf %}')
script_lines.append('{%- if e3sm_hdf5_netcdf %}')
script_lines.extend(
_convert_module_commands_to_script_lines(
e3sm_hdf5_netcdf_modules, shell_type
)
)
script_lines.append('{% endif %}')
script_lines.append('{%- endif %}')
script_lines.append('')

script_lines.extend(_convert_env_vars_to_script_lines(config, shell_type))
Expand All @@ -121,7 +122,7 @@ def config_to_shell_script(config, shell_type):


def extract_spack_from_config_machines(
machine, compiler, mpilib, shell, output
machine, compiler, mpilib, shell, output=None
):
"""
Extract machine configuration from XML and write it to a shell script.
Expand All @@ -136,10 +137,18 @@ def extract_spack_from_config_machines(
MPI library name.
shell : str
Shell script type ('sh' or 'csh').
output : str
output : str, optional
Output file to write the shell script.

Returns
-------
script: str
The generated shell script as a string.
"""
config_filename = 'mache/cime_machine_config/config_machines.xml'
config_filename = (
importlib_resources.files('mache.cime_machine_config')
/ 'config_machines.xml'
)

config = extract_machine_config(config_filename, machine, compiler, mpilib)
if config is None:
Expand All @@ -149,8 +158,11 @@ def extract_spack_from_config_machines(
)

script = config_to_shell_script(config, shell)
with open(output, 'w') as f:
f.write(script)
if output is not None:
with open(output, 'w') as f:
f.write(script)

return script


def _convert_module_commands_to_script_lines(module_commands, shell_type):
Expand Down Expand Up @@ -249,12 +261,12 @@ def _convert_env_vars_to_script_lines(config, shell_type):
script_lines.append('')

if e3sm_hdf5_netcdf_env_vars:
script_lines.append('{% if e3sm_hdf5_netcdf %}')
script_lines.append('{%- if e3sm_hdf5_netcdf %}')
for name, value in e3sm_hdf5_netcdf_env_vars:
if shell_type == 'sh':
script_lines.append(f'export {name}="{value}"')
elif shell_type == 'csh':
script_lines.append(f'setenv {name} "{value}"')
script_lines.append('{% endif %}')
script_lines.append('{%- endif %}')

return script_lines
Loading
Loading