Alpha Linux への GMT3.3.5 と netcdf-3.4 のインストール 02/02/06 追記 01/01/11 改訂 00/11/29 第1稿 ■インストールを確認した distribution(02/02/06 の追記はこの部分です) 実際にこの手法でインストールできることを確認した Alpha Linux の distribution は次の通りです。 ・PowerLinux 1.0(Visual Technology 製の RedHat 5.2 ベースの distribution) ・Vine 2.1CR for alpha ■注意すべき点 1. Alpha 特有の問題(01/01/11 の改訂はこの問題に関する部分です) Alpha CPU は IEEE で規定された +-Inf、NaN 等の例外処理がハードウェアでサポート されていませんので、それに対処する C compiler のオプションを指定してやらねばなり ません。と書いていますが、僕は計算機に弱いのでちゃんと理解していません。これは 検索エンジンで見つけたページ(Stataboware で高名な後藤さんの「Linux/Alpha 入門」 のページ) http://www.linet.gr.jp/lswg/990625/Alpha/tsld019.htm に書いてあったことです。具体的には ・GNU gcc ではオプション -mieee ・Compaq ccc ではオプション -ieee を指定してやります。これを指定して netcdf と GMT を compile してやらないと、例え ば GMT3.3.5/examples/ex15 にあるサンプルスクリプトを実行すると Floating point exception というエラーが出て、絵を描いてくれません 2. compiler の選択 GMT 本体の compile 時には gcc よりも Compaq の ccc を使った方が、お絵描きに よっては劇的に速くなります。 netcdf の compile は gcc + g77 + g++ (GNU compilers) ccc + fort + cxx (Compaq compilers) のどちらでやっても実行速度の違いはほとんどありませんでした。 詳しくは下記の表をどうぞ。 表:速度比較一覧 GMT3.3.5 job01.csh job02.csh job15.csh job19.csh ccc 3.04 12.72 7.20 5.36 gcc 7.52 1:03.44 22.91 24.63 ※job01.csh、job02.csh、job15.csh、job19.csh はそれぞれ GMT3.3.5 の example の 01、02、15、19。 ※数字は実時間(秒)。 ※数字は以下のようにして計った。 % set time = 1 % job02.csh 11.152u 0.528s 0:12.72 91.7% 0+0k 0+0io 2771pf+0w ↑ ↑ ↑ ユーザー時間 | | システム時間 | 実時間 ※Compaq の Linux 用 Fortran compiler(fort)、C compiler(ccc)、C++ compiler(cxx) とその関連 library などは、教育目的や「熱狂的なユーザー(?)」に限り、使用条件を 了解した上で Compaq のホームページから無償ダウンロードできます。 3. 海岸線などのデータの置き場所についての注意 /usr/localで GMT_full.tar.gz GMT_high.tar.gz GMT_share.tar.gz を展開すると、/usr/local/GMT3.3.5/share ではなく /usr/local/share に海岸線などのデータが置かれます。これらのファイルはサイズが大きく、ハードディス クを圧迫するので、異なるバージョンを混在させる環境で共有させることを意図している のかな、と想像しています。 しかし GMT3.3.5 はデフォルトでは、海岸線などのデータが /usr/local/GMT3.3.5/share に置かれていることを想定しています。なので、何もしないと、海岸線を描かせようとし ても、「海岸線のデータがあれへんで」と文句を言われてしまいます。具体的には pscoast: Error: No configuration file /usr/local/GMT3.3.5/share/coastline.conf available! と言われます。この warning はちょっと舌足らずで、補ってやると、「default では海 岸線のデータは/usr/local/GMT3.3.5/share/ に置くんやけど、そこにはあれへんで。ほ んで、別の場所に置くときは /usr/local/GMT3.3.5/share/coastline.conf っちゅう設定 ファイルに置き場所を書くことになっとんやけど、そのファイルもあれへんで」と言って いるのです。 そこで、 /usr/local/GMT3.3.5/share/coastline.conf というファイル中に(これは空っぽのファイルすら用意してないので、全く自分で作って やる必要があります)、 /usr/local/share と海岸線などのデータの置き場所を書いてやって、GMT に置き場所を知らせてやります。 これで大丈夫です。 もちろん海岸線などのデータを /usr/local/GMT3.3.5/share に置くか、symbolic link を張る、という手もあります。なお、海岸線のデータの置き場所は compile 時には必要 ない情報なので、この処置は compile がすんだあとに行っても大丈夫です。 以上の情報は、install_gmt で対話的にインストールしている時に、install_gmt が教 えてくれました。 --------------------------------------------------------------------------- ■インストール作業の実際 1. ftpサイトからファイルをとってくる GMTを使うにはnetcdfというlibraryが必要です。 netcdfは ftp.eos.hokudai.ac.jp/pub/gmt/netcdf より netcdf-3.4.tar.Z を、GMTは ftp.eos.hokudai.ac.jp/pub/gmt より GMT3.3.5_doc.tar.gz GMT3.3.5_progs.tar.gz GMT3.3.5_scripts.tar.gz GMT3.3.5_suppl.tar.gz GMT3.3.5_web.tar.gz GMT_full.tar.gz GMT_high.tar.gz GMT_share.tar.gz triangle.tar.gz install_gmt をとってきます。 GMT3.3.5 では日本語のフォントを使うことができますが、日本語フォントと英字 フォントを(1つのコマンド中で)混在させることはできません。それを可能にする patch GMT3.3.5-j.patch が http://plaza26.mbn.or.jp/~higamasa/gmt/ にありますので、頂いてきます。作者の檜垣さんに感謝いたします。 2. netcdf-3.4 のインストール netcdf-3.4.tar.Z を展開すると INSTALL という文書があります。それをよく読みま しょう。install の手順と、各種 OS に対応した適切な compile option を使うための、 環境変数設定の実例が載っています。Linux の場合の設定例もちゃんと書いてありますの で、その記述に従います。 以下に、Fortran compiler として ・g77 を使う場合 ・fort77 を使う場合 ・Compaq の Fortran compiler の fort を使う場合 ※Compaq の Linux 用 Fortran compiler(fort)、C compiler(ccc) と その関連 library などは、教育目的や「熱狂的なユーザー(?)」に限 り、使用条件を了解した上でCompaq のホームページから無償ダウンロード できます。 の3通りを書いておきます。この例では、root の shell は csh や tcsh などの C shell 系である、としています。 以下の例で、hogehoge には netcdf-3.4.tar.Z が置いてあるディレクトリ名が入りま す。 ・compiler として gcc + g77 + g++ を使う場合 # /bin/csh (← shellがcsh系でなければcshに変更) # # cd /usr/local # # gzip -cd hogehoge/netcdf-3.4.tar.Z | tar xvf - # # setenv CC /usr/bin/gcc # setenv CPPFLAGS -Df2cFortran # setenv CFLAGS "-g -mieee" # setenv FC /usr/bin/g77 # setenv FFLAGS "-g -Wno-globals" # setenv CXX /usr/bin/g++ # # cd netcdf-3.4/src # ./configure # make # make test ※(make test でエラーは出ませんでした) # make install # # cd /usr/local # ln -sf netcdf-3.4 netcdf (← これは趣味の問題です) ・compiler として gcc + fort77 + g++ を使う場合 # /bin/csh (← shellがcsh系でなければcshに変更) # # cd /usr/local # # gzip -cd hogehoge/netcdf-3.4.tar.Z | tar xvf - # # setenv CC /usr/bin/gcc # setenv CPPFLAGS -Df2cFortran # setenv CFLAGS "-g -mieee" # setenv FC /usr/bin/fort77 # setenv FFLAGS "-g -Nx400 -w" # setenv CXX /usr/bin/g++ # # ./configure # make # make test ※(make test でエラーは出ませんでした) # make install # # cd /usr/local # ln -sf netcdf-3.4 netcdf (←これは趣味の問題です) ・compiler として Compaq の ccc + fort + cxx を使う場合 # /bin/csh (← shellがcsh系でなければcshに変更) # # cd /usr/local # # gzip -cd hogehoge/netcdf-3.4.tar.Z | tar xvf - # # setenv CC /usr/bin/ccc # setenv CPPFLAGS -DNDEBUG # setenv CFLAGS "-ieee -O2" # setenv FC /usr/bin/fort # setenv FFLAGS "-O2 -assume no2underscores" # setenv CXX /usr/bin/cxx # # ./configure # make # make test ※(make test でエラーが出ますが気にしない→下記参照) # make install # # cd /usr/local # ln -sf netcdf-3.4 netcdf (←これは趣味の問題です) ※Alpha CPU の場合、C compiler にIEEE で規定された例外処理に関するオプションを つけるという情報は http://www.linet.gr.jp/lswg/990625/Alpha/tsld019.htm で知りました。これは Stataboware という Alpha Linux ディストリビューションで 高名な後藤さんのページでした。後藤さんに感謝いたします。 ※Compaq の ccc + fort + cxx を使う場合は make test 時に下記のエラーが出ますが、 実害はないようです。 make[2]: *** [test.nc] Floating point exception make[2]: *** Deleting file `test.nc' make[2]: Leaving directory `/usr/local/netcdf-3.4/src/nc_test' make[1]: *** [subdir_target] Error 1 make[1]: Leaving directory `/usr/local/netcdf-3.4/src' make: *** [nc_test/test] Error 2 INSTALL を読んでみると、いろんなプラットフォームで make test 時にエラーが出る ようです。 ※make test 時のエラーに関しては、次のホームページで情報を得ました。ありがとうご ざいます。 ・筑波大の堀さんのホームページ http://air.geo.tsukuba.ac.jp/~eddie/freebsd/doc-gmtinst.html ・九州大学の上椙さんのホームページ http://jupiter.geo.kyushu-u.ac.jp/~uesugi/gmt.html ※Compaq の fort を使う場合 -assume no2underscores というオプションが必要という 情報は ・地球流体電脳ライブラリーの「電脳 davis プロジェクト」のメーリングリストの 堀之内さんの投稿 http://dennou-t.ms.u-tokyo.ac.jp/library/davis/ml/2000/msg00443.html で知りました。ありがとうございます。 3. GMT3.3.5 のインストール ftp サイトに、対話的にインストールを行うための install_gmt というシェルスクリ プトが用意されています。それを使うことにします。 以下の例で、hogehoge には *.tar.gz が置いてあるディレクトリ名が入ります。 まず、アーカイブファイルを展開します。 # cd /usr/local # # tar xvzf hogehoge/GMT3.3.5_doc.tar.gz # tar xvzf hogehoge/GMT3.3.5_progs.tar.gz # tar xvzf hogehoge/GMT3.3.5_scripts.tar.gz # tar xvzf hogehoge/GMT3.3.5_suppl.tar.gz # tar xvzf hogehoge/GMT3.3.5_web.tar.gz # tar xvzf hogehoge/GMT_full.tar.gz # tar xvzf hogehoge/GMT_high.tar.gz # tar xvzf hogehoge/GMT_share.tar.gz # tar xvzf hogehoge/triangle.tar.gz 次に、Compaq の C compiler である ccc の オプションとして、例外処理のための -ieee と、(必須ではないですが)最適化のための -O2 をつけるための細工をします。 どうしてよいかよく分からなかったので、GMT3.3.5/configure を直接エディタでいじ ることにしました。1486行目の CC_OPT=$OPTGO を CC_OPT=$OPTG'-ieee -O2' に変えます。なお、gcc でcompile する場合は(ccc の場合よりずっと遅い binary ができますが)、GMT3.3.5/configure をいじらずともきちんと Alpha CPU を使った システムだということを認識して オプション -mieee を勝手につけてくれます。 せっかくですので 檜垣さん作の日本語フォント・英字フォント混在を可能にする patch をあてておきましょう。 # cd GMT3.3.5 # patch -p0 < hogehoge/GMT3.3.5-j.patch あとは、対話的にインストールを行うための install_gmt というシェルスクリプト でインストールしましょう。C compiler は何を使うか? ときいてくるところでは ccc と答えましょう。 # cd .. # cp hogehoge/install_gmt . # chmod +x install_gmt # # ./install_gmt ・ ・ (install_gmt の質問に答えながら対話的にインストール) ・ ・ # # echo /usr/local/share > GMT3.3.5/share/coastline.conf (↑ 海岸線などのデータの置き場所を教えてやります) --------------------------------------------------------------------------- ■ install_gmt との対話の中身 [kakehi@sc210 local]# ./install_gmt +++ Will expand *.bz2 files made with bzip2 +++ ==> Enter make utility to use [make]: ==> Enter print command to use [lpr]: ==> Have you installed netcdf version 3.4 or later? (y/n) [y]: ==> Enter directory with netcdf lib and include [/usr/local/netcdf-3.4]: /usr/local/netcdf (↑ netcdf のディレクトリ名を書きます) ==> Want to ftp and get any of the GMT version archives? (y/n) [y]: n ==> Where should GMT data be stored [/usr/local/GMT3.3.5/share]? : ==> Where should GMT executables be stored [/usr/local/GMT3.3.5/bin]? : ==> Where should GMT linkable libraries be stored [/usr/local/GMT3.3.5/lib]? : ==> Where should GMT include files be stored [/usr/local/GMT3.3.5/include]? : Unix man pages are usually stored in /usr/man/manX, where X is the relevant man section. This is usually l for local. Below, you will be asked for X and the /usr/man part; the /manX will be appended automatically, so do not answer /usr/man/manl ==> Where should GMT man pages be stored [/usr/local/GMT3.3.5/man]? : ==> Enter Man page section for GMT man pages (1-9,l) [l]: ==> Where should GMT www pages be stored [/usr/local/GMT3.3.5/www]? : At run-time, GMT uses the $GMTHOME environmental parameter to find /usr/local/GMT3.3.5/share. The name must not contain the trailing /share. You may want to override the default if users will see a different mount point or a symbolic link instead of a local directory. ==> Enter default GMTHOME selection [/usr/local/GMT3.3.5]? : The answer to the following question will modify the GMT defaults. (You can always change your mind by editing share/gmt.conf) ==> Do you prefer SI or US default values for GMT (s/u) [s]: The answer to the following question will modify the GMT defaults. (You can always change your mind later by using gmtset) PostScript (PS) files contain commands to set paper size, pick a specific paper tray, or ask for manual feed. Encapsulated PS files (EPS) are not intended for printers (but will print ok) and can be included in other documents. Both formats will preview on most previwers (out-of-date Sun pageview is an exception). ==> Do you prefer PS or EPS as default PostScript output (p/e) [p]: Building the GMT libraries as shared instead of static will reduce executable sizes considerably. GMT supports shared libraries under Linux, SunOS, Solaris, IRIX, HPUX, and FreeBSD. Under other systems you may have to manually configure macros and determine what specific options to use with ld. ==> Try to make and use shared libraries? (y/n) [n]: y If you have more than one C compiler you need to specify which, otherwise the default cc should work fine. ==> Enter name of C compiler (include path if not in search path) [cc]: ccc ↑ gccでもよいですが、Compaq の ccc を使った方が速いバイナリができます。 GMT passes information about previous GMT commands onto later GMT commands via a hidden file (.gmtcommands). To avoid that this file is updated by more than one program at the same time (e.g., when connecting two or more GMT programs with pipes) we use POSIX advisory file locking on the file. Apparently, some versions of the Network File System (NFS) have not implemented file locking properly. We know this is the case with Linux pre-2.4 kernels when mounting NFS disks from a Unix server. If this is your case you should turn file locking OFF. ==> Use POSIX Advisory File Locking in GMT (y/n) [y]: n ==> Want to test GMT by running the 20 examples? (y/n) [y]: n ==> Delete all tar files after install? (y/n) [n]: n Normally, all coastline files are installed in GMT3.3.5/share. However, you can also place some of them in separate directories. These dirs must exist or you must have write permission to make them. If alternate directories are specified then a coastline.conf file will be kept in /usr/local/GMT3.3.5/share to contain the names of these directories. NOTE: Do not append the final subdirectory /share as that is done automatically! Set write privileges on all files in GMT3.3.5 ...Done ==> Install any of the supplemental programs? (y/n/a(ll)) [a]: y dbase: Extracting data from NGDC DEM and other grids ==> Install the dbase programs? (y/n) [y]: cps: Encoding and decoding of Complete PostScript files for archiving ==> Install the cps programs? (y/n) [y]: imgsrc: Extracting grids from global altimeter files (Sandwell/Smith) ==> Install the imgsrc programs? (y/n) [y]: meca: Plotting special symbols in seismology and geodesy ==> Install the meca programs? (y/n) [y]: mex: Matlab interface for reading/writing GMT grdfiles (REQUIRES MATLAB) ==> Install the mex programs? (y/n) [y]: n (← MATLAB は入っていないので) mgg: Programs for making, managing, and plotting MGD77 & .gmt data ==> Install the mgg programs? (y/n) [y]: misc: Make posters on laserwriters and create bit-patterns ==> Install the misc programs? (y/n) [y]: segyprogs: Plot SEGY seismic data files ==> Install the segyprogs programs? (y/n) [y]: spotter: Plate tectonic backtracking and hotspotting ==> Install the spotter programs? (y/n) [y]: x2sys: New (Generic) Track intersection (crossover) tools ==> Install the x2sys programs? (y/n) [y]: x_system: Old (MGG-specific) Track intersection (crossover) tools ==> Install the x_system programs? (y/n) [y]: xgrid: An X11-based graphical editor for netCDF-based .grd files ==> Install the xgrid programs? (y/n) [y]: ==> Want to print any of the GMT Documentation? (y/n) [n]: ---> Begin GMT 3.3.5 installation <--- ---> Run configure to create makegmt.macros and gmt_notposix.h creating cache ./config.cache checking host system type... i686-pc-linux-gnu checking target system type... i686-pc-linux-gnu checking build system type... i686-pc-linux-gnu ・ ・ (中略) ・ ・ if [ ! /usr/local/GMT3.3.5/www = /usr/local/GMT3.3.5/www ]; then \ mkdir -p /usr/local/GMT3.3.5/www; \ \cp -r www/gmt /usr/local/GMT3.3.5/www; \ else \ echo "Install www directory the same as distribution www directory - nothing copied"; \ fi Install www directory the same as distribution www directory - nothing copied All users should add /usr/local/GMT3.3.5/www/gmt/gmt_services.html to their browser bookmarks rm -f *.o gmt_nan_init for i in blockmean blockmedian blockmode filter1d fitcircle grdfilter gmtconvert gmtdefaults gmtmath gmtselect gmtset grd2cpt grd2xyz grdcontour grdcut grdclip grdedit grdfft grdgradient grdhisteq grdimage grdinfo grdlandmask grdmask grdtrack grdreformat grdmath grdpaste grdproject grdsample grdtrend grdvector grdview grdvolume makecpt mapproject minmax nearneighbor project psbasemap psclip pscoast pshistogram psimage psmask psrose psscale pstext pscontour pswiggle psxy psxyz sample1d spectrum1d splitxyz surface trend1d trend2d triangulate xyz2grd; do \ rm -f $i; \ done GMT installation complete. Remember to set these: ----------------------------------------------------------------------- setenv GMTHOME /usr/local/GMT3.3.5 set path = (/usr/local/GMT3.3.5/bin $path) Add /usr/local/GMT3.3.5/man to MANPATH: Add /usr/local/GMT3.3.5/www/gmt/gmt_services.html as browser bookmark ----------------------------------------------------------------------- install_gmt: Session parameters written to file install.par [kakehi@sc210 local]# --------------------------------------------------------------------------- ■ GMT のコマンドと man ファイルへの path を切っておく 僕は tcsh を使っていますので、.cshrc に # setting for GMT3.3.5 setenv GMTHOME /usr/local/GMT3.3.5 set path = ($path ${GMTHOME}/bin) setenv MANPATH ${MANPATH}:${GMTHOME}/man:/usr/local/netcdf/man と書いています。