天天看点

WRF模式学习_从linux安装开始

http://wrfchina.com/node/93

本文作者为中山大学杨超锋同学,特此感谢。

1 CentOS 5 Linux 安装图解

参照:http://hi.baidu.com/senya/blog/item/410b2afa60dec88f9e514642.html

2 PGI 安装

2.1 将文件pgilinux86-64-707.tar.gz 下载到/home/yourname/pgi707 目录下解压

[yourname @localhost pgi707]$ tar -zxvf pgilinux86-707.tar.gz

[yourname @localhost pgi707]$ ls

common install INSTALL.txt linux86 linux86-64 pgilinux86-707.tar.gz

postinstall

2.2 编译并安装

[yourname @localhost pgi707]$ su root

[[email protected] pgi707]# ./install

Do you accept these terms? [accept,decline]

accept

Install the ACML? [y/n]

n

Installation directory? [/usr/pgi]

/usr/local/pgi

Create an evaluation license? [y/n]

n

Do you want the files in the install directory to be read-only? [y,n]

n

还有许多其他设置可以默认进行,直接回车即可

2.3 用root 用户把license.dat(在使用期范围的其他版本的license.dat 也可以用)复制

(cp)到/usr/local/pgi 下

2.4 把以下几行放到/home/yourname/.bashrc 的最后

export PGI=/usr/local/pgi/linux86/7.0-7

export PATH=$PGI/bin:$PATH

export MANPATH=$PGI/man:$MANPATH

export LM_LICENSE_FILE=/usr/local/pgi/license.dat

并执行:

[[email protected] pgi707]# source /home/yourname/.bashrc

2.5 测试PGI:

[[email protected] pgi707]# pgf90

pgf90-Warning-No files to process

以上说明PGI 安装成功!

3 Netcdf 安装

3.1 将文件netcdf.tar.gz 下载到/home/yourname/netcdf 下解压

[yourname @localhost netcdf]$ tar -zxvf netcdf-4.0.1.tar.gz

[yourname @localhost netcdf]$ ls

netcdf-4.0.1 netcdf-4.0.1.tar.gz

3.2 编译并安装

[yourname @localhost netcdf]$ cd netcdf-4.0.1/

[yourname @localhost netcdf-4.0.1]$ su root

[[email protected] netcdf-4.0.1]# mkdir /usr/local/netcdf

[[email protected] netcdf-4.0.1]# ./configure --prefix=/usr/local/netcdf

FC=pgf90

[[email protected] netcdf-4.0.1]# make

[[email protected] netcdf-4.0.1]# make install

3.3 把以下几行放到/home/yourname/.bashrc 的最后

export NETCDF=/usr/local/netcdf

export PATH=$NETCDF/bin:$PATH

并执行:

[[email protected] netcdf-3.6.2]# source /home/yourname/.bashrc

这样NetCDF 安装成功!

4 NCARG 安装

4.1. 安装PPNGlib 的支持,到http://www.libpng.org/pub/png/libpng.html 下载然后执行

./configure --prefix=/usr/local

make all install

4.2. 下载ncl 安装文件,到http://www.earthsystemgrid.org/下载和本地机器和gcc 版本相近的ncl 预编译

版本。本地机器版本可以用uname -m 查看,gcc 版本用 gcc --version 查看。我下载的是 NCL 5.1.1 32-bit

binary for i686 chips for LINUX (compiled with gcc 4.1.2)。

4.3. 安装

将下载的文件解压,把里面的三个子文件夹bin, lib, include 解压到目标文件夹,即/usr/local/ncarg。

命令如下:

su

输入口令

mkidr /usr/local/ncarg

cd /usr/local/ncarg

tar zxvf /home/yourname/ncl_ncarg-5.1.1.Linux_i686_gcc412.tar.gz

