-
Notifications
You must be signed in to change notification settings - Fork 148
Tutorials
The following jupyter notebooks (formerly IPython) illustrate some analysis of MOM6 output with explanation. You can peruse the notebooks on GitHub by navigating through MOM6-examples.
You can also run the notebooks interactively yourself. You will need jupyter installed (we recommend using conda to obtain and manage python):
cd MOM6-examples/
jupyter notebook
And then open the URL posted in the output (if it doesn't open automatically).
The directories corresponding to individual examples follow a common pattern of contents. Examples that have no binary input data typically look like:
tree MOM6-examples/ocean_only/benchmark/
MOM6-examples/ocean_only/benchmark/
|-- diag_table
|-- input.nml
|-- MOM_input
|-- MOM_memory.h
|-- MOM_override
|-- MOM_parameter_doc.all
|-- MOM_parameter_doc.layout
`-- MOM_parameter_doc.short
Of the above, only some files are read by the model while the rest are written. We record them in order version control the experiment as a whole, and to regression test the code.
Input file | i/o | Contents |
---|---|---|
input.nml | IN | Has the necessary fortran namelists for executing MOM6 and controlling non-MOM6 components of the code. This includes the list of MOM-style parameter files to read, usually "MOM_input" and "MOM_override". |
MOM_input | IN | Contains all the necessary run-time parameters that define this experiment. |
MOM_override | IN | Is usually blank except in cases where there are several variants on an example (e.g. with different coordinates). |
diag_table | IN | List of diagnostics, used by FMS's diagnostic manager. |
MOM_parameter_doc.all | OUT | Records all the run-time parameters that are not associated with the parallelization. |
MOM_parameter_doc.short | OUT | Records all the non-default run-time parameters that are not associated with the parallelization. |
MOM_parameter_doc.layout | OUT | Records all the run-time parameters that are associated with the parallelization. These parameters are computational and do not affect the numerical solution. |
available_diags | OUT | a list of available diagnostics. |
ocean.stats.* | OUT | are ascii files with a few key statistics/metrics used for bitwise regression testing by the core-MOM6 team. These files are version controlled in a separate "regressions" repository that is platform specific. |
When you run the models you will so other files appear:
- *.nc - Most diagnostics will be in netcdf files named in
diag_table
. There are a few others that are written to files such as "ocean_geometry.nc", "timestats.nc", "MOM_IC.nc", which are controlled by MOM6 rather than through the diagnostics manager. - ocean.stats, CPU_stats, - a few key statistics/metrics.
- logfile.* -
- RESTART/* - restart files. The model will fail with an error if the RESTART directory does not exist.
- fort.*, exitcode, _read_error.nml - are written by FMS code and can usually be ignored.
As outlined in Getting started obtain an interactive shell on batch nodes:
msub -I -lsize=32,walltime=01:00:00
To run the benchmark test, cd
to the benchmark directory and launch the executable:
cd ocean_only/benchmark/
mkdir -p RESTART
aprun -n 8 ../../build/intel/ocean_only/repro/MOM6
The benchmark test case is an example of a regional ocean model with two (hypothetical) ocean basins connected via a channel. The idealized shape of the basins (i.e., ocean mask), topography and grids are generated at run-time so there is no need for input grid files. The initial conditions are also set at runtime.
The grid resolution is set at NIGLOBAL x NJGLOBAL = 360x180 (1/4 degree for the region in this test case). If desired, this can be changed via an input file (MOM_override) in the working directory. For example, to make the model 4 times bigger one could do this in the workdir:
cd ocean_only/benchmark/
cat << EOF > MOM_override
#override NIGLOBAL = 720
#override NJGLOBAL = 360
EOF
The default total run time of this test is 2 days. This can be changed by adding the following lines to input.nml in the working directory:
cd ocean_only/benchmark/
cat << EOF >> input.nml
&ocean_solo_nml
months = 0
days = 20 /
EOF
The model will write the model state to the RESTART directory at the end of the run. To restart the model, copy the files from the RESTART directory to the INPUT directory. You also need to edit the input.nml file so that:
input_filename = 'n'
becomes
input_filename = 'r'
Almost all the analysis examples above use python. Here's some steps to setup a working python environment that should work for the examples above:
- Find the appropriate bash script installer for your system from https://docs.conda.io/en/latest/miniconda.html#linux-installers and copy the URL
- Download the installer with wget, e.g.
wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.12.0-Linux-x86_64.sh
where the second argument is the URL from step 1. - Run the installer script with
bash Miniconda3-py39_4.12.0-Linux-x86_64.sh
, where the second argument is the name of the actual script you downloaded. - Answer the questions. We recommended saying "Y" to updating your .bashrc.
- Create a python environment using
conda create -n mom6py jupyter xarray matplotlib numpy netcdf4
- Activate the new environment
conda activate mom6py
- Launch a jupyter notebook with
jupyter notebook
and click the URL that appears in the terminal.