#	Information for installing GMT 4.x
#
#	$Id: README 10213 2014-02-27 16:30:57Z pwessel $
#
#	Copyright (c) 1991-2014, P. Wessel & W. H. F. Smith
#
#	See LICENSE.TXT file for copying and redistribution conditions.
#
#	This program is free software; you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation; version 2 or any later version.
#
#	This program is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#	GNU General Public License for more details.
#
#	Contact info: http://gmt.soest.hawaii.edu

Permission to use, copy, modify, and distribute (with no more than a
reasonable redistribution fee) this software and its documentation
for any purpose is hereby granted, provided that the above copyright
notice appear in all copies, that both that copyright notice and this
permission notice appear in supporting documentation, and that the name
of GMT not be used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.  The GMT
package may be included in a bundled distribution of software for which
a fee may be charged.
The University of Hawaii (UH) and the National Oceanic and Atmospheric
Administration (NOAA) make no representations about the suitability of
this software for any purpose.  It is provided "as is" without expressed
or implied warranty.  It is provided with no support and without
obligation on the part of UH or NOAA, to assist in its use, correction,
modification, or enhancement.

0. Introduction
---------------

If you obtained GMT using the install_gmt4.sh script then you have
already completed the installation unless something went wrong.
You do not need to read these instructions unless you plan to
install and make the programs manually.

Visit gmt.soest.hawaii.edu and click DOWNLOAD to do the simple installation.

GMT has been installed successfully under Unix/Linux/OSX on workstations
from Sun, Silicon Graphics, Cray, DEC, HP, Data General, IBM, Apple, NEXT,
as well on any number of PC clones running Linux.  It also installs under
WIN32 and in Unix emulators such as Cygwin on PCs and Machten on Macs.
We anticipate few problems if you are installing the package on other platforms.
Should you need to make small modifications, e.g., not use certain
include files, please let us know so that future releases will be even
more portable.  This is likely to mean that your platform is not
POSIX compliant.  For a non-UNIX solution, see Appendix L for options
and installation details.

Note there are three GMT tar archives available:

1. gmt-4.5.12-src.tar.bz2           The GMT distribution (GNU License)
2. gmt-4.5.12-non-gpl-src.tar.bz2   Optional, non-GNU License code (Triangle)
3. gshhg-gmt-2.3.0.tar.gz           All five resolutions of GSHHG geography data

For Windows users there are separate Windows installers available; this
discussion only considers UNIX/Linux/OS X installations.

1. Install netCDF library
-------------------------