4.4. 配置环境变量: (可参考http://www.ncl.ucar.edu/Download/install.shtml)

cd ~

gedit .bashrc

打开.bashrc 文件添加下面几行:

export NCARG_ROOT=/usr/local/ncarg

export PATH=/usr/local/ncarg/bin:$PATH

export DISPLAY=:0.0

export NCARG_LIB=/usr/local/ncarg/lib

export NCARG_INC=/usr/local/ncarg/include

然后保存

再在~/目录下,输入 source .bashrc

4.5. 配置文件:

在~/ 目录下建立.hluresfile 文件, 然后把下面内容复制( 此文件说明见:

http://www.ncl.ucar.edu/Document/Graphics/hlures.shtml)这个文件已经做好给你们了,直接复制到~/里

!=========================================

! comments for ".res" files are preceded by a "!"

! remember quotations are not used in .res files

! White background/black foreground

*wkForegroundColor : (/0.,0.,0./)

*wkBackgroundColor : (/1.,1.,1./)

*wkColorMap : rainbow+gray

! Font stuff

*Font : helvetica

! Function Codes [Default is a colon ]

*TextFuncCode : ~

! Make default X11 window larger (adjust as necessary)

*wkWidth : 800

*wkHeight : 800

! Have a favorite colormap that you use for everything? You can

! make it your default here (note the name is NOT in quotes):

! *wkColorMap : temp1

! Increase the default (16mb) contour memory

! If you gave gridded data > 500 x 500, you may need this

*wsMaximumSize: 32556688

!==========================================

然后 cd ~, 分别执行

ng4ex gsun01n ncl gsun01n.ncl

ncargex cpex08, ctrans -d X11 cpex08.ncgm

此时,可以看到测试的显示结果。

※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※

到此为止,WRF 模式安装的前期准备已经完成,下面开始正式安装模式。在正式安装之前,我们先在我们

自己的用户目录下建立一个名为WRF 的文件夹,然后把地形文件压缩包geog_v3.1.tar.gz、WRFV3 压

缩包WRFV3.1.1.TAR.gz、WPSV3 压缩包WPSV3.1.1.TAR.gz 和ARWpost 压缩包ARWpost.tar.gz

都复制到WRF 文件夹里,最后就可以在WRF 文件夹里进行模式的安装了。

※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※

5 WRFV3 安装

要先安装WRF,再安装WPS,这个顺序不能颠倒。

安装步骤:

5.1 WRF 压缩包可以到以下网页下载:

http://www.mmm.ucar.edu/wrf/users/download/get_source.html

需要注册,不过注册很方便。我们已经下载好了。

5.2 在事前建立的WRF 目录下,解压WRFV3 的压缩包

tar zxvf WRFV3.1.1.TAR.gz

cd WRFV3

export WRFIO_NCD_LARGE_FILE_SUPPORT=1

./configure

注释:serial means single processor (考虑到大家机器的实际情况,请大家选择这项)

smpar means Symmetric Multi-Processing/Shared Memory Parallel (OpenMP)

dmpar means Distributed Memory Parallel (MPI)

dm+sm means Distributed Memory with Shared Memory (for example, MPI across

nodes with OpenMP within a node)

the second option is for nesting: 0 = no nesting, 1 = standard static nesting,

2 = nesting with a prescribed set of moves, 3 = nesting that allows a domain

to follow a vortex (typhoon tracking)

注意:选择linux with pgi 编译器(serial)的选项,回车以后,出现compile for nesting?

选择basic。

5.3 开始编译

./compile em_real

ls -ls main/*.exe

注释:you should see ndown.exe, real.exe, and wrf.exe 。代表WRFV3 安装成功。

5.4 如果编译失败,请先回到WRFV3 目录下,输入./clean –a ,再重新查找问题,重新安装。

6 WPSV3 安装

6.1 获取WPS 的源文件 WPSV3.TAR.gz

o http://www.mmm.ucar.edu/wrf/users/download/get_source.html

6.2 进入WRF 目录,并解压:

cd WRF

tar -zxvf WPSV3.1.1.TAR.gz

解压后,进入WPS 目录

cd WPS

6.3 配置:

./configure

这一布会出现相关选项,注意事项如下:

o choose one of the options

o usually, option "1" and option “2” are for serial builds, that is the best

for an initial test

o WPS requires that you build for the appropriate Grib decoding, select an

option that suitable for the data you will use with the ungrib program

o If you select a Grib2 option, you must have those libraries prepared and

built in advance

6.4 编译:

./compile

ls -ls *.exe

注释:

o you should see geogrid.exe, ungrib.exe, and metgrid.exe (if you are missing

both geogrid.exe and metgrid.exe, you probably need to fix where the path to

WRF is pointing in the configure.wps file; if you are missing ungrib.exe, try

a Grib1-only build to further isolate the problem)

ls -ls util/*.exe

注释:

o you should see a number of utility executables: avg_tsfc.exe,

calc_ecmwf_p.exe, g1print.exe, g2print.exe, mod_levs.exe, plotfmt.exe,

plotgrids.exe, and rd_intermediate.exe (files requiring NCAR Graphics are

plotfmt.exe and plotgrids.exe)

• if geogrid.exe and metgrid.exe executables are missing, probably the path

to the WRFV3 directory structure is incorrect (found inside the configure.wps

file)

• if the ungrib.exe is missing, probably the Grib2 libraries are not linked

or built correctly

• if the plotfmt.exe or the plotgrids.exe programs are missing, probably the

NCAR Graphics path is set incorrectly

6.5 如果编译失败,请先回到WPS 目录下,输入./clean –a ,再重新查找问题,重新安装。

7 ARWpost 安装

ARWpost 是一个把WRF 结果转为GrADS 或Vis5D 可以辨识的数据格式的软件。

下面为安装步骤:

tar zxvf ARWpost.tar.gz

cd ARWpost

解压后进入文件夹,然后如下操作:

./configure

生成configure.arwp

如果你的WRF 目录路径不是在"../WRFV3" ,则要编辑configure.arwp,文件,设置“WRF_DIR“变

量为你的WRFV3 路径

./complie

生成 ARWpost.exe,表明安装成功,

运行时,先修改namelist.ARWpost

然后运行 ./ARWpost.exe

这就会生成 output_root_name.dat & output_root_name.ctl 或output_root_name.v5d

然后就可以通过 GrADS 或Vis5D 画图。

8 GrADS 安装

假设文件下载位置为/home/yourname/grads-2.0.a7.1-bin-i686-pc-linux-gnu.tar.gz

8.1.选择安装路径.一般选择装在 /usr/local/bin/ 目录(也可自行选择其他)

[[email protected] ~]$ su 转入根用户,以便访问/usr/local/bin

[[email protected] yourname]# cd /usr/local/bin

8.2.解压缩文件

[[email protected] bin]# tar zxvf

/home/yourname/grads-2.0.a7.1-bin-i686-pc-linux-gnu.tar.gz

[[email protected] bin]# cd ..

[[email protected] grads-2.0.a7.1]# mkdir dat

[[email protected] grads-2.0.a7.1] # cd dat

[[email protected] bin]# tar zxvf /home/yourname/data.tar.Z

8.3.设置环境变量

转到普通用户(Ctrl+D),打开 ~./.bashrc,

[[email protected] ~]$ vi .bashrc

添加如下命令:

export GADDIR=/usr/local/bin/grads-2.0.a7.1/dat

export GASCRP=/usr/local/bin/grads-2.0.a7.1/lib

export PATH=/usr/local/bin/grads-2.0.a7.1/bin:$PATH

alias grads=/usr/local/bin/grads-2.0.a7.1/bin/grads

保存后[[email protected] ~]$ source .bashrc

8.4.OK.输入'grads'命令即可打开GrADS.

继续阅读