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

#### 操作步骤

1. 使用PuTTY工具，以root用户登录服务器。
2. 执行以下命令进入WAVEWATCH III安装目录。

```
cd
/path/to/WAVEWATCH
```


3. 执行以下命令解压WAVEWATCH III源码包。

```
tar -xvf WW3-6.07.1.tar.gz
```


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

```
cd  WW3-6.07.1
```


5. 执行以下命令创建环境变量文件。

  a. 创建环境变量文件。

```
vi env_ww3.sh
```


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

```
############# gnu + openmpi #################
export PATH=
/path/to/GNU
/bin:$PATH
export LD_LIBRARY_PATH=
/path/to/GNU
/lib64:$LD_LIBRARY_PATH
export PATH=
/path/to/
OpenMPI
/bin:$PATH
export LD_LIBRARY_PATH=
/path/to/
OpenMPI
/lib:$LD_LIBRARY_PATH
############# netcdf #################
export NETCDF_DIR=
/path/to/NETCDF
export NETCDF_LIBDIR=$NETCDF_DIR/lib
export NETCDF_INCDIR=$NETCDF_DIR/include
export PATH=$NETCDF_DIR/bin:$PATH
export LD_LIBRARY_PATH=$NETCDF_LIBDIR:$LD_LIBRARY_PATH
export WWATCH3_NETCDF=NC4
export NETCDF_CONFIG=$NETCDF_DIR/bin/nc-config
############# metis #################
export METIS_PATH=
/path/to/
METIS
export PATH=$METIS_PATH/bin:$PATH
export LD_LIBRARY_PATH=$METIS_PATH/lib:$LD_LIBRARY_PATH
```


    “/path/to/GNU”指GNU9.1的安装路径，“/path/to/OPENMPI”指OpenMPI的安装路径，“/path/to/NETCDF”指NETCDF和NETCDF-Fortran的安装路径，“/path/to/METIS”指ParMETIS的安装路径。

  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
6. 执行以下命令加载环境变量。

```
source env_ww3.sh
```


7. 执行以下命令配置ww3参数，注意粗体部分。

```
./model/bin/w3_setup  model/
```

```
*****************************
***   WAVEWATCH III setup     ***
*****************************
[INFO] local env file wwatch3.env created in /home/WW3-6.07.1/model/bin/wwatch3.env
Setup file /home/WW3-6.07.1/model/bin/wwatch3.env not found
Default set up :
Printer (listings)       :
printer
Auxiliary FORTRAN comp.  :
gfortran
Auxiliary C compiler     :
gcc
Scratch directory        :
/path/to/WAVEWATCH
/WW3-6.07.1/model/tmp
Save sources             :
yes
Save listings            :
yes
Update settings ? [y/n]
y
Creating new set-up :
Printer for listings [printer] :
Auxiliary FORTRAN compiler [gfortran] :
Auxiliary C compiler [gcc] :
Scratch space [/home/wdy/WW3-6.07.1/model/tmp] :
Save source code files (*.f)  [yes] :
Save listing files  [yes] :
Modified set up :
Printer (listings)       : printer
Auxiliary FORTRAN comp.  : gfortran
Auxiliary C compiler     : gcc
Scratch directory        : /path/to/WAVEWATCH III/WW3-6.07.1/model/tmp
Save sources             : yes
Save listings            : yes
New settings OK ? [y/n] y
Setup makefile for auxiliary programs
……
Create required model subdirectories
Finished setting up WAVEWATCH III
```
