ubuntu 20.04 安装 gCAP3D 格林函数 fk3.3 全流程

下载 gCAP3D 全部代码

1 修改 Makefile

FFLAGS = -OCFLAGS = ${FFLAGS}CAP  = cap3D mtdcmp radpttnSUBS = fft.o Complex.o radiats.o grid3d.o futterman.o sacio.o trap.oall: $(CAP)cap3D : %:%.o $(SUBS) cap_sub.o$(LINK.f) -o $@ $^ -L$(SACHOME)/lib -lsac -lsaciomtdcmp: mtdcmp.o$(LINK.f) -o $@ $@.oradpttn: radpttn.o radiats.o$(LINK.c) -o $@ $@.o radiats.o -lm%/mt.all: %/weight.datfor dp in 10 15 20; do cap3D.pl -G${HOME}/data/models/Glib -H0.2 -P300000/65 -Q0.02 -T50/100 -S2/5/0 -D2/1/0.5 -C0.05/0.3/0.02/0.1 -W1 -X10 -Mcus_$dp $*; head -1 $*/cus_$dp.out >> $@; done%/mt.best: %/mt.all(depth.pl lt; $* > $*/depth.ps) >& $@clean:rm -f $(CAP) *.o

上面是 Makefile 全部内容,在最上面增加一行

FC = gfortran -ffixed-line-length-none

把 14 行的 LINK.c 换成 FC,修改后如下

FC = gfortran -ffixed-line-length-noneFFLAGS = -OCFLAGS = ${FFLAGS}SACHOME = /home/ubuntu/sacCAP  = cap3D mtdcmp radpttnSUBS = fft.o Complex.o radiats.o grid3d.o futterman.o sacio.o trap.oall: $(CAP)cap3D : %:%.o $(SUBS) cap_sub.o        $(LINK.f) -o $@ $^ -L$(SACHOME)/lib -lsac -lsaciomtdcmp: mtdcmp.o        $(FC) -o $@ $@.oradpttn: radpttn.o radiats.o        $(LINK.c) -o $@ $@.o radiats.o -lm%/mt.all: %/weight.dat        for dp in 10 15 20; do cap3D.pl -G${HOME}/data/models/Glib -H0.2 -P300000/65 -Q0.02 -T50/100 -S2/5/0 -D2/1/0.5 -C0.05/0.3/0.02/0.1 -W1 -X10 -Mcus_$dp $*; head -1 $*/cus_$dp.out >> $@; done%/mt.best: %/mt.all        (depth.pl lt; $* > $*/depth.ps) >& $@clean:        rm -f $(CAP) *.o

另外还要给出 SACHOME 的位置,进行这些操作前需要安装好 SAC 软件。

2 修改 cap3D.pl

#!/usr/bin/env perl## A user-friendly PERL interface to the CAP3D source inversion code cap3D## written by Lupei Zhu, 3/6/1998, Caltech# # revision history#6/18/2001add usage and documentation.#11/05/2012add isotropic and CLVD search (-J).#1/13/2013add option to output potency tensor parameters.#04/15/2014add option to use 3D Green's function (-Y).#05/05/2015no need of initial magnitude input.## these are the only things one need to change based on the site installation$home = $ENV{HOME};# my home directoryrequire "$home/gCAP3D/cap_plt.pl";# include plot script#================defaults======================================$cmd = "cap3D";$green = "$home/gCAP3D/models/Glib";#green's function location$ngf = 3;#number of fundamental sources of 1D FK Green's functions for DC$eloc = ".";$repeat = 0;$bootstrap = 0;$fm_thr = 0.01;$appdx='';$disp=0;$mltp=0;$weight="weight.dat";

修改第17行为本地cap_plt.pl的位置,第21行本地格林函数的位置。

3 可能出现的问题

修改以上两项后,make 一下,会提示上图的错误。

百度一在圈,有人说是sac101.6a版本有问题,换成sac102就没问题了。

重新安装 102 版 sac 问题解决,编译通过。

把 gCAP3D 的路径加入到 PATH,source .bashrc 就可以使用了。

4 测试

5 安装 fk

下载 fk 源代码

wget http://www.eas.slu.edu/People/LZhu/downloads/fk3.3.tar

解压缩

tar -xvf fk3.3.tarmkdir ~/srcmv fk ~/srccd srccd fk

