Ubuntu20.24 安装ecCodes,包括 tar.gz 和 python(笔记)
这里写目录标题
- 动机
- 为此找了解决方案。废话不多说,如下:
- 1. 下载 ecCodes 的源文件,网址如下: https://confluence.ecmwf.int/display/ECC/Releases
- 2. 解压包:
- 3. 创建 ecCodes 的安装目录:
- 4. 通过 cmake 安装 :
- 5. 编译, 测试,安装:
- 6.最后为Python 安装 eccodes
- 7. 添加环境变量作为默认
- 具体看官网:https://confluence.ecmwf.int/display/ECC/Releases,我只是搬运工,做笔记。
动机
我的Ubuntu系统提示 grid_copy 找不到,具体问题如下:
./pre_era5.sh: line 78: grib_copy: command not found
./pre_era5.sh: line 84: codes_split_file: command not found
./pre_era5.sh: line 84: codes_split_file: command not found
./pre_era5.sh: line 84: codes_split_file: command not found
./pre_era5.sh: line 84: codes_split_file: command not found
ls: cannot access 'OUTPUTS/2d.grb_*': No such file or directory
因为 找不到 grib_copy,所以最终报错。
为此找了解决方案。废话不多说,如下:
1. 下载 ecCodes 的源文件,网址如下: https://confluence.ecmwf.int/display/ECC/Releases
2. 解压包:
# 安装环境
sudo apt install build-essential gcc gfortran cmake git subversion libnetcdff-dev libnetcdf-c++4-dev libopenmpi-dev netcdf-bin nco cdo ncl-ncarg libxml2 libxml2-utils liblapack-dev libblas-dev
# 解压包
cd /home/user/ecmwf/
cp ~/Download/eccodes-2.32.1-Source.tar.gz
tar -zxvf eccodes-2.32.1-Source.tar.gz
3. 创建 ecCodes 的安装目录:
mkdir /home/user/ecmwf/eccodes
cd /home/user/ecmwf/eccodes
4. 通过 cmake 安装 :
cmake ../eccodes-2.32.1-Source -DCMAKE_INSTALL_PREFIX=/home/user/ecmwf/eccodes
5. 编译, 测试,安装:
make
ctest
make install
6.最后为Python 安装 eccodes
### 我的环境:python3.7 Anaconda3-2019-10
python -m pip install eccodes
或
python -m pip install --install-option="--prefix=/home/user/ecmwf/eccodes" eccodes
7. 添加环境变量作为默认
vim ~/.bashrc
# 在最末尾添加以下内容
# >>> eccodes initialize >>>
export ECCODES_DIR=/home/user/ecmwf/eccodes
export LD_LIBRARY_PATH=$ECCODES_DIR/lib
export PATH=$ECCODES_DIR/bin:$PATH