---
title: 创建环境变量
description: "1. 使用PuTTY工具，以root用户登录服务器。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpcindapp/prtg-osc/kunpengroms_02_0005.html
sourcePath: /source/zh/kunpenghpcs/hpcindapp/prtg-osc/kunpengroms_02_0005.html
indexId: 784dc6eb2f5f5f79a3fc8bd3cea16a4f1a9a9c4481725246340a81c4078282fc66
---
# 创建环境变量

#### 操作步骤

1. 使用PuTTY工具，以root用户登录服务器。
2. 执行以下命令创建环境变量文件“env.sh”。

  a. 创建环境变量文件“env.sh”。

```
vi /root/env.sh
```


  b. 按“i”进入编辑模式，编写“env.sh”文件。

```
#!/bin/bash
export GNU_HOME=
/path/to/GNU
export MPI_HOME=
/path/to/OPENMPI
export HDF5=
/path/to/HDF5
export PNETCDF=
/path/to/PNETCDF
export NETCDF=
/path/to/NETCDF
export PHDF5=$HDF5
export CPPFLAGS=" -I$HDF5/include -I$PNETCDF/include -I$NETCDF/include -I$MPI_HOME/include "
export CFLAGS=" -I$HDF5/include -I$PNETCDF/include -I$NETCDF/include -I$MPI_HOME/include "
export CXXFLAGS=" -I$HDF5/include -I$PNETCDF/include -I$NETCDF/include -I$MPI_HOME/include "
export FCFLAGS=" -I$HDF5/include -I$PNETCDF/include"
export FFLAGS=" -I$HDF5/include -I$PNETCDF/include"
export LDFLAGS=" -L$HDF5/lib -L$PNETCDF/lib -L$NETCDF/lib"
export LD_LIBRARY_PATH=$HDF5/lib:$PNETCDF/lib:$NETCDF/lib:$MPI_HOME/lib: $GNU_HOME/lib64:$LD_LIBRARY_PATH
export PATH=$NETCDF/bin:$PNETCDF/bin:$MPI_HOME/bin:$GNU_HOME/bin:$PATH
```


  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
3. 执行以下命令配置文件生效。

```
source /root/env.sh
```
