用 Docker Desktop 启动 Ubuntu 容器,安装intel及NC-4

docker ps -s  -a   # 显示已安装的容器
docker start intel-env   # 启动容器
docker exec -it <容器名或容器ID> /bin/bash  # 进入
docker stop intel-env   # 终止已安装的容器
docker rm intel-env     # 删除容器
  1. 在 PowerShell 或 Terminal 用:虚拟unbutu20.04环境
    并挂载"F:\1-WPS同步\env:/opt/env"文件夹
docker run -it --name fvcom-intel-clean -v "F:\1-WPS同步\env:/opt/env" ubuntu:20.04 bash

注意:挂载目录只能在一开始创建容器时挂载,后面不能更改了

ls /opt/env
apt update && apt install -y \
  wget curl vim nano \
  build-essential gfortran m4 cmake \
  zlib1g-dev libcurl4-openssl-dev \
  git unzip
  1. 安装intel编译器
./l_HPCKit_p_2021.3.0.3230_offline.sh -a -s --eula accept
source /opt/intel/oneapi/setvars.sh
which icc
  1. 安装nc-4
    zlib
cd opt
wget https://zlib.net/fossils/zlib-1.2.13.tar.gz

tar -xzf zlib-1.2.13.tar.gz
cd zlib-1.2.13
 CC=icc CXX=icpc FC=ifort F77=ifort ./configure --prefix=/opt/netcdf-intel
make -j4
make install

hdf5
cd opt

wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.2/src/hdf5-1.12.2.tar.gz
tar -xzf hdf5-1.12.2.tar.gz
cd hdf5-1.12.2
CC=icc CXX=icpc FC=ifort F77=ifort ./configure \
  --prefix=/opt/netcdf-intel \
  --with-zlib=/opt/netcdf-intel \
  --enable-fortran \
  --disable-shared
make -j4
make install

添加环境变量

export LD_LIBRARY_PATH=/opt/netcdf-intel/lib:$LD_LIBRARY_PATH
export CPPFLAGS="-I/opt/netcdf-intel/include"
export LDFLAGS="-L/opt/netcdf-intel/lib"

nc-c

cd /opt

wget https://downloads.unidata.ucar.edu/netcdf-c/4.9.2/netcdf-c-4.9.2.tar.gz
tar -xzf netcdf-c-4.9.2.tar.gz
cd netcdf-c-4.9.2
CPPFLAGS="-I/opt/netcdf-intel/include"
LDFLAGS="-L/opt/netcdf-intel/lib"

CC=icc ./configure \
  --prefix=/opt/netcdf-intel \
  --disable-dap \
  --disable-shared \
  --disable-libxml2      
make -j4
make install

nc-f
vim ~/.bashrc

export LD_LIBRARY_PATH=/opt/netcdf-intel/lib:$LD_LIBRARY_PATH
export CPPFLAGS="-I/opt/netcdf-intel/include"
export LDFLAGS="-L/opt/netcdf-intel/lib"
export LIBS="-lnetcdf -lhdf5_hl -lhdf5 -lz"


export CPPFLAGS="$(/opt/netcdf-intel/bin/nc-config --cflags)"
export LDFLAGS="$(/opt/netcdf-intel/bin/nc-config --libs)"
export LD_LIBRARY_PATH=/opt/netcdf-intel/lib:$LD_LIBRARY_PATH
source ~/.bashrc
cd /opt

wget https://downloads.unidata.ucar.edu/netcdf-fortran/4.6.0/netcdf-fortran-4.6.0.tar.gz
tar -xzf netcdf-fortran-4.6.0.tar.gz
cd netcdf-fortran-4.6.0
CC=icc FC=ifort ./configure \
  --prefix=/opt/netcdf-intel \
  --disable-shared
make -j4
make install

最后,可以export一下nc的相关环境变量

source /opt/intel/oneapi/setvars.sh
export LD_LIBRARY_PATH=/opt/netcdf-intel/lib:$LD_LIBRARY_PATH
export NETCDF=/opt/netcdf-intel
export PATH=$NETCDF/bin:$PATH
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值