Ubuntu 20.4 源代码方式安装 cdo(笔记)

动机

我找到的处理 era5-land 代码在需要用到 cdo,但是 sudo apt-get install cdo 总是出现 abort (core dump) 等问题,所以放弃这种安装方式,不走捷径,安装源代码,也就是 cdo-x.x.x.tar.gz。

安装过程

# 下载网站
https://src.fedoraproject.org/repo/pkgs/
# 例如:
https://src.fedoraproject.org/repo/pkgs/hdf5/hdf5-1.6.6.tar.gz/


INSTALL_DIR=/home/user/soft
mkdir $INSTALL_DIR

# Install netcdf:
tar xzf netcdf-3.6.3.tar.gz
cd netcdf-3.6.3/
./configure --prefix=$INSTALL_DIR --disable-f77
make
make install
cd ..

# Install szip:
tar xzf szip-2.1.tar.gz
cd szip-2.1/
./configure --prefix=$INSTALL_DIR CFLAGS="-lm"
make
make check
make install
cd ..

# Install zlib:
tar xzf zlib-1.2.3.tar.gz
cd zlib-1.2.3/
./configure --shared --prefix=$INSTALL_DIR
make
make install
cd ..

# Install hdf5 (with zlib and szip support):

   # 在文件 /home/user/soft/hdf5-1.6.6/perform/zip_perf.c 中做了以下修改
        /* do compressed data write 
        output = open(filename, O_RDWR | O_CREAT);*/
        /* Change by Liyongkang */
        output = open(filename, O_RDWR | O_CREAT, 0600);


tar xzf hdf5-1.6.6.tar.gz
cd hdf5-1.6.6/
./configure --with-zlib=$INSTALL_DIR --with-szlib=$INSTALL_DIR --prefix=$INSTALL_DIR
make
make install
cd ..

# Install proj
tar xzf proj-4.6.1.tar.gz
cd proj-4.6.1/
./configure --prefix=$INSTALL_DIR
make
make install
cd ..

# Install cdo (with hdf5 and netcdf support):  错误
tar xzf cdo-1.3.1.tar.gz
cd cdo-1.3.1/
./configure --with-hdf5=$INSTALL_DIR --with-szlib=$INSTALL_DIR --with-netcdf=$INSTALL_DIR --with-proj=$INSTALL_DIR --with-zlib=$INSTALL_DIR --prefix=$INSTALL_DIR CC=gcc CFLAGS="-g -D_REENTRANT -O2"
make
make install
cd ..

# Install cdo (with hdf5 and netcdf support):自己修改的版本
tar xzf cdo-1.7.2.tar.gz
cd cdo-1.7.2/
./configure --with-hdf5=$INSTALL_DIR --with-szlib=$INSTALL_DIR --with-netcdf=$INSTALL_DIR --with-proj=$INSTALL_DIR --with-zlib=$INSTALL_DIR --prefix=$INSTALL_DIR CC=gcc CFLAGS="-g -D_REENTRANT -O2"
make
make install
cd ..

# 通过 source , 添加全局变量 至 ~/.bashrc:
sudo gedit ~/.bashrc

# 复制以下内容至.bashrc 末尾
export INSTALL_DIR=/home/user/soft
export LD_LIBRARY_PATH=$INSTALL_DIR/lib
export PATH=$INSTALL_DIR/bin:$PATH

python 调用cdo

import subprocess

command1= '/home/user/soft/bin/cdo expr,"var1=6.112*exp(17.67*(var168-273.15)/(var168-273.15+243.5))" '+"ERA5_2D_2019010900"+" "+"ERA5_E_2019010900"

相关推荐

  1. Ubuntu 20.4 源代码方式安装 cdo笔记

    2023-12-06 17:14:02       31 阅读
  2. Ubuntu20.24 安装ecCodes,包括 tar.gz 和 python(笔记

    2023-12-06 17:14:02       38 阅读
  3. ubuntu20 安装eclipse

    2023-12-06 17:14:02       37 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-06 17:14:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-06 17:14:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-06 17:14:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-06 17:14:02       18 阅读

热门阅读

  1. 入门 PyTorch

    2023-12-06 17:14:02       39 阅读
  2. linux审计功能及规则 (audit.rule)

    2023-12-06 17:14:02       38 阅读
  3. nn.relu和F.rulu的区别

    2023-12-06 17:14:02       38 阅读