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

#### 操作步骤

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

```
tar -zxvf netcdf-fortran-4.4.5.tar.gz
```


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

```
cd netcdf-fortran-4.4.5
```


4. 执行以下命令进行编译配置。

```
CC=mpicc CFLAGS="$optflags -I
/path/to/HDF5
/include -I
/path/to/NETCDF
/include" FC=mpif90 FFLAGS="$optflags -fPIC -I
/path/to/HDF5
/include -I
/path/to/NETCDF
/include" FCFLAGS="$optflags -fPIC -I
/path/to/HDF5
/include -I
/path/to/NETCDF
/include" F77=mpif77 LDFLAGS="$ldflags -L
/opt/compiler
/BS/bisheng-compiler-1.3.1-aarch64-linux -L
/path/to/HDF5
/lib -L
/path/to/NETCDF
/lib" ./configure --build=aarch64-linux --prefix=
/path/to/NETCDF
--enable-static --enable-shared --with-pic --enable-parallel-tests --enable-largefile --enable-large-file-tests
```


5. 执行以下命令合入patch包。

```
patch -p1 < libtool.patch
```


6. 新建并编辑“libtool.patch”文件。

  a. 新建“libtool.patch”文件。

```
vi libtool.patch
```


  b. 按“i”进入编辑模式，添加如下内容。

```
diff -ruN hdf5-1.10.1/libtool hdf5-1.10.1-new/libtool
--- hdf5-1.10.1/libtool 2019-12-02 20:02:56.270676503 +0000
+++ hdf5-1.10.1-new/libtool 2019-12-02 20:03:05.062708034 +0000
@@ -11832,7 +11832,7 @@
pic_flag=""
# How to pass a linker flag through the compiler.
-wl=""
+wl="-Wl,"
# Compiler flag to prevent dynamic linking.
link_static_flag=""
```


  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
7. 执行以下命令进行编译安装。

```
make -j$threads
```

```
make install
```


8. 执行以下命令验证是否安装成功。

```
ls
/path/to/NETCDF
/bin
ls
/path/to/NETCDF
/lib
```
