Ubuntu compiler environment - adcroft/MOM6-examples GitHub Wiki

Supplementary instructions for Ubuntu Linux environments

These instructions closely follow the instructions outlined for GFDL's HPC platforms with

Setup a compiler environment on Ubuntu

Execute the following commands to install the compilation prerequisites on an Ubuntu machine:

sudo apt-get install csh
sudo apt-get install make
sudo apt-get install gfortran
sudo apt-get install openmpi-bin
sudo apt-get install libopenmpi-dev
sudo apt-get install libnetcdf-dev
sudo apt-get install libnetcdff-dev
sudo apt-get install netcdf-bin

Create a blank env file

The following commands make use of a file build/gnu/env that can contain any local environment changes need for compilation:

mkdir -p build/gnu
echo > build/gnu/env

Building libfms.a

To build the Makefile use:

mkdir -p build/gnu/shared/repro/
(cd build/gnu/shared/repro/; rm -f path_names; \
../../../../src/mkmf/bin/list_paths ../../../../src/FMS; \
../../../../src/mkmf/bin/mkmf -t ../../../../src/mkmf/templates/linux-gnu.mk -p libfms.a -c "-Duse_libMPI -Duse_netCDF -DSPMD" path_names)

To build the FMS library (libfms.a):

(cd build/gnu/shared/repro/; source ../../env; make NETCDF=3 REPRO=1 FC=mpif90 CC=mpicc libfms.a -j)

Notice the addition of FC=mpif90 and CC=mpicc above, which is necessary to find the MPI header files.

Building the ocean-only MOM6 executable

To create the Makefile for compiling MOM6:

mkdir -p build/gnu/ocean_only/repro/
(cd build/gnu/ocean_only/repro/; rm -f path_names; \
../../../../src/mkmf/bin/list_paths ./ ../../../../src/MOM6/{config_src/dynamic,config_src/solo_driver,src/{*,*/*}}/ ; \
../../../../src/mkmf/bin/mkmf -t ../../../../src/mkmf/templates/linux-gnu.mk -o '-I../../shared/repro' -p 'MOM6 -L../../shared/repro -lfms' -c "-Duse_libMPI -Duse_netCDF -DSPMD" path_names)

To build the MOM6 executable:

(cd build/gnu/ocean_only/repro/; source ../../env; make NETCDF=3 REPRO=1 FC=mpif90 LD=mpif90 MOM6 -j)

This time note the addition of LD=mpif90.

Run MOM6 ocean-only

For any example in ocean_only/ that does NOT have an INPUT/ directory, e.g. double_gyre:

cd ocean_only/double_gyre/
mkdir RESTART
mpirun -np 4 ../../build/gnu/ocean_only/repro/MOM6

Ubuntu platform notes

14.10: nc-config within the template will work fine.

15.10: We noticed that you also need to install the package libnetcdff-dev and change nc-config to nf-config within the template file.