Installing GMT and MB-System on Ubuntu Systems

The following instructions are derived from posts by Marcel Croon on the MB-System Discussion List on April 18, 2009. Some editing has been applied and references to a particular Ubuntu release have been omitted. Thanks Marcel!

Below I have posted step by step instructions for installing GMT and MB-System on Ubuntu. The Poseidon Linux is great and very convenient but I personally prefer to have control over what I install on my Ubuntu installation.

To obtain the current Ubuntu release go to the Ubuntu web site: http://www.ubuntu.com/

Installing GMT

1) Install libnetcdf-dev package via Synaptic Package Manager (System/Administration)

2) Make a folder in your home directory in Terminal (Applications/Accessories):

$ cd ~/Documents
$ mkdir gmt440

3) Get "install_gmt" script.

Follow the instructions on the gmt install page in Firefox at http://gmt.soest.hawaii.edu/gmt/gmt_install_form.html . Save the "install_gmt" file (Right-click the "install_gmt" link under "A. Basic Requirements" and then select "Save Link As...") in your newly generated "~/Documents/gmt440" folder

4) Get "GMTparam.txt" file

Continue following the instructions on the gmt install page in Firefox at http://gmt.soest.hawaii.edu/gmt/gmt_install_form.html . Generate a "GMTparam.txt" file by filling out the parameters and click the GET PARAMETERS button at the bottom of the page. Right-click on the parameters page that shows up in Firefox and select "Save Page As..." and save the "GMTparam.txt" file in your "~/Documents/gmt440" folder.

I copied my file below in this email as an example for how to fill out the parameters on the webpage before clicking the GET PARAMETERS button. I strongly recommend to generate your own GMTparam.txt file via the webpage and not by copying the following text since characters in emails and web pages are often different and if you just copy and paste the following lines into a "GMTparam.txt file" you are likely to get errors during installation.

# This file contains parameters needed by the install script
# install_gmt for GMT Version 4.4.0. Give this file
# as the argument to the install_gmt script and the whole
# installation process can be placed in the background.
# Default answers will be selected where none is given.
# You can edit the values, but do not remove definitions!
#
# Assembled by gmt_install_form.html, $Revision: 1.66 $
# Processed by install_gmt_form.pl : 1.36 on
#
# Sat Apr 18 14:30:22 HST 2009
#
# Do NOT add any spaces around the = signs. The
# file MUST conform to Bourne shell syntax
#---------------------------------------------
# SYSTEM UTILITIES
#---------------------------------------------
GMT_make=make
#---------------------------------------------
# NETCDF SECTION
#---------------------------------------------
netcdf_ftp=n
netcdf_install=n
netcdf_path=/usr
passive_ftp=y
#---------------------------------------------
# GMT FTP SECTION
#---------------------------------------------
GMT_ftp=y
GMT_ftpsite=1
GMT_get_src=y
GMT_get_share=y
GMT_get_coast=y
GMT_get_high=y
GMT_get_full=y
GMT_get_suppl=y
GMT_get_doc=y
#---------------------------------------------
# GMT SUPPLEMENTS SELECT SECTION
#---------------------------------------------
GMT_suppl_dbase=y
GMT_suppl_gshhs=y
GMT_suppl_imgsrc=y
GMT_suppl_meca=y
GMT_suppl_mex=n
GMT_mex_type=octave
GMT_suppl_mgd77=y
GMT_suppl_mgg=y
GMT_suppl_misc=y
GMT_suppl_segyprogs=y
GMT_suppl_spotter=y
GMT_suppl_x2sys=y
GMT_suppl_x_system=y
GMT_suppl_xgrid=n
#---------------------------------------------
# GMT ENVIRONMENT SECTION
#---------------------------------------------
GMT_si=y
GMT_ps=y
GMT_prefix=/usr/local/gmt440
GMT_bin=/usr/local/gmt440/bin
GMT_lib=/usr/local/gmt440/lib
GMT_share=/usr/local/gmt440/share
GMT_include=/usr/local/gmt440/include
GMT_man=/usr/local/gmt440/share/man
GMT_doc=/usr/local/gmt440/share/doc/gmt
GMT_sharedir=/usr/local/gmt440/share
GMT_dir_full=
GMT_dir_high=
GMT_dir_cli=
#---------------------------------------------
# COMPILING & LINKING SECTION
#---------------------------------------------
GMT_sharedlib=n
GMT_cc=cc
GMT_flock=y
GMT_triangle=n
#---------------------------------------------
# TEST & print FILE SECTION
#---------------------------------------------
GMT_run_examples=y
GMT_delete=n
#---------------------------------------------
# MEX SECTION
#---------------------------------------------

6) Now go to Terminal and run following commands:

$ cd ~/Documents/gmt440
$ sudo sh install_gmt GMTparam.txt

