Routines for evaluating approximate covariance matrices of Green's functions, designed for uncertainty quantification in Bayesian inversions of earthquake sources (ready for high-performance computing).
This repository provides a Fortran90 and MATLAB routines for evaluation of the covariance (and cross-covariance) matrices of Green's functions. It is specifically designed as a high-performance toolset to efficiently handle model uncertainties in Bayesian waveform-based earthquake source inversions. It features a dual-language implementation to balance computational power (Fortran90) with ease of testing and visualization (MATLAB). List of four types of methods implemented in this package:
- Approximate Covariance Function (ACF)
- Approximate Cross-covariance Function (AXCF)
- Stationarized Approximate Covariance Function (SACF)
- Stationarized Approximate Cross-covariance Function (SAXCF)
Hallo, M., Gallovic, F. (2016). Fast and cheap approximation of Green functions uncertainty for waveform-based earthquake source inversions, Geophysical Journal International, 207, 1012-1029. https://doi.org/10.1093/gji/ggw320
Fortran90, High Performance Computing (HPC), Fourier Transform, Cross-Platform (Windows, Linux, macOS)
- High Performance: Core routines implemented in Fortran90 for efficient evaluation of large covariance and cross-covariance matrices.
- Dual-Language Implementation: Fortran90 functions are supplemented with respective MATLAB functions, using identical mathematical logic for seamless testing and prototyping.
- Efficient Uncertainty Quantification: Specifically optimized for handling model uncertainties in Bayesian source inversion frameworks.
- Full Matrix Output: The toolset returns complete covariance structures ready for integration into inverse solvers.
src/approxc.f90- Fortran 90 module containing the calculation subroutines ACF, AXCF, SACF, SAXCFsrc/example.f90- Fortran 90 main program for calculating covariances from data inexample_data.txtsrc/nr.for- Fortran 77 subroutine four1 from Numerical RecipesMakefile- Compilation script for the Fortran partrun_example_plot.py- Python script to load and plot matrices generated by the Fortran coderequirements.txt- pip requirements file for instalation of Python dependenciesaxcf.m- MATLAB function for determining covariance matrices (ACF, AXCF)saxcf.m- MATLAB function for determining stationarized covariance matrices (SACF, SAXCF)example.m- MATLAB example using these two functions
FORTRAN: Codes fulfill Fortran 90 Standard
Python: Version 3.12 or higher
Python Libraries: matplotlib, numpy
Install Python dependencies via pip:
pip install -r requirements.txtMATLAB: Version R2025b
MATLAB Toolboxes: Matlab Curve Fitting Toolbox (smooth.m), Matlab Signal Processing Toolbox (filtfilt.m)
- Open a Linux terminal in the project root directory
- To compile Fortran code, type:
make- Check
run_examplebinary program in the project root directory
Fortran:
- Compile Fortran codes by using
Makefile - Run the program:
run_examplein the project root directory - Run the Python script:
run_example_plot.pyto visualize results from Fortran - Check for high-resolution output figure
example_Fortran.png
MATLAB:
- Open MATLAB
- Run the main script:
example.mto compute and visualize results
This repository provides Fortran 90 and MATLAB routines for evaluating covariance matrices of Green's functions. The included example codes are for illustrative purposes; for full functionality, users should integrate these subroutines into their own projects. These covariance matrices should be implemented within a Bayesian inversion framework to properly account for uncertainty. Below are figures from a test using simple synthetic waveforms, showing the covariance matrices ACF, AXCF, SACF, and SAXCF.
Copyright (C) 2016-2018,2026 Miroslav Hallo and František Gallovič
This program is published under the GNU General Public License (GNU GPL).
This program is free software: you can modify it and/or redistribute it or any derivative version under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. We would like to kindly ask you to acknowledge the authors and don't remove their names from the code.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
If you use this tools suite, please cite both the original methodology paper (preferred) and the software version as follows:
Hallo, M., Gallovic, F. (2016). Fast and cheap approximation of Green functions uncertainty for waveform-based earthquake source inversions. Geophysical Journal International, 207 (2), 1012-1029. https://doi.org/10.1093/gji/ggw320
Hallo, M., Gallovic, F. (2026). Uncertainty quantification in Bayesian earthquake source inversions, HPC ready routines (v1.3.3) [Software]. Zenodo. https://doi.org/10.5281/zenodo.19343279