Toccata in Nowhere.

Linux / macOS 安装 CPS (Computer Programs in Seismology)

2020.09.13

CPS(Computer Programs in Seismology) 是由 Saint Louis University Earthquake Center 创建的地震工具包,提供简单易用的地震理论分析工具。本文介绍其安装方式。

下载与解压缩

选定一个安装目录,可以在用户文件夹根目录下新建 ~/seismicTool/ 文件夹。

使用wget

wget http://www.eas.slu.edu/eqc/eqc_cps/Download/NP330.Dec-31-2019.tgz

解压:

tar -zxvf NP330.Dec-31-2019.tgz

解压后为 PROGRAMS.330 文件夹。

cd PROGRAMS.330

进行编译前的检查

使用解压后的文件夹 中的 ./Setup进行检查校验:

$ ./Setup
Checking for existence of bin and lib directories
Creating Directory bin
Creating Directory lib
Usage: Setup SOL WIN32 SOL-EGCS LINUX LINUX64 CYGWIN OSX
   LINUX40    Linux with gcc/gfortran compilers
   LINUX6440  Linux 64 bit with gcc/gfortran compilers
   OSX40      Apple  with gcc/gfortran compilers
   OSX40-32   Apple  with 32-bit gcc/gfortran compilers
 ----- not tested in a long while -----
   SOL        SUN Solaris Compilers
   SOL-GNU    SUN Solaris with gcc/g77 compilers
   CYGWIN     CYGWIN 98/NT/2K/XP gcc/g77 Compilers
   CYGWIN40   CYGWIN 98/NT/2K/XP gcc/gfortran Compilers

选择系统,例如 macOS 选择 OSX40;Linux 选择 LINUX6440,注意一下系统指令集位数32还是64。 以 macOS 为例再次运行 ./Setup OSX40

$ ./Setup OSX40
Checking for existence of bin and lib directories
Directory bin exists
Directory lib exists
OSX gcc4.? gfortran for Apple
Copying VOLI/src/Makefile.OSX40 VOLI/src/Makefile
Copying VOLII/src/Makefile.OSX40 VOLII/src/Makefile
Copying VOLIII/src/Makefile.OSX40 VOLIII/src/Makefile
Copying VOLIV/src/Makefile.OSX40 VOLIV/src/Makefile
Copying VOLV/src/Makefile.OSX40 VOLV/src/Makefile
Copying VOLVI/src/Makefile.OSX40 VOLVI/src/Makefile
Copying VOLVII/src/Makefile.OSX40 VOLVII/src/Makefile
Copying VOLVIII/src/Makefile.OSX40 VOLVIII/src/Makefile
Copying VOLVIII/gsac.src/Makefile.OSX40 VOLVIII/gsac.src/Makefile
Copying VOLIX/src/Makefile.OSX40 VOLIX/src/Makefile
Copying VOLX/src/Makefile.OSX40 VOLX/src/Makefile
Copying CALPLOT/src/cmd.unx/Makefile.OSX40 CALPLOT/src/cmd.unx/Makefile
Copying CALPLOT/src/clib.unx/Makefile.OSX40 CALPLOT/src/clib.unx/Makefile
Copying CALPLOT/src/flib.unx/Makefile.OSX40 CALPLOT/src/flib.unx/Makefile
Copying CALPLOT/src/util/Makefile.OSX40 CALPLOT/src/util/Makefile
Copying IRIS/rdseedv5.3.slu/Makefile.OSX40 IRIS/rdseedv5.3.slu/Makefile
Copying IRIS/DOCOMPILE.OSX40 IRIS/DOCOMPILE
Copying CALPLOT/src/XVIG/src/Makefile.OSX40 CALPLOT/src/XVIG/src/Makefile
Copying CALPLOT/testf/Makefile.OSX40 CALPLOT/testf/Makefile
Copying CALPLOT/testc/Makefile.OSX40 CALPLOT/testc/Makefile
Copying CALPLOT/Utility/Makefile.OSX40 CALPLOT/Utility/Makefile
The proper Makefiles have been installed for your Operating System
Verify that these are correct with respect to compilers, flags
and libraries

If everything is correct, enter the command
./C for the complete distribution

Documentation is in the directory DOC in PDF format

编译

执行 ./C,等待编译完成。

添加路径

编译生成的可执行文件,即程序位于 PROGRAMS.330/bin 中,需要将该路径添加到 bash 的程序路径中。

可以先查询一下文件夹所在的路径

pwd

pwd 会显示当前文件夹路径,复制这个路径,并添加到 .bashrc.bash_profile.zshrc 中,注意其中的 <Folder Path> 需要改成前面复制的路径名:

export CPSPATH=<Folder Path>
export PATH=${CPSPATH}/bin:${PATH}

刷新 rc 文件(或其他shell描述文件):

source ~/.bashrc

测试

$ surf96
  Enter h,dcl,dcr
       h = fraction change in period to get group vel
             (0.005 is reasonable)
       dcl, dcr are phase velocity increment in root
             search for Love and Rayl respectively

显示如上就安装完成啦

致谢

本文感谢ZH. Song老哥🐮🍺

Reference

Computer Programs in Seismology