Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fk: Add install instructions #126

Merged
merged 6 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions source/fk/fk3.3-v20190618.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
diff --git a/Makefile b/Makefile
index 1915244..62a8f67 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,15 @@
+FC=gfortran
optimize=-O
-FFLAGS=$(optimize) -ffpe-trap=overflow,invalid,denormal
+FFLAGS=$(optimize) -ffpe-trap=overflow,invalid,denormal -ffixed-line-length-none
CFLAGS=$(optimize)
#if SAC library has been installed, uncomment the next two lines
-#CFLAGS=$(optimize) -DSAC_LIB
-#SACLIB=-L$(SACHOME)/lib -lsac -lsacio
+CFLAGS=$(optimize) -DSAC_LIB
+SACLIB=-L$(SACHOME)/lib -lsac -lsacio
#

SUBS = fft.o Complex.o sacio.o
FKSUBS = fk.o kernel.o prop.o source.o bessel.o $(SUBS)
-TARGETS = fk syn st_fk trav sachd
+TARGETS = fk syn st_fk trav sachd fk2mt

all: $(TARGETS)

@@ -27,6 +28,9 @@ sachd: sachd.o sacio.o
trav: trav.o tau_p.o
$(LINK.f) -o $@ trav.o tau_p.o -lm

+fk2mt: fk2mt.o sacio.o radiats.o
+ $(LINK.f) -o $@ $^ -lm
+
bessel.f: bessel.FF
cpp -traditional-cpp $< > $@

diff --git a/sac.h b/sac.h
index f7d8c2f..6e2ff49 100644
--- a/sac.h
+++ b/sac.h
@@ -316,7 +316,7 @@ int wrtsac2(const char *, int, const float *x, const float *y);
SACHEAD sachdr(float, int, float);
void swab4(char *, int);
void ResetSacTime(SACHEAD *);
-int sac_head_inex(const char *name);
+int sac_head_index(const char *name);
int testByte(char *);

/* the following two are in libsac.a */
diff --git a/syn.c b/syn.c
index 57f32c3..ecb9183 100644
--- a/syn.c
+++ b/syn.c
@@ -139,7 +139,7 @@ int main(int argc, char **argv) {
case 1:
if (mtg) {
mt[0][0]=mt[1][1]=mt[2][2] = 1.;
- mt[0][1],mt[0][2],mt[1][2] = 0.;
+ mt[0][1]=mt[0][2]=mt[1][2] = 0.;
} else {
nn = 1;
}
3 changes: 2 additions & 1 deletion source/fk/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fk

:教程贡献者: |田冬冬|\(作者)、
|姚家园|\(审稿)
:教程更新日期: 2021-01-04
:教程更新日期: 2021-01-13

----

Expand All @@ -30,3 +30,4 @@ fk
:hidden:

introduction
install
63 changes: 63 additions & 0 deletions source/fk/install.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
安装
====

1. 下载::

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

2. 解压::

$ tar -xvf fk3.3.tar

将解压得到的 :file:`fk` 文件夹移至 :file:`~/src/` 目录下::

$ mkdir -p ~/src/
$ mv fk ~/src/

3. 修改 fk 源码

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

- :file:`Makefile` 中需要添加 ``FC=gfortran`` 指定使用 gfortran 编译器
- :file:`Makefile` 中需要给 ``FFLAGS`` 加上中 ``-ffixed-line-length-none``
使得 Fortran 一行可以超过 72 字符
- :file:`Makefile` 中第 6—7 行被注释了,所以 ``fk`` 无法使用 SAC 提供的
滤波功能。若 SAC 已安装,则可以注释将第 6—7 行行首的注释符号 ``#`` 去掉
- :file:`Makefile` 中未指定如何编译生成 ``fk2mt`` 文件。需要将 ``fk2mt``
加到变量 ``TARGETS`` 中,并向 :file:`Makefile` 尾部加入如下语句:

.. code-block:: makefile

fk2mt: fk2mt.o sacio.o radiats.o
$(LINK.f) -o $@ $^ -lm
seisman marked this conversation as resolved.
Show resolved Hide resolved

- :file:`syn.c` 第 142 行需改写为 ``mt[0][1]=mt[0][2]=mt[1][2] = 0.;``
- :file:`sac.h` 中 319 行 ``sac_head_inex`` 应改为 ``sac_head_index``

.. note::

为了便于用户使用,我们对 fk 源码做了以上修改,并提供了 patch 文件,供用户使用。
下载 patch 文件 :download:`fk3.3-v20190618.patch`,将其放在 fk 源码目录下,
然后执行如下命令即可修改源码::

$ patch < fk3.3-v20190618.patch
core-man marked this conversation as resolved.
Show resolved Hide resolved

.. note::

我们已经将以上 BUG 报告给原作者,在新版本中这些问题可能会得到修复。

4. 进入源码目录并编译::

$ cd fk/
$ make
seisman marked this conversation as resolved.
Show resolved Hide resolved
$ make clean

5. 修改环境变量,将 fk 路径添加到 **PATH** 中::

$ echo 'export PATH=${HOME}/src/fk/:${PATH}'>> ~/.bashrc
$ source ~/.bashrc

6. 检查安装是否成功

终端键入 ``fk.pl`` 若出现 帮助信息则表示安装成功。