本文旨在介紹 PALM 輸出結果的可視化處理工具:NCL (The NCAR Command Language) 的安裝。
官方網站 http://www.ncl.ucar.edu
官方教程 http://www.ncl.ucar.edu/Download/index.shtml#Download
NCL 提供 Binaries 和 Source 兩類安裝包,二者區別參考Binaries和Source兩類包的區別,本文主要介紹NCL binaries 的安裝過程
一. 下載 NCL binaries
1. 下載步驟
步驟如下:
- 訪問 NCL binary 下載地址www.earthsystemgrid.org
- 點擊頁面底部的 "NCL: NCAR Command Language"
- 點擊要下載的版本,進行下載
2. NCL版本選擇:
可供選擇的版本如下:
上圖中所有版本的區別在于:系統版本;Foran complier 版本;處理器類型(即i686,x86_64,64bit等選項)的不同。打開終端輸入
uname -m
cat /etc/issue
lsb_release -d
gcc --version
查詢系統的信息,我的系統信息顯示如下:
lsb_release -d
Description: Ubuntu 16.04.4 LTS
annie@Ubuntu1:~$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
因此,對應的版本應該選擇與Ubuntu接近的系統 Debian, gcc的版本為5.4.0, 而NCL-Debian 最高的版本為492 (也就是4.9.2), 參考官方教程的說明:
It's important to try to match your flavor of Linux if possible, and then match your version of gcc as close as possible. If your version of gcc doesn’t match any in the list, then use aversion of gcc that is lower or just slightly higher (for example, if you have gcc 4.4.6, you can probably use a gcc 4.4.5 binary).
含義就是說Ubuntu的gcc版本要比下載的NCL的版本低,或者稍高一些。我的系統版本是5.4,大于是4.9.2,這樣安裝了可能會出現問題,雖然沒有試過在高版本gcc下使用NCL到底會不會出現問題,但保險起見,我們最好還是將系統的gcc版本從5.4降至4.9版本
3. gcc的降級
在終端輸入如下命令
sudo apt-get install gcc-4.9
接下來添加gcc的配置管理,再選擇默認的gcc版本:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 40
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50
sudo update-alternatives --config gcc
第一行后面的50表示優先級,數字越大,則對應版本在第二行輸入后出來的結果中排位越靠前。輸入第三行之后,出來幾個選項,就會發現我們現在默認使用的就是gcc-4.7了.結果顯示如下:
選擇 路徑 優先級 狀態
------------------------------------------------------------
* 0 /usr/bin/gcc-4.9 50 自動模式
1 /usr/bin/gcc-4.9 50 手動模式
2 /usr/bin/gcc-5 40 手動模式
此時輸入gcc --version
,顯示的版本為4.9.3, 降級完成
四. NCL的安裝
官方教程見http://www.ncl.ucar.edu/Download/install.shtml,本文詳解解釋如下:
- 在/usr/local下創建ncl-6.4.0 文件夾, 將文件的壓縮包移動到該文件夾,進行解壓,然后移出安裝包
cd /usr/local
mkdir ncl-6.4.0
- 安裝軟件包:
sudo apt-get install x11-dev xorg-dev libx11-dev libcairo-devel csh ksh
- 設置環境變量。輸入 “cd” 回到根目錄,再輸入“ls -a”,查看給出的隱藏文件列表中以“.”開頭的文件,并按 shell 的類型分類處理:
- From tcsh/csh (the file might be “.cshrc” or “.tcshrc”):
setenv NCARG_ROOT /usr/local/ncl-6.4.0
setenv PATH $NCARG_ROOT/bin:$PATH
- From bash or ksh (the file might be “.bash_profile” or “.bashrc” or “.bash_profile”):
export NCARG_ROOT=/usr/local/ncl-6.4.0
export PATH=$NCARG_ROOT/bin:$PATH
- From sh (the file might be “.bash_profile” or “.bashrc” or “.bash_profile”):
NCARG_ROOT=/usr/local/ncl-6.1.2
PATH=$NCARG_ROOT/bin:$PATH
export NCARG_ROOT
export PATH
筆者找到了 .bashrc 和 . profile, 說明筆者的系統的 shell 為 bash 和 sh (關于 shell 參考 https://www.cnblogs.com/yinheyi/p/6648242.html),使用與第二種和第三種情況,選擇第二種情況,輸入
gedit ~/.bashrc
在打開的頁面輸入第二種情況的代碼,然后使環境變量生效,輸入
source .bashrc
檢查是否安裝完成,輸入如下代碼:
ng4ex gsun01n -clean
結果顯示如下: