close

這一年實驗室變化很大(因為之前很久沒有變化了),老師的第一位直系博士後高升到中研院,又畢業了兩位博士生,所以很多事情都不一樣了,最近來的博士後一位是大陸人一位是韓國人,基本上差一位日本人就可以完成日本帝國的大東亞共榮圈了(哈哈哈,這是開玩笑的題外話啦),最近韓國的金小姐跟我說他需要使用這套軟體GMT,但是我對這套軟體還真的是一問三不知,所以我大概找了一個下午查詢如何安裝。

先來介紹何謂GMT(Generic mapping tools),它是一個開放性軟體,基本為卡氏座標,可以提供地型特徵,可以畫x-y 圖形到3D圖形以PostScript圖型輸出,共有81個指令可以提供使用。要如何使用我就不清楚了,在這邊做的簡單的安裝記錄,因為本實驗室的cluster(叢集電腦)為suse server 10.1版本核心版本為4.1.2算是6~7年前的產品了,所以對照OS查詢的結果應該是沒有辦法安裝這套軟體,所以我後來用去年購買的伺服器(OS: centos 6)來安裝這套軟體。

首先要先介紹一下安裝時需要的套件,一般我們安裝好linux的時候,基本上它會給你他官方的yum server,但是還有另外一個EPEL(Extra Package for Enterprise Linux)維護的套件軟體庫,要在自己的/etc/yum.repos.d下面把這資料庫加進去,或者是直接用rpm到網路安裝EPEL套件

#>rpm -Uvh http://mirror01.idc.hinet.net/EPEL/6/x86_64/epel-release-6-8.noarch.rpm

他會下載epel套件,所以會自動把EPEL資料庫自動加進去,但是我後來執行

#>yum install netcdf-devel

等了好久,最後連線失敗,所以後來我把epel.repo裡面的位置通通改成baseurl=http://mirror01.idc.hinet.net/EPEL/6/x86_64/

也就是把mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch替換成 baseurl=http://mirror01.idc.hinet.net/EPEL/6/x86_64/

接下來就可以安裝套件了,我一開始是直接更改yum資料庫位置,但是更改完之後安裝套件會出現header的錯誤訊息,所以我就去安裝epel套件,並更改資料庫源。

更新好資料庫接下來就可以安裝套件了

#>yum install gcc-c++ libXt-devel libXaw-devel libXmu-devel libSM-devel -->這是官方來源的函式庫

#>yum install ghostscript cmake netcdf netcdf-devel gdal gdal-devel -->epel的函式庫

通常把epel的套件安裝上去應該就沒有問題了,不過這時候我還是有出現一些warning,接下來就是去安裝GMT的source data

進入這個網站http://gmtrac.soest.hawaii.edu/projects/gmt/wiki/Download,把gmt-5.1.1-doc.tar.gzdcw-gmt-1.1.1.tar.gzgshhg-gmt-2.3.4.tar.gz這三個檔案抓下來

#>tar zxvf gmt-5.1.1-doc.tar.gz dcw-gmt-1.1.1.tar.gz gshhg-gmt-2.3.4.tar.gz

#>cd gmt-5.1.1

#>cp cmake/ConfigUserTemplate.cmake cmake/ConfigUser.cmake

#>vi cmake/ConfigUser.cmake (把#拿掉,並做下列更改)

set (CMAKE_INSTALL_PREFIX "/opt/GMT/gmt5.1.1")
set (GMT_INSTALL_MODULE_LINKS FALSE)
set (GSHHG_ROOT "/opt/gshhg")                        --->解壓縮完gssh之後的路徑位置
set (COPY_GSHHG TRUE)                                  
set (DCW_ROOT "/opt/dcw")                                 --->解壓縮完dcw之後的路徑位置                           
set (COPY_DCW TRUE)                                

set (NETCDF_ROOT /usr)         ------------------->這不用設定,但我們如果有跑WRF、CESM等等模式的話這就很重要了,這是因為手動安裝netcdf的時候常會下這指令./configure --disable-netcdf-4
set (NETCDF_STATIC TRUE)     ------------------->,這指令會跳過hdf library這樣一來會導致GMT不能安裝,因為它需要netcdf中的hdf動態資料庫

紅色字體是一定要設定的,而墨綠色的字體如果這台機器從來不曾安裝過netcdf軟體就不用改了,但是如果曾經使用過或跑過其他模式有用到netcdf格式,請更改。

我一開始的時候並沒有去更改資料庫位置,所以會出現以下的錯誤訊息。

#>mkdir build

#>cd build

#>cmake ..    

-- Looking for nc_def_var_deflate
-- Looking for nc_def_var_deflate - not found
CMake Error at cmake/modules/FindNETCDF.cmake:127 (message):
Library found but netCDF-4/HDF5 format unsupported. Do not configure
netCDF-4 with --disable-netcdf-4.
Call Stack (most recent call first):
src/CMakeLists.txt:39 (find_package)

出現這個問題很有可能是因為netcdf路徑造成,如果你的netcdf是手動安裝,請檢查netcdf安裝檔裡面的config.log有沒有設定'--disable-netcdf-4'在安裝參數裡面,如果有的話請重新安裝,如果沒有的話請更新到4版以上。如果是用yum安裝的話,請檢查yum的來源位置是否來自epel(yum repolist;yum info netcdf-devel; yum repolist netcdf-devel; rpm -qa | grep netcdf ;rpm -qa | grep hdf5),如果不是的話請移除並重新安裝epel的函式庫(yum erase xxxxxxxx ; yum clean all ; yum install xxxxxxxxx),我當時卡機的問題就是我自以為把環境路徑改成後來yum安裝的,但是cmake沒有這麼聰明會自行覆蓋log檔(build/CMakeError.log and build/CMakeOutput.log),所以你第一次產生出上面的錯誤環境檔,環境變數就一直是那個錯誤檔,除非你去刪除(rm build/CMakeError.log  build/CMakeOutput.log),這兩個檔案才會改變。我後來就是確認沒問題之後整個gmt5.1.1整個資料夾刪除,再重新設定環境變數就可以通過了。

#>cmake ..   ---->檢查library跟相容性

#>make       ----->編譯

#>make install   ----->安裝 

安裝完之後設定環境變數  

#>export GMT5HOME=/opt/GMT/gmt5.1.1

#>export PATH=$GMT5HOME/bin:$PATH

#>export LD_LIBRARY_PATH=$GMT5HOME/lib64:$LD_LIBRARY_PATH

#>export INCLUDE=$GMT5HOME/include:$include

#>gmt

        GMT - The Generic Mapping Tools, Version 5.1.1 (r12968) [64-bit]
(c) 1991-2014 Paul Wessel, Walter H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe

Supported in part by the US National Science Foundation (www.nsf.gov)
and volunteers from around the world.

This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of this program under the terms of the
GNU Lesser General Public License (http://www.gnu.org/licenses/lgpl.html).
For more information about these matters, see the file named LICENSE.TXT.

usage: gmt [options]

       gmt <module name> [<module options>]

options:
  --help            List and description of GMT modules.
  --version         Print version and exit.
  --show-datadir    Show data directory and exit.
  --show-bindir     Show directory of executables and exit.

if <module options> is '=' we call exit (0) if module exist and non-zero otherwise.

出現這東西就表示安裝成功了........

雖然目前我不知道這套軟體可以幹嘛,不過感覺上功能好像很強大,提供給各位前輩先進。

 

 

 

arrow
arrow
    全站熱搜

    廖董不懂 發表在 痞客邦 留言(2) 人氣()