---
title: 安装netcdf
description: "1. 使用PuTTY工具，以root用户登录服务器。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpcindapp/prtg-osc/kylin_kunpeng_gribapi_121_02_0009.html
sourcePath: /source/zh/kunpenghpcs/hpcindapp/prtg-osc/kylin_kunpeng_gribapi_121_02_0009.html
indexId: d471b24ddc20b97356fe37308edd9e5947545d314ddcc3d1354a1303d21b442780
---
# 安装netcdf

#### 操作步骤

1. 使用PuTTY工具，以root用户登录服务器。
2. 执行以下命令下载netcdf安装包并解压。

```
cd /path/to
wget https://codeload.github.com/Unidata/netcdf-fortran/tar.gz/refs/tags/v4.4.5 -O netcdf-fortran-4.4.5.tar.gz
wget https://codeload.github.com/Unidata/netcdf-c/tar.gz/refs/tags/v4.7.0 -O netcdf-c-4.7.0.tar.gz
tar xf netcdf-fortran-4.4.5.tar.gz
tar xf netcdf-c-4.7.0.tar.gz
```


3. 执行以下命令进入netcdf-c源码目录并安装。

```
export HDF5_DIR=/path/to/hdf5
export PNETCDF_DIR=/path/to/pnetcdf
cd netcdf-c-4.7.0
CC=mpicc ./configure --prefix=/path/to/netcdf --build=aarch64-unknown-linux-gnu --enable-shared --enable-netcdf-4 --enable-dap --with-pic --disable-doxygen --enable-static --enable-pnetcdf --enable-largefile CPPFLAGS="-I${HDF5_DIR}/include -I${PNETCDF_DIR}/include" LDFLAGS="-L${HDF5_DIR}/lib -L${PNETCDF_DIR}/lib -Wl,-rpath=${HDF5_DIR}/lib -Wl,-rpath=${PNETCDF_DIR}/lib" CFLAGS="-L${HDF5_DIR}/lib -L${PNETCDF_DIR}/lib -I${HDF5_DIR}/include -I${PNETCDF_DIR}/include"
make -j 64
make install
```


4. 执行以下命令进入netcdf-f源码目录并安装。

```
export NETCDF=/path/to/netcdf
export PATH=/path/to/netcdf/bin:$PATH
export LD_LIBRARY_PATH=/path/to/netcdf/lib:$LD_LIBRARY_PATH
cd ../netcdf-fortran-4.4.5
CC=mpicc FC=mpif90 F77=mpif90 ./configure --prefix=${NETCDF} --build=aarch64-unknown-linux-gnu --enable-shared --with-pic --disable-doxygen --enable-largefile --enable-static CPPFLAGS="-I${HDF5_DIR}/include -I${NETCDF}/include" LDFLAGS="-L${HDF5_DIR}/lib -L${NETCDF}/lib -Wl,-rpath=${HDF5_DIR}/lib -Wl,-rpath=${NETCDF}/lib" CFLAGS="-L${HDF5_DIR}/lib -L${NETCDF}/lib -I${HDF5_DIR}/include -I${NETCDF}/include" CXXFLAGS="-L${HDF5_DIR}/lib -L${NETCDF}/lib -I${HDF5_DIR}/include -I${NETCDF}/include" FCFLAGS="-L${HDF5_DIR}/lib -L${NETCDF}/lib -I${HDF5_DIR}/include -I${NETCDF}/include"
make -j 64
make install
```


5. 执行以下命令设置环境变量。

```
export INCLUDE=/path/to/netcdf/include:$INCLUDE
```
