NCL - 安装和配置

本篇随笔将介绍 NCL 的安装和环境配置

下载 NCL 安装包

访问 NCL 官网:
https://www.ncl.ucar.edu/Download/list_of_binaries.shtml
https://www.earthsystemgrid.org/dataset/ncl.html

选择合适的版本下载,这里选用:
ncl_ncarg-6.6.2-Debian7.11_64bit_gnu472.tar.gz

1
wget https://www.earthsystemgrid.org/dataset/ncl.662.dap/file/ncl_ncarg-6.6.2-Debian7.11_64bit_gnu472.tar.gz

解压到安装目录

1
2
sudo mkdir /usr/local/ncl-6.6.2
sudo tar -zxf ./ncl_ncarg-6.6.2-Debian7.11_64bit_gnu472.tar.gz --directory=/usr/local/ncl-6.6.2

配置环境

1
2
3
vim ~/.zshrc
export NCARG_ROOT=/usr/local/ncl-6.6.2
export PATH=$NCARG_ROOT/bin:$PATH

测试

1
ncl

正确输出为

1
2
3
4
5
6
 Copyright (C) 1995-2019 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 6.6.2
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
ncl 0>

如果报错缺少某个依赖文件

1
ncl: error while loading shared libraries: lib***.so.X: cannot open shared object file: No such file or directory

则安装对应的依赖库即可,推荐使用 apt-file 寻找缺失文件所在的库

安装 apt-file 之前,添加 apt 的源

1
2
3
sudo vim /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu/ bionic main universe
sudo apt-get update

安装 apt-file

1
sudo apt-get install apt-file

更新 apt-file 数据库

1
sudo apt-file update

查找缺失文件 lib***.so.X 所在的库,这里以 libgfortran.so.3 为例

1
sudo apt-file search libgfortran.so.3

安装任何一个库即可解决问题

1
sudo apt-get install libgfortran3

配置 vscode

安装 NCL 扩展

NCL扩展

安装 Code Runner 扩展

CodeRunner扩展

配置 Code Runner

打开 ssh / wsl 配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
vim /home/user/.vscode-server/data/Machine/settings.json

{
"code-runner.executorMap": {
"ncl" : "ncl $fileName"
},
"code-runner.executorMapByFileExtension": {
".ncl" : "ncl $fileName",
},
"code-runner.fileDirectoryAsCwd": true,
"code-runner.runInTerminal": true,
"code-runner.saveFileBeforeRun": true,
}