1. Download SeisFlows¶
To run SeisFlows you’ll need a Unix system with Python 2.7, Numpy, Scipy, Obspy and standard Unix utilities. After these prerequisites are in place, from the command line type:
mkdir ~/packages
cd ~/packages
git clone https://github.com/rmodrak/seisflows.git
If you prefer a location other than ~/packages
, modify the commands above and below accordingly.
2. Set environment variables¶
Add the following lines to ~/.bashrc
(modify accordingly, if you are using a shell other than bash):
export PATH=$PATH:~/packages/seisflows/scripts
export PYTHONPATH=~/packages/seisflows
Don’t forget to update any open shells:
source ~/.bashrc
3. Run “system” test¶
Run the following test to make sure everything is working:
~/packages/seisflows/tests/run_test_system
If a ‘’hello’’ message is displayed, the test was successful.
4. Run nonlinear optimization test¶
Run the following test to make sure everything is working:
~/packages/seisflows/tests/run_test_optimize
If the optimization problems are solved in 60 iterations or fewer, the test was successful.
5. Configure and compile SPECFEM2D¶
First, download SPECFEM2D from GitHub:
cd ~/packages
git clone --recursive --branch devel https://github.com/geodynamics/specfem2d.git specfem2d-d745c542
cd specfem2d-d745c542
git checkout d745c542
For now, it is important to work with the exact version specified above (d745c542
). This is necessary because, unlike SPECFEM3D and 3D_GLOBE, SPECFEM2D development is sometimes a bit haphazard, with frequent interface changes.
Next, configure and compile SPECFEM2D using ifort (preferred) or gfortran:
cd ~/packages/specfem2d-d745c542
./configure FC=ifort
make all
(Since make by itself does not compile all the required utilities, be sure to remember to type make all.) For troubleshooting any compilation issues, please view the SPECFEM2D manual and GitHub issues page.
6. Set up checkerboard test¶
Download the starting model and other input files required for the waveform inversion checkerboard test. For simplicity, let’s assume the checkerboard working directory will be placed in ~/tests
(if you prefer a different location, then modify the following commands accordingly):
mkdir ~/tests/
cd ~/tests/
wget --recursive --no-parent --no-host-directories --cut-dirs=2 --reject "index.html*" http://tigress-web.princeton.edu/~rmodrak/2dAcoustic/
A directory ~/tests/checkers
is now being created. Among other files, parameters.py
and paths.py
are being downloaded.
After the download completes, make sure that all paths specified in paths.py
are correct. For example, if you compiled SPECFEM2D somewhere other than ~/packages/specfem2d-d745c542
, you will need to modify the SPECFEM2D_BIN
entry accordingly.
Next, take a minute to view the parameters.py
file and note the close similarity between the first set of parameters and the directory structure of the SeisFlows repository.
7. Run checkerboard test in serial¶
To run the checkerboard test type:
sfclean ; sfrun
within ~/tests/checkers
.
For now, the inversion will run only a single event on only a single processor. Once we verify that everything is working correctly in this case, we can move on to multiple events and multiple processors by modifying parameters.py
.
8. Run checkerboard test in parallel¶
On a laptop or desktop with multiple cores, the work of an inversion can be carried out in parallel. To run the checkerboard example in parallel over events (that is, with multiple event simulations running at the same time on different cores), make the following changes to parameters.py
:
- to invert all available events instead of just one event, change
NTASK
from1
to25
- change
SYSTEM
fromserial
tomultithreaded
- add a parameter
NPROCMAX
and set it to the number of cores available on your machine.
Besides running in parallel over events, the work of an individual event simulation can be parallelized over model regions. See the SPECFEM3D user manual for more information. Both parallelization over events and over model regions can be used at the same time under SeisFlows. The current example, however, illustrates only event parallelism.
Besides serial
and multithreaded
settings for running SeisFlows on laptops and desktops, there are also PBS, SLURM, and LSF options for running on clusters. See here for more information.
9. Visualize inversion results¶
Visualization requires software such as Pylab, Matlab, or Paraview.
With any such software, one approach for plotting SPECFEM2D models or kernels is to interpolate from the unstructured numerical mesh on which the model parameters are defined to a uniform rectangular grid. The Pylab script plot2d illustrates this approach.
Another method is to compute a Delaunay triangulation and plot the model or kernel over the unstructured mesh itself. A Pylab script plot2d_delaunay is available for illustration.
To plot results from the checkerboard example using plot2d
, run the following command from the working directory:
plot2d output/model_init/proc000000_x.bin \
output/model_init/proc000000_z.bin \
output/model_0001/proc000000_vs.bin
(The command line syntax is the same for the other script.) For either script to work, Pylab must be installed and the Pylab backend properly configured. If you prefer visualization software other than Pylab, feel free to use the above scripts for reference in writing your plotting own tools.