banner
NEWS LETTER

WRF基础 | WRF库的安装

Scroll down

介绍

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# WRF模式依赖库版本信息
# 这些库是WRF模式运行的基础依赖

# 并行计算库
mpich-3.0.4 # MPI并行计算库,用于分布式内存并行
openmpi-3.0.0 # OpenMPI并行计算库,MPICH的替代方案

# 压缩和图像处理库
zlib-1.2.7 # 数据压缩库
libpng-1.2.50 # PNG图像处理库
jasper-1.900.1 # JPEG-2000图像压缩库

# 科学数据格式库
hdf5-1.10.5 # 层次化数据格式第5版
netcdf-c-4.8.1 # NetCDF C接口库
netcdf-fortran-4.5.4 # NetCDF Fortran接口库
netcdf-cxx4-4.3.1 # NetCDF C++接口库

# 编译器版本要求
# 编译器使用的是GNU编译器套件
gfortran的版本最好不要高于7,因为Fortran 7以上版本中iand函数的定义发生变化,可能会导致intmath错误
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19



## 文件所用脚本


```shell
# gfortran是Fortran 95 编译器,支持Fortran95和一部分Fortran2003的功能
which gfortran
# /usr/bin/gcc
which cpp
# /usr/bin/cpp
# gcc是GCC中的GUN C Compiler(C 编译器)
which gcc
# /usr/bin/gcc
# 查看gcc版本
gcc --version
# gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash

#系统初始编译器配置
#yum install gcc
#yum install cpp gcc-c++
#yum install gcc-gfortran
#yum install unzip bzip2 time nfs-utils perl tcsh wget m4 mlocate.x86_64 libX11-devel.x86_64 libXext-devel.x86_64 libXrender-devel.x86_64 fontconfig-devel.x86_64 curl-devel cmake subversion

source libraries.sh

# mpich-3.0.4
tar xzvf mpich-3.0.4.tar.gz
cd mpich-3.0.4
./configure --prefix=$DIR/mpich
make
make install
cd ..
rm -rf mpich-3.0.4
source libraries.sh

# zlib-1.2.7
tar xzvf zlib-1.2.7.tar.gz
cd zlib-1.2.7
./configure --prefix=$DIR/grib2
make
make install
cd ..
rm -rf zlib-1.2.7
source libraries.sh

# libpng-1.2.50
tar xzvf libpng-1.2.50.tar.gz
cd libpng-1.2.50
./configure --prefix=$DIR/grib2
make
make install
cd ..
rm -rf libpng-1.2.50
source libraries.sh

# jasper-1.900.1
tar xzvf jasper-1.900.1.tar.gz
cd jasper-1.900.1
./configure --prefix=$DIR/grib2
make
make install
cd ..
rm -rf jasper-1.900.1
source libraries.sh

tar xzvf zlib-1.2.7.tar.gz
cd zlib-1.2.7
./configure --prefix=$DIR/hdf5
make
make install
cd ..
rm -rf zlib-1.2.7
source libraries.sh

# hdf5-1.10.5
tar xzvf hdf5-1.10.5.tar.gz
cd hdf5-1.10.5/
./configure --prefix=$DIR/hdf5 --with-zlib=$DIR/hdf5
make
make install
cd ..
rm -rf hdf5-1.10.5
source libraries.sh

# netcdf-c-4.8.1
unzip netcdf-c-4.8.1.zip
cd netcdf-c-4.8.1/
CPPFLAGS="-I$DIR/hdf5/include" LDFLAGS="-L$DIR/hdf5/lib" ./configure --prefix=$DIR/netcdf --enable-netcdf-4 --enable-netcdf4 --enable-shared --disable-dap
make
make install
cd ..
rm -rf netcdf-c-4.8.1
source libraries.sh

# netcdf-fortran-4.5.4
unzip netcdf-fortran-4.5.4.zip
cd netcdf-fortran-4.5.4/
CPPFLAGS="-I$DIR/netcdf/include" LDFLAGS="-L$DIR/netcdf/lib" ./configure --prefix=$DIR/netcdf
make
make install
cd ..
rm -rf netcdf-fortran-4.5.4
source libraries.sh

# netcdf-cxx4-4.3.1
unzip netcdf-cxx4-4.3.1.zip
cd netcdf-cxx4-4.3.1/
CPPFLAGS="-I$DIR/hdf5/include -I$DIR/netcdf/include" LDFLAGS="-L$DIR/hdf5/lib -L$DIR/netcdf/lib" ./configure --prefix=$DIR/netcdf
make
make install
cd ..
rm -rf netcdf-cxx4-4.3.1
source libraries.sh

# openmpi-3.0.0
tar xzvf openmpi-3.0.0.tar.tar
cd openmpi-3.0.0
./configure --prefix=$DIR/openmpi3.0.0
make
make install
cd ..
rm -rf openmpi-3.0.0
source libraries.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# WRF依赖库环境变量配置脚本
# 注意:使用前请修改路径为实际安装路径

# 创建库文件存储目录
if [ ! -d "/home/daimu/Desktop/LIBRARIES" ];then
mkdir /home/daimu/Desktop/LIBRARIES
else
echo "文件夹已经存在"
fi

# 设置基础编译器环境变量
export DIR=/home//LIBRARIES
export CC=gcc # C编译器
export CXX=g++ # C++编译器
export FC=gfortran # Fortran编译器
export CFLAGS=-m64 # C编译器标志
export F77=gfortran # Fortran77编译器
export FFLAGS=-m64 # Fortran编译器标志

# MPI环境变量设置
export PATH=$DIR/mpich/bin:$PATH

# zlib、libpng、jasper库路径设置
export LDFLAGS=-L$DIR/grib2/lib
export CPPFLAGS=-I$DIR/grib2/include

# HDF5库环境变量
export LD_LIBRARY_PATH=$DIR/hdf5/lib:$LD_LIBRARY_PATH
export PATH=$DIR/hdf5/bin:$PATH
export HDF5_HOME=$DIR/hdf5
export HDF5_INCDIR=$HDF5_HOME/include
export HDF5_LIBDIR=$HDF5_HOME/lib

### netcdf
export PATH=$DIR/netcdf/bin:$PATH
export LD_LIBRARY_PATH=$DIR/netcdf/lib:$LD_LIBRARY_PATH
export NETCDF=$DIR/netcdf
export NETCDF_INC=$NETCDF/include
export NETCDF_LIB=$NETCDF/lib
export NETCDF_INCDIR=$NETCDF/include
export NETCDF_LIBDIR=$NETCDF/lib
export NETCDFPATH=$NETCDF

### openmpi
MPI_HOME=$DIR/openmpi3.0.0
export PATH=${MPI_HOME}/bin:$PATH
export LD_LIBRARY_PATH=${MPI_HOME}/lib:$LD_LIBRARY_PATH
export MANPATH=${MPI_HOME}/share/man:$MANPATH



1
2
3
4
5
6
7
8
9
source /opt/intel2018/bin/compilervars.sh intel64

export DIR=/home/deepin/data/wmj/Daimu/LIBRARIES_intel2
export CC=icc
export CXX=icpc
export FC=ifort
export CFLAGS='-O3 -xHost -ip -no-prec-div -static-intel'
export F77=ifort
export FFLAGS='-O3 -xHost -ip -no-prec-div -static-intel'

Ps: 编译器和库测试

Compiling WRF (ucar.edu)

MPI和OpenMPI

编译时的选择

serial 表示串行计算;
smpar 表示内存共享并行计算(shared memory option),即使用openMP,大部分多核电脑都支持这项功能;
dmpar 表示分布式并行计算(distributed memory option),即使用MPI 进行并行计算,主要用在计算集群,单个电脑就没必要用了;
dm+sm 表示同时使用openMP与MPI两种并行方式.

mpich和openmpi的区别

openmpi是共享式内存结构上的并行计算,就是一台服务器上的多个线程的并行计算

mpich则是分布式内存结构的并行计算,由很多个服务器共同并行计算,是塔式结构。

上述两种并行库对模型计算有影响吗?当然是有的。WRF中的AFWA模块主要是用来诊断降水,极端天气,能见度,水汽,冰,云,热,湍流等的一些变量。如果需要打开这个模块,那么需要保证并行库是mpich的,否则会报错。

其他文章