GAMIT/GLOBK In A Day
M. Floyd and T. Herring
Massachusetts Institute of Technology
GAGE/SAGE 2023 Community Science Workshop
Pre-Workshop Short Course
26 March 2023
http://geoweb.mit.edu/gg/courses/202303_GAGE-SAGE/
Material from R. W. King, T. A. Herring, M. A. Floyd (MIT) and S. C. McClusky (now at ANU)
Installation
Apply for a license
http://geoweb.mit.edu/gg/ http://geoweb.mit.edu/gg/license.php
2023/03/26 Installation and Useful Commands 2
License form
2023/03/26 Installation and Useful Commands 3
Understand and install the prerequisites
http://geoweb.mit.edu/gg/pre.php
• A Fortran compiler (e.g. gfortran)
• A C compiler (e.g. gcc or clang)
• X11 libraries and header files
• Generic Mapping Tools (GMT)
• Linux:
• Mac:
• Xcode or Command Line Tools for Xcode from the Apple
Developer (for C compiler and command line programs in
general for Terminal)
• From Terminal: xcode-select --install
• gfortran (e.g.
https://gcc.gnu.org/wiki/GFortranBinaries#MacOS)
• XQuartz (https://www.xquartz.org/)
• Windows:
• Use Windows Subsystem for Linux (WSL) for Windows 10 and
follow instructions for Linux
• Ubuntu 16.04, Ubuntu 18.04, Debian 9, openSUSE 15.1 and
openSUSE 43.1 Linux shells available for free
• Use a virtual machine (e.g. https://www.vmware.com/ or
https://www.virtualbox.org/), or Cygwin
(https://www.cygwin.com/) for other versions of Windows
2023/03/26 Installation and Useful Commands 4
Read the notes
http://geoweb.mit.edu/gg/docs/GG_Quick_Start_Guide.pdf
• A brief guide to installation steps and prerequisites described here
https://chandler.mit.edu/gps/...:
• README
• General overview of the GAMIT/GLOBK software, including details of
prerequisites and installation
• source/relnote.<NN.nn>
• Specific details of the latest release (<NN.nn> is currently 10.71)
2023/03/26 Installation and Useful Commands 5
Preparation
• We recommend you separate tasks into three separate directories:
• Source code directory (to keep a local copy of the source code files; optional)
• Installation directory (to compile and install the source code)
• Processing directory (to process without overwriting files in the installation
directory)
• Make a main installation directory of your choice on the command
line
• We highly recommend using a separate directory for each release of GAMIT;
do not mix source code from different versions, e.g. (“maf” is the username)
• On Mac, /Users/maf/Applications/gg/10.71/
• On Linux, /home/maf/Programs/gg/10.71/
2023/03/26 Installation and Useful Commands 6
Source code directory
• Users may wish to keep a local copy of source code
• As backup in case of problems during installation
• If unable to reconnect to the source code repository
(https://chandler.mit.edu/gps/)
• If you wish to do this, keep it separate from where you intend to
install GAMIT/GLOBK, e.g.
• ~/src/gg/10.71
• ~/Applications/src/gg/10.71
2023/03/26 Installation and Useful Commands 7
Download source code
• Log in to https://chandler.mit.edu/gps/ using the username and password provided with the
license
• Download at least these required files
• libraries.10.71.tar.gz (common subroutines)
• gamit.10.71.tar.gz (GAMIT source code)
• kf.10.71.tar.gz (GLOBK source code)
• com.10.71.tar.gz (scripts to run the software from the command line)
• tables.10.71.tar.gz (metadata and other definitions and information)
• help.10.71.tar.gz (program help pages)
• incremental_updates.*.tar.gz (all updates to date for the current release version)
• Additional files (optional)
• com_preGMT5.10.71.tar.gz (scripts using syntax prior to GMT 5; no longer supported)
• maps.10.71.tar.gz (used with sh_plotvel and velview; not necessary for most users)
• test_install.10.71.tar.gz (instructions and output files for comparison to test installation)
• relnote.10.71 (release notes for version 10.71)
• Copy these files into your main installation directory if downloaded to a source code directory
2023/03/26 Installation and Useful Commands 8
Compilation
• From the main installation directory
• Either extract install_software from com.10.71.tar.gz and run it:
tar xfzv com.10.71.tar.gz com/install_software
com/install_software
• Or download install_software from https://chandler.mit.edu/gps/, make it
executable and run it:
chmod +x install_software
./install_software
2023/03/26 Installation and Useful Commands 9
Compilation
• Read the output and answer the questions appropriately
• install_software will first extract the source code from all the tar-
files
• You are then quite likely to need to stop the installation process to edit
libraries/Makefile.config according to your operating system, e.g.
• X11LIBPATH (path to libX11)
• X11INCPATH (path to Xlib.h)
• MAXSIT (maximum number of sites to process simultaneously; must be < 100)
• MAXSAT (do not change)
• MAXATM (maximum atmospheric estimates per session)
• MAXEPC (maximum epochs per session, e.g. 24 hours at 30 s interval = 2880
measurement epochs)
• OS block (usually no need to change but see next slide)
2023/03/26 Installation and Useful Commands 10
Compilation: version of gfortran
• Run gfortran --version
• If your gfortran version is greater than or equal to 10, then you will
need to include the --fallow-argument-mismatch option
with FFLAGS in libraries/Makefile.config and
gamit/solve/Makefile.generic
• Unfortunately this option is not even recognized by gfortran version 9
and below, which causes an error if you try to include it, so you must
not include this option with FFLAGS in libraries/Makefile.config and
gamit/solve/Makefile.generic
2023/03/26 Installation and Useful Commands 11
Compilation: version of gfortran
2023/03/26 Installation and Useful Commands 12
Setting the environment
At the end of the installation you will see instructions such as:
Don't forget to set your : PATH to include /Users/maf/Applications/gg/10.71/com,
/Users/maf/Applications/gg/10.71/gamit/bin and
/Users/maf/Applications/gg/10.71/kf/bin;
: HELP_DIR environment variable in your shell profile; and
: INSTITUTE evnironment variable in your shell profile
For example, if using sh or bash ("echo $SHELL" = /bin/sh or /bin/bash),
add the following lines to ~/.bashrc (or ~/.bash_profile on Mac):
PATH="/Users/maf/Applications/gg/10.71/com:/Users/maf/Applications/gg/10.71/gamit/bin:/Use
rs/maf/Applications/gg/10.71/kf/bin:$PATH"; export PATH
HELP_DIR="/Users/maf/Applications/gg/10.71/help"; export HELP_DIR
Or, if using csh or tcsh ("echo $SHELL" = /bin/csh or /bin/tcsh),
add the following lines to ~/.cshrc:
setenv PATH
"/Users/maf/Applications/gg/10.71/com:/Users/maf/Applications/gg/10.71/gamit/bin:/Users/ma
f/Applications/gg/10.71/kf/bin:$PATH”
setenv HELP_DIR "/Users/maf/Applications/gg/10.71/help"
2023/03/26 Installation and Useful Commands 13
Updates!
• Incremental updates are made available on the first day of every
month, so please check at least
• Earth orientation parameters (pole.* and ut1.*; or sh_update_eop)
• SVN-PRN translation tables (svnav.dat)
• Differential code biases (dcb.dat)
• Leap seconds (leap.sec)
• Loading grids (ftp://everest.mit.edu/pub/GRIDS/)
• Example: 2016-12-31T23:59:60Z leap second
2023/03/26 Installation and Useful Commands 16
Additional software
• Generic Mapping Tools (GMT)
(https://www.generic-mapping-tools.org/)
• Required for plotting scripts to work
• Scripts in com/ use GMT 5+
• Prepend com_preGMT5/ to $PATH if using GMT 4
• These scripts are no longer updated, so switch to GMT 5 or GMT 6!
• Tom’s GGMatlab tools
(http://geoweb.mit.edu/~tah/GGMatlab/)
• tsview
• velview
2023/03/26 Installation and Useful Commands 17
Useful commands
Redirection
• The output from one command may be written to a file… (this is
useful for us to review if you have a problem or bug to report)
• “>” to overwrite an existing file
• “>>” to append to an existing file
• sort [file] > [sorted file]
• …or “piped” to another command, effectively forming the second
command’s input
• “|”
• grep ‘^ .* P$’ [file] | sort > [grep’d and sorted
file]
2023/03/26 Installation and Useful Commands 19
Shorthands
• Top-level (“root”) directory = “/”, e.g.
• cd /
• Your home directory = “~” or “$HOME”, e.g.
• ls ~
• “Links” or “shortcuts” may be created, e.g.
• ln -s /home/user/gg/10.71 ~/gg
• This creates a link in the user’s home directory called “gg” that points
to the directory /home/user/gg/10.71
• Rather than “cd /home/user/gg/10.71”, one can get to the same place
simply with “cd ~/gg”
• (This is used in GAMIT/GLOBK scripts and must remain in place!)
2023/03/26 Installation and Useful Commands 20
Checking processes and disk space
Processing sometimes fails, e.g. due to lack of available disk space, or stalls,
e.g. due to a runaway process, which can be checked with the following:
• du
• Disk usage: useful if you want to know how much space your (or others’!) directories
are taking up
• df
• Disk free space: useful if you want to know how much disk space is used and free
• top
• Table Of Processes: useful if you want a real-time overview of processes that are
running
• ps
• List processes: useful if you want to see what processes are running and their
process numbers, commands, etc.
2023/03/26 Installation and Useful Commands 21
What is a script?
• Scripts contain a series of commands written in one file and prepended by
a “hash-bang”
• #!/bin/sh for original Bourne Shell (usually the same as bash on modern systems)
• #!/bin/bash for Bourne Again Shell
• #!/bin/csh for C Shell (usually the same as tcsh on modern systems)
• #!/bin/tcsh for TENEX C Shell
• The script may then be executed to run all of the commands in sequence as
written
• Most scripts in GAMIT/GLOBK are written in csh or tcsh; many newer
scripts are written in bash
• Must have both csh and tcsh installed to run GAMIT/GLOBK scripts
• bash usually installed by default on current Linux distributions
2023/03/26 Installation and Useful Commands 22
Script example
#!/bin/bash
printf ‘The ISO date is: ’
date +’%Y-%m-%dT%H:%M:%S%Z’
printf ‘The mean of all numbers between 1 and 10 is: ’
printf ‘1 10\n’ | awk ‘BEGIN {sum=0; n=0}; {for (i=$1; i<=$2; i++)
{sum=sum+i; n++}}; END {print sum/n}’
printf ‘Goodbye!\n’
(Some lines above are wrapped, and be careful with power point converting – to en-dash and ‘ to a fancy
quote)
2023/03/26 Installation and Useful Commands 23