使用ubuntu18.04安装SWIT-1.0地震波形反演工具箱

### Step 1:  gfortran & OpenMPI


sudo apt-get install build-essential


sudo apt install gfortran

# Download the OpenMPI package, 
推荐浏览器进http://www.open-mpi.org/software/ompi 下载较快


wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.1.tar.gz 


tar xvfz openmpi-4.1.1.tar.gz


cd openmpi-4.1.1

# Configure & install OpenMPI (this would take quite a while)


./configure --prefix=/usr/local/openmpi CC=gcc FC=gfortran


make

sudo make install

# Add path to ~/.bashrc


echo export PATH=/usr/local/openmpi/bin:$PATH >> ~/.bashrc


source ~/.bashrc

# Check
which mpirun
```

### Step 2 : Python & Compile fd2dmpi
# Install Python dependencies (the USTC mirror is used here).

使用python3进行下载依赖项,不然会报错
pip3 install numpy obspy scipy matplotlib multiprocess PySimpleGUI psutil Pillow ls-i https://pypi.mirrors.ustc.edu.cn/simple/
m

pip3有时候安装个别项目也会报错 可以单独一个一个安装试试或者换源,有些依赖项也依赖别的项,比如PySimpleGUI还需要提前安装tkinter否则也装不上

如Pillow安装时failed building wheel for pillow

可以

sudo apt update


sudo apt install -y python3-dev python3-pip libjpeg-dev zlib1g-dev libtiff-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev

python3 -m pip install --upgrade pip

pip3 install pillow
# Complie the fd2dmpi forward solver with gfortran & mpif90.


cd /your/own/path/to/SWIT-1.0/fd2dmpi/


rm *.mod;  会显示无*.mod文件不管

make clean;

make

如果出现gfortran: error: unrecognized
command line option '-fallow-argument-mismatch'
did you mean '-Wno-argument-mismatch'?
Makefile:48: recipe for target '
obj/global.o' failed
make: *** [.obj/global.o] Error 1

是由于gfortran版本不支持

此时可以更新版本或者修改Makefile

vim Makefile.config

找到第48行,删除-fallow-argument-mismatch

保存退出

然后make clean

make

# Add paths of fd2dmpi & Python toolbox to ~/.bashrc 


echo export PATH=/your/own/path/to/SWIT-1.0/bin:$PATH >> ~/.bashrc


echo export PYTHONPATH=/your/own/path/to/SWIT-1.0/toolbox >> ~/.bashrc


source ~/.bashrc

# Check the solver 
which fd2dmpi

# Check the Python toolbox in a Python Shell 
import base, inversion, preprocess, postprocess, solver, tools 可以不用check直接下一步
```

### Step 3 : Run the FWI code

Once all the Python dependencies have been installed and the solver fd2dmpi is compiled successfully, and the envrionment paths have been added to ~/.bashrc.  There are two ways to run the SWIT-1.0. One option is to run via the provided GUI, and another option is to run via the Python script. The former way is very helpful for the beginner of FWI.

Option 1: run via the GUI

```bash
cd /your/own/path/to/SWIT-1.0/toolbox/
python3 runswit_Linux.py   # python runswit_MacOS.py    
30b8f0c4360a4c5d9c0435cfb4ff4c14.png

就会出现界面了 

如果直接python可能会出现File "runswit_Linux.py", line 372
print(f'** Error {E} **')
٨
SyntaxError: invalid syntax
```

如果使用了python3出现Traceback (most recent call last):
File "runswit_Linux.py", line 19, in ‹module> import PySimpleGUI as sg
File "/home/sk/. local/Lt/python3.6/stte-packages/PyStmpleGUI/_tntt_•Py",
line 1, in ‹module>
from •PystmpleGUI import *
File "/home/sk/. local/lib/python3.6/site-packages/PyStmpleGUI/PySimpleGUI.py
",line 83, in snodulesimport tkinter as tk
ModuleNotFoundError: No module named 'tkinter'

表明没有tkinter板块

sudo apt update
sudo apt install python3-tk

Option 2: run via Python scripts

```bash
cd /your/own/path/to/SWIT-1.0/examples/case-XX/
python3 SWIT_workflow.py  # Please modify paths before running  
```

 

## Structure & Workflow

The developed SWIT-1.0 package contains three parts that work intimately, including the Forward & Adjoint Solvers, the inversion toolbox, and the GUI toolbox.

<img src="./doc/Structures.png" style="zoom:20%;" />

 

 

  • 10
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值