MLOC Source Code

MLOC Source Code

The original coding of the hypocentroidal decomposition algorithm (mostly in the module mlocinv.f90) followed the presentation in Jordan and Sverdrup (1981) extremely closely, to the extent of naming variables as nearly the same as possible and including equation numbers from the paper in comments. The published paper, however, contains a few (minor) typographic errors in equations. The code was based on a corrected version.

MLOC was originally written in Fortran 77 but nearly all code has been updated to use structures and features from Fortran 90/95 that improve legibility and robustness. There are multiple user-controlled levels of warnings for errors and debugging. The code is extensively commented, and a full understanding of the functionality of mloc requires at least occasional reference to the source code. Some rarely-needed options are only accessible by editing the code and re-compiling. The code is divided into multiple packages with related functionality. Most variables that are used beyond a given program unit are declared in a master include file ( This file also contains a large number of named common blocks and most communication between program units occurs through them.

Aside from the code base borrowed from Ken Creager’s LOC program for the initial coding of mloc, the major bits of source code that have been adapted from other people’s work are:

  • Code from Johannes Schweitzer’s HYPOSAT program for calculating travel times in the custom crustal models (Schweitzer, 2001)
  • Code from Ray Buland’s software implementing the tau-p travel time calculations (Buland and Chapman, 1983)
  • Code from Bob Engdahl’s location program (Engdahl et al., 1998) for various odious tasks, such as ellipticity corrections and bounce-point corrections
  • A few routines from Numerical Recipes (Press et al., 1986)
  • The code to calculate Sn, the robust estimator of spread, from Croux and Rousseeuw (1992)

Source Code Modules

A list of all the source code modules in the current release of mloc and a note about their functionality can be found here.

Version History

Changes to mloc are documented in the text file mloc_version_history.txt, which is kept with the source code files in the directory /mloc_distribution/mloc_src/. Recent changes are posted here. Early development of mloc was undocumented. Version documentation began in early 2005 with v4.1. The version scheme was expanded to three fields with v9.1.1 in October 2009. The versioning scheme is major.minor.patch or sometimes major.minor.feature, i.e., the third field increments when a significant bug has been patched or a significant feature has been added (or occasionally, removed). For lesser changes the release date is updated but the version number stays the same. The version number and release date are hard-coded in the main program and always listed in the .summary output file.


The mloc distribution package includes a makefile for use with the open source Fortran compiler gfortran. Most development of mloc has taken place under a commercial compiler from Absoft or Intel.


The source code of older distributions of mloc (including v10.5.0) is not fully compatible with the most recent versions of gfortran (e.g., v9.2.0). Versions of gfortran up to about v5 should be compatible with that older code base. The offending sections were some very old codes in the tau-p library taulib.f90. That code has been rewritten for version 10.5.1 of mloc and it is now compatible with gfortran v9.2.0.