pssac是朱露培老師所寫的小程式,是一個特別設計跟gmt參數相同的程式,適合寫在GMT script裡直接繪出sac圖形的有用工具。一年多前嘗試想要編譯成功他,卻一直沒有成功。今年彷彿又聽到大家有使用pssac的需求,於是提筆寫信問朱教授。朱教授熱心的回應,使我終於成功編譯pssac。
首先,你的linux/unix主機必須有gcc任何的c編譯器。
第二,你需要先安裝好GMT;GMT的安裝請參考GMT簡易安裝筆記。新版的GMT已經到4.5.5,但是安裝form大致上是一樣的。
第三,請到朱教授的個人網站下載pssac的原始碼。如果你的GMT版本是4.5以上,還請多下載新的pssac.c取代原本tar裡的檔案。
假設我們安裝好的GMT路徑是/opt/GMT4.5.2,netcdf的路徑為/opt/netcdf-3.6.3:
tar xvf pssac.tar不過直接使用原本的Makefile編譯成功的機會恐怕很少。請修改Makefile成如下的樣子:
cd pssac; mv pssac.c pssac-old.c
wget -c http://www.eas.slu.edu/People/LZhu/downloads/pssac.c
- CC = gcc
- GMT_INC = -I /opt/GMT4.5.2/include -I /opt/netcdf-3.6.3/include
- GMT_LIBS = -L /opt/GMT4.5.2/lib -L /opt/netcdf-3.6.3/lib -lgmt -lgmtps -lpsl -lnetcdf -lm -s
- CFLAGS = -O2 ${GMT_INC}
- pssac: pssac.o sacio.o
- ${CC} -o $@ $@.o sacio.o ${GMT_LIBS} ${CFLAGS}
- clean:
- @rm -f pssac *.o
接著請執行make。如果你有確實的寫對GMT以及netcdf的函式庫位置以及headers的位置,你應該可以看到如下的輸出:
gcc -O2 -I /opt/GMT4.5.2/include -I /opt/netcdf-3.6.3/include -c -o pssac.o pssac.c然而當你想要試著執行他的時候卻出現錯誤訊息:
gcc -O2 -I /opt/GMT4.5.2/include -I /opt/netcdf-3.6.3/include -c -o sacio.o sacio.c
gcc -o pssac pssac.o sacio.o -L /opt/GMT4.5.2/lib -L /opt/netcdf-3.6.3/lib -lgmt -lgmtps -lpsl -lnetcdf -lm -s -O2 -I /opt/GMT4.5.2/include -I /opt/netcdf-3.6.3/include
./pssac: error while loading shared libraries: libnetcdf.so.4: cannot open shared object file: No such file or directory可知pssac執行時期需要libnetcdf.so.4這個函式,利用find指令可以發現這個檔案就在/etc/netcdf-3.6.3/lib裡。原來是系統並不認識他,趕快加進來吧(別忘了切到root身份)!
echo "/opt/netcdf-3.6.3/lib" > /etc/ld.so.conf.d/libnetcdf.conf此時再執行pssac試試看:
echo "/opt/GMT4.5.2/lib" > /etc/ld.so.conf.d/libgmt.conf
ldconfig
Usage: pssac standardGMToptions [SACfiles] [-C[t1/t2]] [-E(k|d|a|n|b)(t[n]|vel)] [-Gr/g/b/c] [-I] [-Msize[/alpha]] [-Q] [-r] [-Sshift] [-V] pssac plots SAC traces. If no SAC file names is provided in the command line, it expects (sacfile,[x,[y [pen]]) from stdin. -C only plot data between t1 and t2 -E option determines (1) profile type: a: azimuth profile b: back-azimuth profiel d: epicentral distance (in degs.) profile k: epicentral distance (in km.) profile n: traces are numbered from 1 to N in y-axis (2) time alignment: tn: align up with time mark tn in SAC head default is the reference time. Others are n= -5(b), -3(o), -2(a), 0-9 (t0-t9) vel: use reduced velocity -G paint amplitudes larger than c with color r/g/b -I integrate the trace before plotting -M multiple traces size: each trace will normalized to size (in y-unit) size/alpha: if alpha<0, use same scale for all traces else plot absolute amplitude multiplied by size*r^alpha where r is the distance range in km -Q square the trace -r remove the mean value in the trace -S shift traces by shift seconds -V plot traces vertically確定可以執行後,把他放到/usr/local/bin裡,這樣所有使用者都可以使用這隻程式啦!
再次感謝朱老師的熱心幫忙!
Share |