2011年7月28日 星期四

Wanna use zplot? Give up!!

If you concern about Rayinvr, you can probably find out there is a program named zplot. It's 20-years-old already, so you can never compile it successfully without modifying those codes.

I've been trying compiling zplot for 2 days, I failed on all Linux distributions. I tried to email to Dr. Zelt about the issue, and these are his reply:

As my web page clearly states, I do not help people install the code on their computers, since I don't know
about such things.

But have a look at the Linux patch on my rayinvr web page, maybe it will help you.

http://terra.rice.edu/department/faculty/zelt/rayinvr.html
My reply is:
Hi Prof. Zelt,
Thanks for your answer.

I've read your pages three times, fully understood what are provided by the page, then asked your help.

The linux patch wrote by Scott is to modify your fortran 77 code and Makefile, it works on rayinvr to make sure the syntax can be recognized by f77/f2c compiler in modern Linux systems, and it doesn't help with zplot at all.

I'm not a student nor a researcher, I'm just a linux admin and java programmer and try to help both seismic program authors and users. The more people know and use your program, the more feedback and fame you have. If a user can't even compile it, probably there is no future story.

Last night I spent three hours to check the error messages from f77 in all linux distributions, I'm not a f77 expert but I knew it due to the syntax of codes, and I don't understand fortran at all. Just hope if Dr. Scott and you would help us through this if you are available.

Thankyou.
And his reply was pretty powerful:
Sorry, I've already told you I don't know how to help you, and I don't have the time.
I do not know much about fortran compilers or makefiles.

This code has been available for 20 years, I am not concerned about its future.

My suggestion is to google search for other rayinvr users, and ask them for help.

Good luck.

So give up! Don't waste your time on it. Zplot's already dead since the author gave it up.

這就是標準的科學家阿,如果你的程式有人用,就不會20年程式碼不變了...恐怕該google的是他吧(茶)

Share

2011年7月27日 星期三

Rayinvr installation on Linux

Rayinvr是一隻能夠計算二維走時以及振幅modeling的小程式,相信許多玩RayGUI的朋友都知道他。只是許多人只是想要用這隻程式,並不想要真正用到這麼大型的程式。你可以下載Rayinvr原始碼,或是直接連到Rayinvr的網頁

不過因為大部分的使用者並不能成功編譯這隻程式。主要原因當然是萬惡的Fortran77,而作者也只靠fortran77來撰寫程式,這使得許多人沒有如此老舊的編譯器及古董級函式庫,根本無法成功編譯或執行。有些人退而求其次試用intel的fortran編譯器,可是這會變得讓程式只能在自己的系統上跑,我非常不贊成用這類型的編譯器。幸好Scott Pearse救了作者 Colin Zelt一命 -- Scott寫了一個patch讓新一代的地球物理學家也能使用這隻程式,本文的目的就是紀錄這隻程式如何使用,並幫助各位成功安裝rayinvr。

1. 準備好編譯器以及所需的libraries

  • For Debian/Ubuntu users:
  • aptitude install fort77 libf2c -y
    ln -s /usr/bin/f77 /usr/bin/g77
  • For CentOS/Fedora users:
  • 以我自己的Fedora14為例,套件名稱會像下面這樣:
    yum install compat-libf2c-34 compat-gcc-34-g77-3.4.6-20.fc14.i686 -y
    ln -s /usr/bin/g77 /usr/bin/f77
    ln -s /usr/lib/libg2c.so.0 /usr/lib/libf2c.so.2
    如果你的版本不同,你需要用yum search找確切的套件名稱。你或許會發現兩套linux對於fortran77的稱呼剛好相反。

2. 下載rayinvr以及patch

cd ; wget -c http://terra.rice.edu/department/faculty/zelt/rayinvr.tar.gz
wget -c http://terra.rice.edu/department/faculty/zelt/rayinvr_g77_patch.tgz
tar zxvf rayinvr.tar.gz && tar zxvf rayinvr_g77_patch.tgz
cp rayinvr_g77_patch/rayinvr_g77.diff rayinvr_g77_patch/build_all.bash rayinvr/