That should do the trick for GMT installation. At the end you should get the message "GMT Installation Complete. Remember ...." without any errors. Ignore the "Remember..." message for now and continue with MB-System.

Installing MB-System

1) Install following packages, which are needed for MB-System, via Synaptic Package Manager:

% xorg-dev
% libmotif-dev
% libxp-dev
% mesa-common-dev
% libsdl1.2-dev
% libsdl-image1.2-dev

2) Make a MB-System folder in Terminal:
$ sudo mkdir /usr/local/mbsystem511

3) Dowload the install package at ftp://ftp.ldeo.columbia.edu/pub/MB-System/MB-System.tar.gz and select "Open with Archive Manager (default)" and extract the tar file to your "~/Documents" folder.

4) In Terminal go to the installation package:
$ cd ~/Documents/mbsystem-5.1.1

5) Change and then save the "install_makefiles" file parameters via the program "gedit" in Terminal for lines 99-114 according to the example below (don't copy following lines to gedit since characters in emails are often different and lead to errors during installation):
$ gedit install_makefiles &

$MBSYSTEM_HOME = "/usr/local/mbsystem511";
$OS = "LINUX";
$CC = "cc";
$BYTESWAPPED = "YES";
$GRAPHICAL = "YES";
$MOTIFINCDIR = "/usr/include";
$MOTIFLIBS = "-L/usr/lib -L/usr/lib/X11 -L/usr/include/X11 -lXm -lXt -lX11";
$OPENGLLIBS = "-lGLU -lGL";
$GMTLIBDIR = "/usr/local/gmt440/lib";
$GMTINCDIR = "/usr/local/gmt440/include";
$NETCDFLIBDIR = "/usr/local/lib";
$NETCDFINCDIR = "/usr/local/include";
$LEVITUS = "$MBSYSTEM_HOME/share/annual";
$PROJECTIONS = "$MBSYSTEM_HOME/share/Projections.dat";
$CFLAGS = "-g -w";
$LFLAGS = "-L$NETCDFLIBDIR -lm -lnetcdf";

6) Download the Levitus Database ( ftp://ftp.ldeo.columbia.edu/pub/MB-System/annual.gz ) and select "Open with Archive Manager (default)" and extract the tar file to the "~/Documents/mbsystem-5.1.1/share" folder.

7) Build the MB-System package by running following commands in Terminal:
$ cd ~/Documents/mbsystem-5.1.1
$ ./install_makefiles
$ sudo make all

If the build is succesful after several minutes you will get the command line prompt back without any error message.

8) Now copy all files to the "/usr/local/mbsystem511" folder in Terminal (make sure you include the /* after mbsystem-5.1.1):
$ sudo cp -r ~/Documents/mbsystem-5.1.1/* /usr/local/mbsystem511

Done. Now it's time to update your profile in order to run the GMT and MB-System program commands anywhere in your file system in Terminal.

UPDATE PROFILE

1) After succesful installation of GMT and MB-System update your profile. In Terminal add following lines to your ".bashrc" profile below the lines that are already there (don't delete anything):
-$ cd ~
$ gedit .basrc &

MANPATH=/usr/local/man:/usr/share/man:/usr/X11R6/man:/usr/local/gmt440/man:/usr/local/mbsystem511/man
export NETCDFHOME=/opt/local
export PATH=/usr/local/gmt440/bin:$PATH
export GMTHOME=/usr/local/gmt440
export MGD77_HOME=/usr/local/gmt440/share/mgd77
export GMTLIBDIR=/usr/local/gmt440/share/mgg
export X2SYS_HOME=/usr/local/gmt440/share/x2sys
export PATH=/usr/local/mbsystem511/bin:$PATH

After saving your ".bashrc" file in gedit type the following command in Terminal:
$ source .bashrc

2) You can test if GMT and MB-System work by running program commands in Terminal, e.g.:
$ psxy
$ man psxy
$ mbgrid
$ man mbgrid

Now both GMT and MB-System are properly installed. I used version names for the folders (gmt440 and mbsystem511) in "/usr/local". In the future just change the names for all instructions above (e.g. gmt441 and mbsystem512) and update your ".bashrc" profile. That way you will never lose your old installations and can roll back to the old versions easily via changing the profile in case anything goes wrong with the new installation.

GV, PS2EPS, PS2PDF and CONVERT

I recommend installing and using the following packages:
- "gv" for viewing the ps and eps files from GMT (in Terminal run "gv yourgmtoutputfile.ps &")
- "ps2eps" for conversion of ps to eps
- "convert" from the "ImageMagick" package for conversion of ps and eps to images like jpg and png
- "ps2pdf" (prepackaged on Ubuntu installation) for conversion of ps and eps files to pdf

1) Go to the Synaptic Package Manager and install following packages:
% gv
% ps2eps
% imagemagick

Hopefully these instructions help you with getting the job done in Ubuntu.

Cheers,
Marcel.


Last Updated: 14 June 2009