Install GMT

From assela Pathirana
Jump to: navigation, search


GMT installation is explained in detail in the GMT Homepge. I recommend the following to windows users.

While it is perfectly possible to run Cygwin using the dos shell, it is much less painfull to first install Cygwin -- a free, open-source, UNIX-like shell environment for Windows and then use that environment to get going as if you are on a UNIX computer.

Assuming that you either are on a UNIX computer or have Cygwin installed on Windows with all the basic stuff like compilers (gcc, g77), utilities (awk, sed), etc., do the following to install GMT.


  • Check whether you can acces ftp sites. If you are behind a firwall, there may be problems. Then the following method will NOT work.
  • Access the install form on GMT homepage. (Last time I checked, it was here.
  • There is a link on the form to download the script called install_gmt. Download and save it now.
  • Fill in the form. Keep the following in mind.
    NetCDF Setup
    • Select "Please get and install netCDF ..." option
    • Give /usr/local/netCDF/ as the path
    High and Full resolutions coastline data
    • Click to get them unless your network is very very slow (Default is not to get).
    Select the C compiler you want to use
    • gcc
    Select default GMTHOME directory
    • /usr/local/GMT
    Select supplemental packages to install
    Unclick this unless you have Matlab: *MEX: Matlab interface for reading/writing GMT grdfiles
  • Submit the form and save the result as gmt_install.txt
  • Go to the place where you have install_gmt script and the above file. Do the following
sh install_gmt gmt_install
  • If everything is successful, the script will suggest some environment settings just before exiting. I use bash shell (as opposed to csh shell). It is also the default shell in Cygwin or Linux. In case of bash , set them in eigher .bashrc file in your home directory (affects only you) or at /etc/bashrc file (better). My settings are like this:
#GMT settings 
export NETCDFHOME=/usr/local/NetCDF
export GMTHOME=/usr/local/GMT/GMT4.1.1
export PATH=/usr/local/GMT/GMT4.1.1/bin:$PATH
export MANPATH=$MANPATH:/usr/local/GMT/GMT4.1.1/man to MANPATH
#GMT settings end
  • For csh settings are different.


Remember to exit the shell and open a new one (for the settings above to take effect). Then the command

printenv |grep GMT

should output lines containing

PATH= ...
(dots ... were added by me!)

Then run an extremely simple GMT operation as follows:

minmax << EOF
> 5 10 15
> -1 -25 35
> 100 0 1

This should produce the following output.

<stdin>: N = 3  <-1/100>        <-25/10>        <1/35>

Then you may like to attempt some simple plotting script.