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

#### 操作步骤

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

```
cd
/path/to
/netcdf
wget https://codeload.github.com/Unidata/netcdf-fortran/tar.gz/refs/tags/v4.5.3 -O netcdf-fortran-4.5.3.tar.gz
wget https://codeload.github.com/Unidata/netcdf-c/tar.gz/refs/tags/v4.7.4 -O netcdf-c-4.7.4.tar.gz
```


3. 执行以下命令解压NETCDF-C安装包。

```
tar xvf netcdf-c-4.7.4.tar.gz
tar xvf netcdf-fortran-4.5.3.tar.gz
```


4. 执行以下命令进入解压后的目录。

```
cd netcdf-c-4.7.4
```


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

```
export CC=mpicc CXX=mpicxx FC=mpifort
export HDF5_DIR=
/path/to/hdf5
export PNETCDF_DIR=
/path/to/pnetcdf
```


6. 执行以下命令编译安装NETCDF-C。

```
./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
make install
```


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

```
export PATH=
/path/to/netcdf
/bin:$PATH
export LD_LIBRARY_PATH=
/path/to/netcdf
/lib:$LD_LIBRARY_PATH
export NETCDF=
/path/to/netcdf
```


8. 执行以下命令编译安装NETCDF-Fortran。

```
cd ../netcdf-fortran-4.5.3
./configure --prefix=
/path/to/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}/HDF5/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"
sed -i '11838c wl="-Wl,"' libtool
make -j
make install
```