修改 Makefile 文件,Makefile 里的文件有好多需要修改的,

fk3.3(下载于 2021-01-13,软件包中文件的最新日期为 2019-06-18)的原始代码存在一些问题,因而需要做一些小修改方可使用。主要修改如下:

  • Makefile 中需要添加 FC=gfortran 指定使用 gfortran 编译器
  • Makefile 中需要给变量 FFLAGS 加上 -ffixed-line-length-none 使得 Fortran 一行可以超过 72 字符
  • Makefile 中变量 FFLAGS 里的 -ffpe-trap=overflow,invalid,denormal 参数需要删除
  • Makefile 中第 6—7 行被注释了,所以 fk 无法使用 SAC 提供的滤波功能。若已安装 SAC ,则可以将第 6—7 行的行首注释符号 # 去掉,并给变量 SACLIB 加上 -no-pie 参数(若操作系统无法使用该参数,手动删除即可)
  • Makefile 中未指定如何编译生成 fk2mt 文件。需要将 fk2mt 加到变量 TARGETS 中,并向 Makefile 尾部加入如下语句:
  • fk2mt: fk2mt.o sacio.o radiats.o $(LINK.f) -o $@ $^ -lm
  • syn.c 第 142 行需改写为 mt[0][1]=mt[0][2]=mt[1][2] = 0.;
  • sac.h 中 319 行 sac_head_inex 应改为 sac_head_index

参考 地震 “学” 软件中 fk 的修改方法,并且给出了 patch 文件,直接 patch 就可以了

patch < fk3.3-v20190618.patchmakemake clean

再把 fk 的路径加入到 PATH 中

export PATH=$SACHOME/bin:/home/ubuntu/gCAP3D:/home/ubuntu/src/fk/:$PATH

测试

(base) ubuntu@ubuntu:~$ fk.plUsage: fk.pl -Mmodel/depth[/f_or_k] [-D] [-Hf1/f2] [-Nnt/dt/smth/dk/taper] [-Ppmin/pmax[/kmax]] [-Rrdep] [-SsrcType] [-Uupdn] [-Xcmd] distances ...-M: model name and source depth in km. f triggers earth flattening (off), k indicates that the 3rd column is vp/vs ratio (vp).    model has the following format (in units of km, km/s, g/cm3):        thickness vs vp_or_vp/vs [rho Qs Qp]        rho=0.77 + 0.32*vp if not provided or the 4th column is larger than 20 (treated as Qs).        Qs=500, Qp=2*Qs, if they are not specified.        If the first layer thickness is zero, it represents the top elastic half-space.        Otherwise, the top half-space is assumed to be vacuum and does not need to be specified.        The last layer (i.e. the bottom half space) thickness should be always be zero.-D: use degrees instead of km (off).-H: apply a high-pass filter with a cosine transition zone between freq. f1 and f2 in Hz (0/0).-N: nt is the number of points, must be 2^n (256).    Note that nt=1 will compute static displacements (require st_fk compiled).              nt=2 will compute static displacements using the dynamic solution.    dt is the sampling interval (1 sec).    smth makes the final sampling interval to be dt/smth, must be 2^n (1).    dk is the non-dimensional sampling interval of wavenumber (0.3).    taper applies a low-pass cosine filter at fc=(1-taper)*f_Niquest (0.3).-P: specify the min. and max. slownesses in term of 1/vs_at_the_source (0/1)    and optionally kmax at zero frequency in term of 1/hs (15).-R: receiver depth (0).-S: 0=explosion; 1=single force; 2=double couple (2).-U: 1=down-going wave only; -1=up-going wave only (0).-X: dump the input to cmd for debug (fk).Examples* To compute Green's functions up to 5 Hz with a duration of 51.2 s and at a dt of 0.1 s every 5 kms for a 15 km deep source in the HK model, usefk.pl -Mhk/15/k -N512/0.1 05 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80* To compute static Green's functions for the same source, usefk.pl -Mhk/15/k -N2 05 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 > st.outor usefk.pl -Mhk/15/k -N1 05 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 > st.out* To compute Green's functions every 10 degrees for a 10 km deep source in the PREM model.fk.pl -Mprem/10/f -N512/5 -H0.01/0.02 -D 10 20 30 40 50 60Author: Lupei Zhu, 02/15/2005, SLU

这步安装也完成了。

发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章