GMT uses several functions in the netCDF-4 library
(http://www.unidata.ucar.edu/).  Prepackaged versions of netCDF-4
are available for virtually all UNIX distributions.  The package
is usually named libnetcdf-dev (e.g., Ubuntu/Debian) or netcdf-dev.
EPEL (http://fedoraproject.org/wiki/EPEL) provides recent packages
for Red Hat, CentOS, and other Enterprise Linux.  MacPorts
(http://www.macports.org/) and Fink (http://www.finkproject.org/)
have recent packages for OSX.

1b. OPTIONAL GDAL support
-----------------------

To use the experimental GDAL interface (ability to provide grids
or images to be imported via gdal) you must have the GDAL library
and include files installed and configure with --enable-gdal[=dir].
Either use the dir modifier for the parent dir to include and lib,
or setenv GDAL_INC and GDAL_LIB prior to running configure.
Please report any problems or limitations that you might experience
as this is an optional and experimental feature.

2. Install support data
-----------------------

At run-time, GMT programs will expect to find its databases
in the "share" directory pointed to by the environment variable
GMT_SHAREDIR. The appropriate default value is set at compilation
time, so users need not set this environment variable, unless they
moved the "share" directory elsewhere.

You may ftp GMT from pub/gmt on any of the following sites.  Try
the site that is closest to you to minimize transmission times:

        Site                            FTP address
--------------------------------------------------------------
SOEST, U. of Hawaii                     gmt.soest.hawaii.edu
Lab for Satellite Altimetry, NOAA       ibis.grdl.noaa.gov
IRIS, Washington, US                    ftp.iris.washington.edu
IAG-USP, U. of Sao Paulo, BRAZIL        ftp.iag.usp.br
Dep. Geology, U. in Oslo, NORWAY        ftp.geologi.uio.no
ISV, Hokkaido U, Sapporo, JAPAN         ftp.eos.hokudai.ac.jp
GDS, Vienna U. of Technology, AUSTRIA   gd.tuwien.ac.at
TENET, Tertiary Education & Research Networks, SOUTH AFRICA
                                        gmt.mirror.ac.za

Extract the files and put them in separate directory (need not be
where you eventually want to install GMT).

If your connection is such that you are unable to obtain these files
you may order a CD-ROM from Geoware.  See section 15 below for details.

3. Configure
------------

You must first create the files src/config.mk, src/GMT,
src/isogmt, src/gmt_notposix.h and src/gmt_version.h
by running the configure script.  If you have several C compilers on your
system, or using one that is not called cc or gcc, you should first do a

setenv CC <compilername, including path if unusual>

(this is in csh, other shells have different syntax).

If you want to specify your own CFLAGS setting, use
setenv CFLAGS <your options>
otherwise configure will provide the option known to
work on your system.  You should know what you are doing if
you want to override the defaults.
If your standard POSIX Bourne shell is NOT /bin/sh you
may need to do
setenv CONFIG_SHELL <path_to_your_shell>
Finally, if you plan to install the Matlab extensions you
need to
setenv MATLAB <path to Matlab dir>
unless it is /usr/local/matlab [the default].
For building the mex supplement for Octave instead
you select --enable-octave.  Optionally specify where
the mex and .m files should be placed with
--mex-enable-mdir and --mex-enable-xdir.
You can disable Matlab/Octave mex compilation by using the
--disable-mex option
One supplement (xgrid) requires X11.  You can disable the
compilation of this supplement by using the option
--disable-xgrid

For a summary of configure options, type configure --help.

If you want to override the default directories for the GMT
main directory (current dir) and executable directory (cwd/bin)
you should pass these directories on the configure command line.

  --prefix=your-main-GMT-dir      Set main GMT directory [cwd]
  --bindir=your-bindir            Set bin directory [PREFIX/bin]
  --libdir=your-libdir            Set lib directory [PREFIX/lib]
  --includedir=your-includedir    Set include directory [PREFIX/include]
  --mandir=your-mandir            Set man directory [PREFIX/man]
  --datadir=your-datadir          Set GMT share directory for coastlines [PREFIX/share]
  --docdir=your-docdir            Set directory for documentation [PREFIX/share]

There are a few GMT-specific options in configure.  They are

  --with-nc-config=       Full path to nc-config [auto]
  --enable-netcdf=dir     Directory with netCDF [auto]
  --enable-matlab=dir     Specify Matlab directory [/usr/local/matlab]
  --enable-octave         Select Octave interface (disables Matlab interface)
  --enable-mex-mdir       Override where to place *.m functions for Matlab or Octave
  --enable-mex-xdir       Override where to place *.mex functions for Matlab or Octave
  --enable-shared         To make shared (dynamic) libraries
  --enable-triangle       To use J. Shewchuk's fast triangulation
  --enable-US             To use US (inch) instead of SI (cm) units
  --enable-eps            Make Encapsulated PostScript by default [Freeform PS]
  --enable-flock          Use file locking on .gmtcommands4 files
  --disable-mex           Disable compilation of mex supplement which requires Matlab or Octave
  --disable-xgrid         Disable compilation of xgrid supplement which requires X11

By default, GMT will be made with static libraries.  If you system
supports shared (dynamic) libraries you can select the option
--enable-shared which will try to assemble shared libraries.

By default, GMT will use Dave Watson's Delaunay triangulation
routine.  However, a much faster alternative is available from
Jonathan Shewchuk, but his routine is not distributed under the GNU
Public License.  If you work for a for-profit organization you should read
Shewchuk's copyright statement (in src/README.TRIANGLE) first.  If you can
use his routine you should append --enable-triangle.

At run-time, GMT will initialize all default variables by reading
either the share/gmtdefaults_SI or the share/gmtdefaults_US file.
Both are installed, and the one that is read is given by the file
share/gmt_setup.conf.  This file will have either SI or US as the first
two columns on a line.  SI is default, use --enable-US to switch.
The default values differ slightly between SI and US, mostly because
it is inconvenient to convert, say, 1" to 2.54 cm; we use 2.5 cm
instead.  Although strongly discouraged, if you want to make
permanent changes to some of the defaults you can edit the
gmtdefaults_{SI,US} files directly.  A much better approach is to
create a .gmtdefaults4 file in your home directory and edit those
settings since GMT will check for that file before loading system
defaults (actually, it will first look in the current directory,
then the home directory, and then finally in share).  See the gmtdefaults
man page for a description of all defaults.

To prevent two GMT processes writing to the same .gmtcommands4 file
simultaneously (thereby corrupting it), GMT can implement the POSIX
advisory file locking scheme and sets and releases locks on these
files.  Under GNU/Linux, this does not work when the files reside
in directories mounted with NFS.  Since it works with NFS under
other UNIX systems we suspect this is a [temporary] limitation of GNU
NSF.  If you want to activate file locking you may enable it by
supplying the --enable-flock flag to configure.

GMT can produce either Freeform PostScript (suitable to be sent to
various printers) or Encapsulated PostScript (suitable to be included
in another document).  True PS files will use the setpagedevice
PostScript command to manipulate paper trays and manual feeds
on selected printers.  Some PostScript previewers (such as Sun's
old pageview) do not understand these commands and will abort; this
is also true of some PS to raster conversion utilities.  On the other
hand, EPS files are intended to be included in another document and
are not allowed to use setpagedevice.  To simplify printing, EPS files
are allowed to contain a showpage operator which means EPS files will
print if sent to a printer.  The PAPER_MEDIA setting in .gmtdefaults4
can be set to one or the other format (see man gmtdefaults).  By
default GMT will produce PS files.  If you do not need to take
advantage of paper tray manipulations or expect to make mostly EPS
files you may want to use --enable-eps to make EPS the default.  Note
that this can be changed at any time via the PAPER_MEDIA parameter.

	In the main GMT directory, type

./configure [options]

Append any of the options as you see fit.  If configure cannot figure
out all the required compiler and linker flags it will give you a message
and you will be asked to edit src/config.mk to set macros manually.

Once this step is completed you may move on to the Makefile section.

If for some reason the configure step fails on your system, you may
have to manually create the files from above from the *.in templates
If you run into this problem, pls let us know so we may improve this
processes further.
[Note: For PCs running WIN?? or DOS you must copy the file
gmt_math_win32.h to gmt_math.h instead; see Appendix L in the docs]

4. Makefile preparation
-----------------------

	If you are on a system without IEEE floating point support (some
Crays we know of) you must add -DNO_IEEE to the CC_OPT flags as well.

5. Compile/link
---------------

From the main GMT directory (all make calls herein refers to the main
GMT directory), type

	make (or make all)

which will compile/link all the programs.  After a successful
compilation you may install the executables in the designated
bin directory with the command

	make install-gmt

Place the support data and coastline files in the correct
directory by saying

	make install-data

After a successful install you can have *.o files and the local
executables removed by saying

	make clean

PS.  Should you need to start from scratch again, for instance
to reinstall under another OS from the same directory, you should
first say

	make spotless

and run configure again before returning to step 5.

6. Man pages
------------

GMT man pages are stored in man/manl.  You can either
install the entire set of man pages to the chosen directory with

	make install-man

or set the environment variable MANPATH in your .login file to
include the man directory that holds the desired gmt man pages.

7. Documentation
____________________

In the directory doc/html you will find html files for online
browsing of GMT documentation (Cookbook) and manual pages.
The Documentation also contains the GMT_Tutorial.pdf
file which is a short course in how to use GMT.  It can be
followed individually or in a lab setting by a group of users.
While these are available from the main GMT home page in
Hawaii, users may find it convenient to install these
pages locally for added speed.  The subdirectories
contain both HTML and PDF versions of the cookbook, and
HTML versions of the manual pages.  All users need to do
is to add a browser bookmark to the top-level file
doc/html/gmt_services.html.
To install all documentation in your chosen directory, type

	make install-doc

8. Set path
-----------

Make sure users set their PATH to include the directory containing
the GMT executables (BINDIR) if this is not a standard directory
like /usr/local/bin.  You should now be able to run GMT programs.

9. GMT supplemental Code
-------------------------

GMT users elsewhere have developed programs that utilize the GMT
libraries and produce PostScript code compatible with the rest of
GMT or simply perform data manipulation.  In addition, misc.
code developed by us depend on GMT libraries.
Currently, the supplemental archive include the directories:

  dbase     - Data extractor for global gridded data sets such
              as those on CD-ROM from NGDC.
  gshhg     - Data extractor for GSHHG polygons and lines.
  imgsrc    - Data extractor for Smith/Sandwell altimetry grids.
  meca      - Plotting of focal mechanisms, velocity arrows,
              and error ellipses on maps.
  mex       - Matlab or Octave mex files for grid file I/O.
  mgg       - Programs for MGD-77 data in .gmt format.
  mgd77     - Programs for handling of native MGD77 files.
  misc      - psmegaplot, makepattern, gmtdigitize,
              gmtstitch, gmtdp, and nc2xy
  segyprogs - Plotting SEGY seismic data sets.
  sph       - Spherical interpolation and triangulation.
  spotter   - Plate tectonic & kinematics applications.
  x2sys     - Track intersection (crossover) tools.
  x_system  - Track intersection (crossover) tools (old version).
  xgrid     - X11 editor for grid files.

These are installed automatically, except for mex and xgrid which
requires more configuration as they depend on non-GMT libraries.

10. Example Scripts
-------------------

	A complete set of the example scripts used to create all the
example plots, including all necessary data files, are provided by
the installation; you can run all the examples from the
src directory using

	make examples

11. Misc
--------

Before running programs, there are a few things you should do/know:

  - Read carefully the documentation for the gmt system.  This can be
    found as both PDF and HTML files in the doc/pdf|html directories.
    The successful operation of gmt-programs depends directly on your
    understanding of how gmt "works", its option lists, I/O, and composite
    plot mechanisms.  Then, before running individual gmt programs, read
    the associated man page.

  - Do not confuse the GMT-system with the GMT-database that was
    initiated at Lamont-Doherty Earth Observatory.  These
    marine geophysical data files (Gravity, Magnetics, Topography)
    are NOT distributed with the GMT-system!  [However, programs that
    deal with gmt-files can be found in the supplemental tar archive.

13. A reminder
--------------

   If you think it is appropriate, you may consider paying us back
by including our latest EOS article (Wessel, P. and W. H. F. Smith,
New, improved version of the Generic Mapping Tools released, EOS Trans.
AGU, 79, 579, 1998, and our Geophysics article on the gridding algorithm
in surface (Smith, W. H. F. and P. Wessel, Gridding with continuous
curvature splines in tension, Geophysics, 55, 293-305, 1990) in the
reference list of your future publications that will benefit from the
availability of GMT.

14. Software support
--------------------

   You haven't bought anything so you cannot expect full service.
However, if you find a bug in any of the programs, please report
it to us via gmt.soest.hawaii.edu rather than trying to fix it yourself
so that we, and through us, other users may benefit from your find.
Make sure you provide us with enough information so that we can recreate
the problem.
Two mailing lists of interest to GMT users are available:  gmt-group@lists.hawaii.edu
allows us to notify registered users in the event of bugfixes
and/or new releases.  A separate mailing list (gmt-help@lists.hawaii.edu) exists
for GMT users who have questions about GMT installation and usage.  If you want
to subscribe to one or both of these mailinglists, send a message to
listproc@hawaii.edu that contains one or both of the commands

subscribe gmt-help <yourname, not email address>
subscribe gmt-group <yourname, not email address>

You may post messages to gmt-help while gmt-group is more of a one-way street
for us to inform users of bug fixes and upgrades.  The online registration
also lets you subscribe to the two mailinglists.

15. Ordering the GMT package on CD/DVD-Rs
-----------------------------------------

Should you or someone you know without net-access need to obtain GMT:
Geoware makes and distributes CD/DVD-Rs with the GMT package and many
useful data sets.  For more details and a full description of the data
sets (up to 60 Gb of data!) visit www.geoware-online.com


Good luck!

The GMT Team.
