Building MOM6
To run idealised models, or add extra features for yourself and others, you will likely need to build a MOM6 executable. The aim of this page is provide instructions for how to do this using the infrastructure provided by ACCESS-NRI. If you notice anything that is missing or could be improved in the explanation please raise an issue!
Building a standalone MOM6 executable
The below are instructions for how to build a standalone MOM6 executable. Here, we show two ways of building MOM6 standalone using Spack with OM3.
For some inspiration of why this is fun, have a look at the available test cases in the MOM6-examples repository. For some additional background on the below two workflows, see these official docs:
Building MOM6 standalone within your own Spack environment
Tip
This option is slower but does not require write access to ACCESS-NRI/ACCESS-OM3. It does require your own Spack installation.
Before starting on the below steps, you need to install your own version of Spack. There are instructions on how to do that here, you can stop once you've completed the enable spack step (i.e. you may skip the test step). With spack installed, we first need to change to the spack directory, then load spack's custom bash script and check everything is up to date:
cd /g/data/$PROJECT/$USER/spack/0.22
. spack-config/spack-enable.bash
cd spack-packages
git pull
cd ../spack-config
git pull
cd /g/data/$PROJECT/$USER/spack/0.22
Now we clone ACCESS-OM3 into our spack directory:
git clone git@github.com:ACCESS-NRI/ACCESS-OM3.git
cd ACCESS-OM3
git tag #check out the release you want
git checkout 2025.08.001
At this point we need to modify the ACCESS-OM3/spack.yaml so it knows how to build MOM6 on it's own, we do this by modifying this line:
spack:
specs:
- access-om3@git.2025.08.001
To this:
spack:
specs:
- access-mom6@2025.07.000 fflags="-march=sapphirerapids -mtune=sapphirerapids -unroll" cflags="-march=sapphirerapids -mtune=sapphirerapids -unroll" cxxflags="-march=sapphirerapids -mtune=sapphirerapids -unroll" ~access3
access-mom6 at @2025.07.000, this is because that is what was originally specified in the spack.yaml with tag 2025.08.001.
Then we have to comment out the following lines:
access-mom6:
require:
- '@2025.07.000'
- 'fflags="-march=sapphirerapids -mtune=sapphirerapids -unroll"'
- 'cflags="-march=sapphirerapids -mtune=sapphirerapids -unroll"'
- 'cxxflags="-march=sapphirerapids -mtune=sapphirerapids -unroll"'
Now we can create the spack environment in which to build MOM6:
cd ..
spack env create mom6standalone ACCESS-OM3/spack.yaml
Finally, we activate the mom6standalone environment and build MOM6:
spack env activate mom6standalone -p
spack concretize -f --fresh
spack install access-mom6 ~access3
These last two commands will take some time.
Tip
spack concretize only needs to be re-run if there are changes to the spack.yaml file. If changes are made to the MOM6
source code that mom6standalone is built from, running spack install should be sufficient for the build system to use the modified source code.
However, if something does not work correctly running spack concretize should fix things up.
Once completed one can find the executable with which mom6:
Warning
The mom6 executable can only be found if the spack environment it is built from is activated. Specifically,
if spack deactivate is run, the command which mom6 will not be able to find the MOM6 executable unless it is added.
to PATH.
Building MOM6 standalone with a pre-release build
Tip
This option is faster but requires write access to ACCESS-NRI/ACCESS-OM3.
Warning
This is NOT a supported workflow and is only provided to show that it is possible.
- Create branch from main, e.g.
cbull_test_mom6standalone - Edit the spack.yaml to have the following line:
spack: specs: - access-mom6@2025.07.000 fflags="-march=sapphirerapids -mtune=sapphirerapids -unroll" cflags="-march=sapphirerapids -mtune=sapphirerapids -unroll" cxxflags="-march=sapphirerapids -mtune=sapphirerapids -unroll" ~access3 - create a pre-release by opening a pull request with the above change (example)
When loading the pre-release a slight change of text is needed, here's an example:
module purge
module use /g/data/vk83/prerelease/modules
module load access-mom6/pr151-4
which mom6
Then add the following to your config.yaml:
modules:
use:
- /g/data/vk83/prerelease/modules
load:
- access-mom6/pr151-4
model: mom6
exe: mom6
exe field is the path to the executable (or just the executable name if it is already in your PATH).
Additional resources for running MOM6 standalone
Here are some other guides for building MOM6 using FMS. These builds will be more difficult to relate to ACCESS-OM3. Links: