8
$\begingroup$

I am learning ocean modelling and have started with MOM6. I needed guidance on where to start from and how to run the model on my local machine (Ubuntu) to perform various tasks such as regridding or creating initial conditions or maybe small runs which might not take much time.

$\endgroup$

1 Answer 1

7
$\begingroup$

You can follow the instructions I wrote at https://medium.com/@manmeet20singh11/installing-mom6-on-ubuntu-57918a200293?sk%3D9961d6f8565659b05e007349c47568b7&sa=D&source=hangouts&ust=1576058141492000&usg=AFQjCNH74gi6j9XgT6I3509nb8Y0gtj4-Q

Installing MOM6 on Ubuntu

Downloading the model and basic libraries

Following https://github.com/NOAA-GFDL/MOM6-examples/wiki/Installing-MOM6-in-a-virtual-machine-running-Ubuntu

And the video https://www.youtube.com/watch?v=a5hKh8s_1b0&t=181s

sudo apt-get install git tcsh pkg-config
sudo apt-get install gfortran
sudo apt-get install netcdf-bin libnetcdf-dev libnetcdff-dev
sudo apt-get install openmpi-bin libopenmpi-dev
sudo apt-get install libnetcdff-dev
git clone --recursive https://github.com/NOAA-GFDL/MOM6-examples demo
cd demo

Open the file src/mkmf/templates/linux-gnu.mk and find the variable LIBS. Now in this file add the syntax

# Add -lnetcdff
LIBS += -lnetcdff

Compiling

Now we are ready to start compiling and that we will do by going to https://github.com/NOAA-GFDL/MOM6-examples/wiki/Getting-started#compiling-the-models

The instructions are for setting up on an intel compiler so we have to do some editing on these commands because we are going to use gfortran which is GNUs fortran.

Make a directory to work to build the advanced libraries

mkdir -p build/gnu/shared/repro/
cd  build/gnu/shared/repro/

Next, we will run the mkmf list path tools and we are going to give it the relative path to FMS the source code

../../../../src/mkmf/bin/list_paths -l ../../../../src/FMS

So what you have done is populated this file path_names with all these files and now we are going to run another mkmf tool and care of itself and we are going to specify the linux gnu template that we edited above and we are going to tell it to build FMS

../../../../src/mkmf/bin/mkmf -t ../../../../src/mkmf/templates/linux-gnu.mk -p libfms.a -c "-Duse_libMPI -Duse_netCDF -DSPMD" path_names

and that makes the Makefile

Finally we can type

make NETCDF=3 REPRO=1 FC=mpif77 CC=mpicc  libfms.a -j

So that builds the lib FMS code which can be seen by

$ ls -l libfms.a 
-rw-rw-r-- 1 manmeet manmeet 13863094 Dec 10 13:22 libfms.a

Now we are going to go back and we will make a new set of folders ocean_only/repro

cd ../../
mkdir -p ocean_only/repro
cd ocean_only/repro

Now we are going to run the list paths command again and that is just down and this time we are going to provide the current directory as a possible supply of sorts and gauge you want to put some source files in here and thats the dot for, and then there is the relative path of source code for MOM6 and we are going to be linking a dynamic executable, so we are putting the dynamic directory out of the config source and we are building a set up using the solo drivers, the driver had a config source, and all of the source code under src is being used.

