MITgcmExampleSteadyGauss

View the Project on GitHub

Example MITgcm setup for steady stratified flow over Gaussian Bump

Example Model Snapshot

Installing and running the code:

The MITgcm requires the openmpi compilers to run in parallel. These are often supplied on a supercluster, sometimes available via a module load command if they are not in the default environment. On a Mac, these compilers used to be challenging to install, but conda-forge now has recipes that will install these for you with minimal effort (you can also use brew, but that is less portable).

Using pixi

pixi is a more contained mamba/conda that I would recommend for analyzing data, and it works well for MITgcm work as well. Once you have installed pixi, you can download the requirements for the MITgcm and analysis using python by doing pixi install in the top directory of this repo.

If you really just want to check that everything is working, you can now just type pixi run all, and the following steps will run in order, as defined in ./pixi.toml:

Note that when using pixi, you need to either get into the pixi shell to execute commands like make, or you need to do pixi run make to ensure the pixi environment is being used.

Similarly, when analyzing the data, make sure that pixi is being used as the “environment” or “kernel” in tools like Jupyter lab, or VSCode.

Manually:

If not using pixi, then you can replicate the steps above manually using conda/mamba

Compiling

’./build’ is where we compile the gcm. To compile you should run:

 /Users/jklymak/MITgcmc66h/MITgcm/tools/genmake2 \
  -optfile=../build_options/darwin_brewgfortranmpi -mods=../code/ \
   -rootdir=/Users/jklymak/MITgcmc66h/MITgcm

then make depend followed by make.

Running

Generate the data

In ./input, run python gendata.py.

Note that this writes many files in ../runs/RunFr1300. This is where we will run the model from. Why do we move it? Because we often want a number of runs that are similar, and this ensures reproducibility. In addition to creating the files we need some plots are made into ../runs/RunFr1300/figs/ that are often useful to make sure we did what we wanted, and the ‘./input’, ‘./code’, ‘./build_options’, and ‘./analysis’, directories are saved into this directory as well. These essentially ensure that the model can be rerun even if the data is removed.

Run the model

Now we can execute the model:

mpirun -np 4 ../../build/mitgcmuv

where -np 4 means we want 4 processors (as also specified in code/SIZE.h)

The results should be in ../runs/RunFr1300/ and if we used nf90io, then the data should be in ``statevars.nc and statevars2d.nc`.

Modifying to your own needs:

You probably don’t want to use the simulation provided, so now you need to do the work of creating your own simulation.

Changing domain size

  1. Change code/SIZE.h and recompile.
  2. If using open boundaries change input/data.obcs i.e. OB_Jnorth=80*0, where in this case ny=80
  3. Check data.diagnostics for the correct data being output for your purpose.
  4. Change input/gendata.py and rerun python gendata.py. It would be good practice to make a new name for the run at this point.

Changing other parameters

  1. Edit gendata.py. For new runs it is best to change the value of outdir right away so you don’t overwrite your old runs.