3. 開始編譯:

cd rayinvr/
sed -i 's/usr\/X11R6\/lib/usr\/lib\/X11/g' rayinvr_g77.diff
sed -i 's/usr\/X11R6\/include\/X11/usr\/include\/X11/g' rayinvr_g77.diff
patch -p0 < rayinvr_g77.diff
打完patch應該顯示下列結果:
patching file misc/iseis.f
patching file misc/order_picks.f
patching file misc/phercount.f
patching file misc/reciprocity2.f
patching file misc/reciprocity.f
patching file misc/resample.f
patching file misc/smooth_picks.f
patching file misc/tx2pois.f
patching file misc/tx2rec.f
patching file misc/txmatch.f
patching file misc/txoffset2.f
patching file misc/txoffset.f
patching file misc/txphase.f
patching file misc/txshift.f
patching file misc/vex.f
patching file misc/xshot.f
patching file pltlib/pltlib.f
patching file pltsyn/Makefile
patching file pltsyn/pltsec.f
patching file rayinvr/main.f
patching file rayinvr/Makefile
patching file rayinvr/plt.f
patching file rayinvr/rngkta.f
patching file rayinvr/trc.f
patching file rayplot/Makefile
patching file rayplot/rayplot.f
patching file tramp/amp.f
patching file tramp/Makefile
patching file tramp/plt.f
patching file tramp/rngkta.f
patching file tramp/trc.f
patching file vmodel/Makefile
patching file vmodel/plt.f
另外建議大家額外在補個增加解析度的patch上來:
wget -c http://seismic.ocean.dal.ca/pwp_wiki/static/upload/rayinvr_hiprecision.diff
patch -p0 < rayinvr_hiprecision.diff
打完patch正常結果應該如下:
patching file read.me.precision
patching file vmodel/vmodel.par
patching file vmodel/main.f
patching file rayinvr/main.f
patching file rayinvr/rayinvr.par
patching file misc/v2c.com
patching file misc/v2c.par
patching file misc/rayinvr.par
patching file misc/v2c.f
patching file misc/c2v.f
patching file misc/README
patching file misc/dmplstsqr.f
patching file examples/setup9
patching file examples/d9.in
patching file examples/tx9.in
patching file examples/r9.in
patching file examples/v9.in
patching file examples/vm9.in
開始進行自動編譯:
mkdir bin
./build_all.bash | tee rayinvr.log 2>&1
你可以參考rayinvr.log來檢視是否有任何錯誤發生。如果有,請把這個log寄給Colin Zelt,然後他會告訴你:『I do not help people install the code on their computers, since I don't know about such things.』。也千萬不要寄給我,我很討厭fortran。

4. 設定環境變數:
至此你已經完成編譯。現在你只需要把這東西放到/opt裡,再設定環境變數即可:

cd ..; rsync -av rayinvr /opt/
新增(append)幾行到/etc/profile裡:
export Rayinvr="/opt/rayinvr"
export PATH="$PATH:$Rayinvr/bin"
			
然後重新登入(re-login),就可以快樂的使用這些指令了。關於rayinvr的操作,請參考射線追縱法與時間反演法的使用

後記:
1. I HATE fortran...想退休了,不想在寫文章描述如何debug該死的fortran。拜託新一代的地球物理學家,麻煩好好學fortran以外的語言...別葬送你們的青春在fortran上!
2. Fedora的使用者跑到patch -p0 < rayinvr_g77.diff可能會出現下列錯誤:

patch: **** rejecting target file name with ".." component: ../rayinvr_g77/misc/iseis.f
原因或許出在先前有cracker利用patch漏洞可任意使用../..來當作檔案路徑,理論上這應該是所有linux的問題,但只有Fedora出現,恐怕真的是Fedora比較安全@@...
解決的方法很簡單,從非Fedora的linux上複製/usr/bin/patch給Fedora服用即可。
3. 至於另一個程式zplot,請參考Wanna use zplot? Give up!!一文。

Share