../../../../src/mkmf/bin/list_paths ./ ../../../../src/MOM6/{config_src/dynamic,config_src/solo_driver,src/{*,*/*}}/

So this has made a path_names file again which is populated will all the MOM6 source code. Now we are going to run the mkmf tool again and this time the target there is MOM6 and we have to change the template again to the linux-gnu

../../../../src/mkmf/bin/mkmf -t ../../../../src/mkmf/templates/linux-gnu.mk -o '-I../../shared/repro' -p MOM6 -l '-L../../shared/repro -lfms' -c '-Duse_libMPI -Duse_netCDF -DSPMD' path_names

This will create the Makefile and now we can run the Makefile using a similar command but the target will be MOM6

make NETCDF=3 REPRO=1 FC=mpif77 CC=mpicc LD=mpif77 MOM6 -j

Now we have the executable just called MOM6 and we will demonstrate that it works.

Going to the top of the directory and then to double_gyre

cd ../../../../
cd ocean_only/double_gyre/
mpirun -n 1 ../../build/gnu/ocean_only/repro/MOM6

This is a simple 10 day test and will give something like this

$ mpirun -n 1 ../../build/gnu/ocean_only/repro/MOM6
NOTE: MPP_DOMAINS_SET_STACK_SIZE: stack size set to    32768.
&MPP_IO_NML
 HEADER_BUFFER_VAL=      16384,
 GLOBAL_FIELD_ON_ROOT_PE=T,
 IO_CLOCKS_ON=F,
 SHUFFLE=          0,
 DEFLATE_LEVEL=         -1,
 CF_COMPLIANCE=F,
 /
NOTE: MPP_IO_SET_STACK_SIZE: stack size set to     131072.
NOTE: ======== Model being driven by MOM_driver ========
NOTE: callTree: o Program MOM_main, MOM_driver.F90
NOTE: open_param_file: MOM_input has been opened successfully.
NOTE: open_param_file: MOM_override has been opened successfully.
 MOM domain decomposition
whalo =    4, ehalo =    4, shalo =    4, nhalo =    4
  X-AXIS =   44
  Y-AXIS =   40
 MOMc domain decomposition
whalo =    2, ehalo =    2, shalo =    2, nhalo =    2
  X-AXIS =   22
  Y-AXIS =   20
NOTE: diag_manager_mod::diag_manager_init: prepend_date only supported when diag_manager_init is called with time_init present.
 MOM domain decomposition
whalo =    4, ehalo =    4, shalo =    4, nhalo =    4
  X-AXIS =   44
  Y-AXIS =   40
 MOM domain decomposition
whalo =    4, ehalo =    4, shalo =    4, nhalo =    4
  X-AXIS =   44
  Y-AXIS =   40WARNING: depth_list_setup: ./Depth_list.nc does not exist.  Creating a new file.WARNING: depth_list_setup: ./Depth_list.nc does not exist.  Creating a new file.MOM Day       0.000      0: En 1.423707E-13, MaxCFL  0.00000, Mass 5.288178268008E+18
    Total Energy: 4126F9E3C5B6FEAF  7.5288188616176497E+05
    Total Mass:   5.2881782680077681E+18, Change:   0.0000000000000000E+00 Error:  0.00000E+00 ( 0.0E+00)
MOM Day       1.000     72: En 4.580432E-06, MaxCFL  0.00023, Mass 5.288178268008E+18
    Total Energy: 42B607A80A83D4D0  2.4222139843540812E+13
    Total Mass:   5.2881782680077681E+18, Change:  -4.3787057037831573E+01 Error: -4.37871E+01 (-8.3E-18)
MOM Day       2.000    144: En 8.958206E-06, MaxCFL  0.00040, Mass 5.288178268008E+18
    Total Energy: 42C58AE533474153  4.7372590026370648E+13
    Total Mass:   5.2881782680077681E+18, Change:   4.0318344822758547E+00 Error:  4.03183E+00 ( 7.6E-19)
MOM Day       3.000    216: En 1.166708E-05, MaxCFL  0.00045, Mass 5.288178268008E+18
    Total Energy: 42CC0E8B5CE02C7F  6.1697586479192992E+13
    Total Mass:   5.2881782680077681E+18, Change:   3.7798219410031322E+01 Error:  3.77982E+01 ( 7.1E-18)
MOM Day       4.000    288: En 1.542296E-05, MaxCFL  0.00044, Mass 5.288178268008E+18
    Total Energy: 42D28B60D5891799  8.1559337444446391E+13
    Total Mass:   5.2881782680077681E+18, Change:  -5.3715335655123397E+01 Error: -5.37153E+01 (-1.0E-17)
MOM Day       5.000    360: En 1.826022E-05, MaxCFL  0.00053, Mass 5.288178268008E+18
    Total Energy: 42D5F4B97D5D13C3  9.6563312817231047E+13
    Total Mass:   5.2881782680077681E+18, Change:  -2.1099290705067006E+01 Error: -2.10993E+01 (-4.0E-18)
MOM Day       6.000    432: En 2.397431E-05, MaxCFL  0.00062, Mass 5.288178268008E+18
    Total Energy: 42DCD397A5E14CB5  1.2678043163166683E+14
    Total Mass:   5.2881782680077681E+18, Change:  -1.0757841703346941E+01 Error: -1.07578E+01 (-2.0E-18)
MOM Day       7.000    504: En 2.927962E-05, MaxCFL  0.00073, Mass 5.288178268008E+18
    Total Energy: 42E19A5109E607AC  1.5483585791186938E+14
    Total Mass:   5.2881782680077681E+18, Change:   4.6503600220410505E+01 Error:  4.65036E+01 ( 8.8E-18)
MOM Day       8.000    576: En 3.486441E-05, MaxCFL  0.00081, Mass 5.288178268008E+18
    Total Energy: 42E4F5D995BB3999  1.8436920009364478E+14
    Total Mass:   5.2881782680077681E+18, Change:   2.4524203108417453E+01 Error:  2.45242E+01 ( 4.6E-18)
MOM Day       9.000    648: En 4.195565E-05, MaxCFL  0.00090, Mass 5.288178268008E+18
    Total Energy: 42E9393C9CAC4D82  2.2186896584766006E+14
    Total Mass:   5.2881782680077681E+18, Change:  -2.0342624683786397E+01 Error: -2.03426E+01 (-3.8E-18)
MOM Day      10.000    720: En 4.604729E-05, MaxCFL  0.00100, Mass 5.288178268008E+18
    Total Energy: 42EBAEF71B9A7E17  2.4350627232664072E+14
    Total Mass:   5.2881782680077681E+18, Change:   2.2570880028229340E+01 Error:  2.25709E+01 ( 4.3E-18)FATAL: NETCDF ERROR: No such file or directory File=RESTART/MOM.res.ncFATAL: NETCDF ERROR: No such file or directory File=RESTART/MOM.res.nc--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD 
with errorcode 1.NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------
-------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code.. Per user-direction, the job has been aborted.
-------------------------------------------------------
--------------------------------------------------------------------------
mpirun detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:Process name: [[19779,1],0]
  Exit code:    1
--------------------------------------------------------------------------

Thus we will get an error when we haven’t created a restart. We will do that now

mkdir -p RESTART
mpirun -n 1 ../../build/gnu/ocean_only/repro/MOM6

Next we will use two processors and we see that it runs faster now

mpirun -n 2../../build/gnu/ocean_only/repro/MOM6

https://github.com/NOAA-GFDL/MOM6-examples/wiki/Ubuntu-compiler-environment

$\endgroup$
1
  • 5
    $\begingroup$ IMO, it's generally best to include the relevant information & content in the answer itself, not just a link to where the content may be. That's more useful for future readers, or in case the link goes down. The link is nice to have in addition for reference or for further information. See also How to answer. $\endgroup$ Commented Dec 10, 2019 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.