First Arrival Seismic Tomography(FAST)是一隻能夠計算二維/三維first arrival tomography的小程式,雖然他已經13歲了(1998年first release),不過到現在還是非常實用。
請下載FAST主程式,也必須下載for g77的patch檔。
請注意這個patch檔(十分感謝Drew Brenders提供這個patch)是必要的,因為作者Colin Zelt當初是在Sun Solaris上開發這隻程式的,沒有這個patch檔將無法在linux上成功編譯。
1. 準備好編譯器以及所需的libraries
- For Debian/Ubuntu users:
- For CentOS/Fedora users: 以我自己的Fedora14為例,套件名稱會像下面這樣:
- For OpenSuSE users: 以我自己的OpenSuSE 11.4為例,套件名稱會像下面這樣:
aptitude install fort77 libf2c make -y
ln -s /usr/bin/f77 /usr/bin/g77
yum install compat-libf2c-34 compat-gcc-34-g77-3.4.6-20.fc14.i686 make -y如果你的版本不同,你需要用yum search找確切的套件名稱。你或許會發現兩套linux對於fortran77的稱呼剛好相反。
ln -s /usr/bin/g77 /usr/bin/f77
ln -s /usr/lib/libg2c.so.0 /usr/lib/libf2c.so.2
yum install -y gcc33-fortran make libg2c33
ln -s /usr/bin/g77-3.3 /usr/bin/g77
ln -s /usr/bin/g77-3.3 /usr/bin/f77
ln -s /usr/lib/libg2c.so.0 /usr/lib/libf2c.so.2
2. 下載FAST以及其patch
cd ; http://terra.rice.edu/department/faculty/zelt/fast.tar.gz
wget -c http://terra.rice.edu/department/faculty/zelt/fast_g77_patch.tar.gz
tar zxvf fast.tar.gz && mv fast fast_g77
tar zxvf fast_g77_patch.tar.gz
rsync -av fast/2d_example_linux/ fast_g77/2d_example/
3. 開始編譯:
我覺得COMPILE_FAST.csh實在寫得很爛,決定寫一個更好一點的script,所以在此先刪除他。
cd fast打完patch應該顯示下列結果:
rm -f COMPILE_FAST.csh
patch -p0 < fast_g77.diff
patching file ../fast_g77/fd/fd.com patching file ../fast_g77/fd/fd.par patching file ../fast_g77/fd/findiff.f patching file ../fast_g77/fd/main.f patching file ../fast_g77/fd/Makefile patching file ../fast_g77/fd/misc.f patching file ../fast_g77/misc/1dvel2.f patching file ../fast_g77/misc/1dvel.f patching file ../fast_g77/misc/2dvel.f patching file ../fast_g77/misc/add2.f patching file ../fast_g77/misc/add.f patching file ../fast_g77/misc/ave2.f patching file ../fast_g77/misc/ave4.f patching file ../fast_g77/misc/ave.f patching file ../fast_g77/misc/difference2.f patching file ../fast_g77/misc/difference.f patching file ../fast_g77/misc/gmtslice_2d.f patching file ../fast_g77/misc/gmtslice.f patching file ../fast_g77/misc/gmtslicep.f patching file ../fast_g77/misc/h2z.f patching file ../fast_g77/misc/inverse_2d.f patching file ../fast_g77/misc/inverse.f patching file ../fast_g77/misc/lambda3.f patching file ../fast_g77/misc/latave.f patching file ../fast_g77/misc/ray.par patching file ../fast_g77/misc/real2int.f patching file ../fast_g77/misc/rec_ascii.f patching file ../fast_g77/misc/rec_binary.f patching file ../fast_g77/misc/rec_deci.f patching file ../fast_g77/misc/rec_diff.f patching file ../fast_g77/misc/rec_noise2.f patching file ../fast_g77/misc/rec_noise.f patching file ../fast_g77/misc/rec_offset.f patching file ../fast_g77/misc/regrid_2d.f patching file ../fast_g77/misc/regrid.f patching file ../fast_g77/misc/resamp.f patching file ../fast_g77/misc/smodel.f patching file ../fast_g77/misc/vz.f patching file ../fast_g77/misc/z2h.f patching file ../fast_g77/ray/blkdat.f patching file ../fast_g77/ray/main.f patching file ../fast_g77/ray/Makefile patching file ../fast_g77/ray/ray.com patching file ../fast_g77/ray/ray.par patching file ../fast_g77/ray/tomo.f patching file ../fast_g77/zslice/main.f patching file ../fast_g77/zslice/MakefileIf you're using Fedora, patching will be failed because Fedora have security concern about command "patch". The easiest solution is to copy patch from other Linux, and replace original patch. 由於個人因素,我覺得作者的Makefile寫得很不好,因此我自己寫了一個小script,開始進行自動編譯:
cd ../fast_g77The script "COMPILE_FAST.sh" is hiding in the source code of this article. 這個COMPILE_FAST.sh威力強大,能自動產生正確的Makefile並進行編譯(if you can't download the script from it, check the source code of this page)。通常只有misc資料夾下的小程式會出現問題,你可以參考misc.log來檢視是否有任何錯誤發生,而這類fortran的問題我無法解決。如果有編譯上的困難,請千萬不要問我,我很討厭fortran。
find . -name Makefile -exec rm {} \;
bash COMPILE_FAST.sh
4. 設定環境變數:
至此你已經完成編譯。現在你只需要把這東西放到/opt裡,再設定環境變數即可:
cd ..; rsync -av fast_g77 /opt/新增(append)幾行到/etc/profile裡:
export FAST="/opt/fast_g77" export PATH="$PATH:$FAST/bin"然後重新登入(re-login),就可以快樂的使用這些指令了。關於fast的操作,請參考Traveltime calculation using FAST.
Share this Link |