本文是在结合网上多个帖子的基础上的详细安装过程,在此对那些作者致以感谢,因个人能力有限,大家可根据电脑实际配置更改
安装MM5前的准备
1.安装NCAR Graphics
(1)解压: #tar –xvzf ncl_ncarg-6.0.0-beta.Linux_RedHat_x86_64_gcc412.tar.gz
进入INSTALL目录,输入命令#./install.sh
(2) 配置环境变量
若Linux shell为tcsh/csh命令为:
#setenv NCARG_ROOT /opt/ncarg
#setenv PATH $PATH":$NCARG_ROOT/bin"
若Linux shell为bash/sh命令为:
#export NCARG_ROOT=/opt/ncarg
#export PATH=$PATH":$NCARG_ROOT/bin"
2.安装Fortran编译器
(1)安装C++库支持
#yum install libstdc++.so.5;
#yum install gcc
#yum install gcc-c++
#yum install gcc-gfortran
#yum install libX11-devel
#yum install libgfortran
#yum install java-1.6.0-openjdk
(2)解压:#tar -xzvf l_fcompxe_2011.3.174.tgz
进入INSTALL目录,输入命令#./install.sh
(3)配置环境变量
若Linux shell为tcsh/csh命令为:’
#setenv PATH /usr/local/sbin:/opt/intel/compiler70/intel64/bin:/usr/sbin:
/sbin:${PATH}:${HOME}/bin
# source install-dir/bin/compilervars.csh intel64
若Linux shell为bash/sh命令为:
#source install-dir/bin/compilervars.sh intel64
3.测试INTEL Fortran complier 和 NCAR Graphics
测试INTEL Complier:
输入#which ifort,如果能看到/opt/intel/fce/10.0.015/bin/ifort ,那么就安装设置成功了
测试NCAR Graphics:
输入# ncargex cpex08
输入# ctrans -d X11 cpex08.ncgm
能看到图形表示安装成功,如果提示“g77: command not found.”,则运行
# yum install compat-gcc-34-g77.i386
然后重新再试一次
3.2 安装运行MM5
下载MM5的所有模块: ftp://ftp.ucar.edu/mesouser/MM5V3
下载TERRAIN DATA: ftp://ftp.ucar.edu/mesouser/MM5V3/TERRAIN_DATA
3.2.1编译运行TERRAIN
1.下载libg2c.a 放到 /usr/lib/ , 如果 /usr/lib/gcc-lib/i386-redhat-linux/*.*.*/ 中有该文件则不用下载
2 .编辑 Makefile
# gedit Makefile
将原文中的下列代码
intel:
echo "Compiling for Linux using INTEL compiler"
( $(CD) src ; $(MAKE) all \
"RM = $(RM)" "RM_LIST = $(RM_LIST)" \
"LN = $(LN)" "MACH = SGI" \
"MAKE = $(MAKE)" "CPP = /lib/cpp" \
"CPPFLAGS = -I. -C -traditional -D$(NCARGRAPHICS) " \
"FC = pgf90 " "FCFLAGS = -I.-byteswapio "\
"LDOPTIONS = " "CFLAGS = -I." \
"LOCAL_LIBRARIES = -L$(NCARG_ROOT)/lib -L/usr/X11R6/lib –lncarg -lncarg_gks -lncarg_c -lX11 -L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/ -lg2c " ) ;\
( $(RM) terrain.exe ; $(LN) src/terrain.exe . ) ;
改成:
intel:
echo "Compiling for Linux using INTEL compiler"
( $(CD) src ; $(MAKE) all \
"RM = $(RM)" "RM_LIST = $(RM_LIST)" \
"LN = $(LN)" "MACH = SGI" \
"MAKE = $(MAKE)" "CPP = /lib/cpp" \
"CPPFLAGS = -I. -C -traditional -D$(NCARGRAPHICS) " \
"FC = ifort " "FCFLAGS = -I. -w90 -w95 -convert big_endian "\
"LDOPTIONS = -i_dynamic" "CFLAGS = -I." \
"LOCAL_LIBRARIES= -L$(NCARG_ROOT)/lib -L/usr/X11R6/lib -lncarg -lncarg_gks -lncarg_c -lX11 -L/usr/lib/gcc/x86_64-redhat-linux/4.1.1 -lgfortran" ) ; \
( $(RM) terrain.exe ; $(LN) src/terrain.exe . ) ;
3. 编译
# make intel
# make terrain.deck
若成功,会出现:
90 Lines Compiled
/bin/rm -f rdnml.f
ifc rdnml.o -i_dynamic -o rdnml
make[1]: Exiting directory `$home/mm5v3/TERRAIN/src'
4.编辑 terrain.deck
高亮部分为需要修改的地方,修改后要重新编译
cat > src/parame.incl.tmp << EOF
C IIMX,JJMX are the maximum size of the domains, NSIZE = IIMX*JJMX
PARAMETER (IIMX = 100, JJMX = 100, NSIZE = IIMX*JJMX)
EOF
cat > src/paramed.incl.tmp << EOF
PARAMETER (ITRH = 500, JTRH = 500, NOBT = ITRH*JTRH)
C PARAMETER (ITRH = 1500, JTRH = 1800, NOBT = ITRH*JTRH)
EOF
#
# --------------------------------------------------------------
# 2. Set up NAMELIST
# --------------------------------------------------------------
#
if ( -e terrain.namelist ) rm terrain.namelist
cat > terrain.namelist << EOF
&MAPBG
PHIC= 36.0, ; CENTRAL LATITUDE (minus for southern hemesphere)
XLONC= -85.0, ; CENTRAL LONGITUDE (minus for western hemesphere)
IEXP= .F., ; .T. EXPANDED COARSE DOMAIN, .F. NOT EXPANDED.
; USEFUL IF RUNNING RAWINS/little_r
AEXP = 360., ; APPROX EXPANSION (KM)
IPROJ= 'LAMCON', ; LAMBERT-CONFORMAL MAP PROJECTION
;IPROJ = 'POLSTR', ; POLAR STEREOGRAPHIC MAP PROJECTION
;IPROJ = 'MERCAT', ; MERCATOR MAP PROJECTION
&END
&DOMAINS
;
MAXNES= 2, ; NUMBER OF DOMAINS TO PROCESS
NESTIX= 35, 49, 136, 181, 211, 221, ; GRID DIMENSIONS IN Y DIRECTION
NESTJX= 41, 52, 181, 196, 211, 221, ; GRID DIMENSIONS IN X DIRECTION
DIS= 90., 30., 9., 3.0, 1.0, 1.0, ; GRID DISTANCE
NUMNC= 1, 1, 2, 3, 4, 5, ; MOTHER DOMAIN ID
NESTI= 1, 10, 28, 35, 45, 50, ; LOWER LEFT I OF NEST IN MOTHER DOMAIN
NESTJ= 1, 17, 25, 65, 55, 50, ; LOWER LEFT J OF NEST IN MOTHER DOMAIN
RID = 1.5, 1.5, 1.5, 3.1, 2.3, 2.3, ; RADIUS OF INFLUENCE IN GRID UNITS (IFANAL=T)
NTYPE= 2, 3, 4, 6, 6, 6, ; INPUT DATA RESOLUTION
;
; 1: 1 deg (~111 km) global terrain and landuse
; 2: 30 min ( ~56 km) global terrain and landuse
; 3: 10 min ( ~19 km) global terrain and landuse
; 4; 5 min ( ~9 km) global terrain and landuse
; 5; 2 min ( ~4 km) global terrain and landuse
; 6; 30 sec ( ~.9 km) global terrain and landuse
;
NSTTYP= 1, 2, 2, 2, 2, 2, ; 1 -- ONE WAY NEST, 2 -- TWO WAY NEST
&END
&OPTN
IFTER= .TRUE., ; .T.-- TERRAIN, .F.-- PLOT DOMAIN MAPS ONLY
IFANAL = .F., ; .T.-- OBJECTIVE ANALYSIS, .F.-- INTERPOLATION
ISMTHTR = 2 , ; 1: 1-2-1 smoother, 2: two pass smoother/desmoother
IFEZFUG = .F., ; .T. USE NCAR GRAPHICS EZMAP WATER BODY INFO TO FUDGE THE LAND USE
; .F. USE LANDWATER MASK DATA
IFTFUG = .F., ; .T. DON'T DO EZFUDGE WITHIN THE USER-SPECIFIED
; LAT/LON BOXES, need to define namelist fudget
IFFUDG = .F., ; .T. POINT-BY-POINT FUDGING OF LANDUSE,
; need to define namelist fudge
IPRNTD = .F., ; PRINT OUT LAT. AND LON. ON THE MESH
IPRTHT = .F., ; PRINT OUT ALL PROCESSING FIELDS ON THE MESH
IPRINT = 0, ; = 1: A LOT MORE PRINT OUTPUT IN terrain.print.out
FIN = 100., 100., 100., 100., 100., 100., ; CONTOUR INTERVAL (meter) FOR TERRAIN HEIGHT PLOT
;TRUELAT1=91., ; TRUE LATITUDE 1
;TRUELAT2=91., ; TRUE LATITUDE 2, use this if IPROJ='LAMCON'
IFILL= .TRUE., ; .TRUE. --- color filled plots
LSMDATA= .FALSE., ; .TRUE. --- Create the data for LSM
VEGTYPE= 1, ; LANDUSE DATA TYPE: =0: old 13 cat; =1: 24 cat USGS; =2: 16 cat SiB
VSPLOT= .TRUE., ; .TRUE. --- plot Vege., Soil, Vege. Frc. percentages.
IEXTRA= .FALSE., ; .TRUE. --- Create extra data for Pleim-Xiu LSM
&END
根据需要修改里面的参数,然后输入命令
# mv terrain.deck.intel terrain.deck
5.运行
# ./terrain.deck
若成功,会出现:
mon may 29 14:18:43 CET 2013
./terrain.exe
rm fort.15 fort.16 fort.18
若成功,输出日志文件最后会出现:
== NORMAL TERMINATION OF TERRAIN PROGRAM ==
FORTRAN STOP 9999
并产生TERRAIN_DOMAIN1、TERRAIN.DOMAIN2..等文件
6.画图
# idt TER.PLT
如果对输出结果不满意则再编辑terrain.deck,然后重新运行
3.2.2编译运行 REGRID
1.编辑Makefile
将原文中的下列代码
intel:
echo "Compiling for Linux using INTEL compiler" ; \
>> macros_pregrid ; \
echo "FC = pgf90" >> macros_pregrid ; \
echo "FCFLAGS = -Mfreeform -byteswapio -I../util" >> macros_pregrid ; \
echo "LDFLAGS = " >> macros_pregrid ; \
echo "CCFLAGS = -DDEC -DBIT32 -I. -DSGI_IA64">> macros_pregrid ; \
echo "LOCAL_LIBRARIES = ../util/libpgu.a" >> macros_pregrid ; \
>> macros_regridder ; \
echo "FC = pgf90" >> macros_regridder ; \
echo "FCFLAGS = -Mfreeform -pc 32 -byteswapio">> macros_regridder ; \
echo "LDFLAGS = " >> macros_regridder ; \
echo "CCFLAGS = -DDEC -DBIT32 -I. " >> macros_regridder ; \
echo "LOCAL_LIBRARIES = " >> macros_regridder ; \
( $(CD) regridder ; $(MAKE) all ) ; \
改为
intel:
echo "Compiling for Linux using INTEL compiler" ; \
>> macros_pregrid ; \
echo "FC = ifort" >> macros_pregrid ; \
echo "FCFLAGS = -FR -I../util -convert big_endian -DDEC_ALPHA" >> macros_pregrid ; \
echo "LDFLAGS = -i_dynamic" >> macros_pregrid ; \
echo "CCFLAGS = -DDEC -DBIT32 -I. -DSGI_IA64">> macros_pregrid ; \
echo "LOCAL_LIBRARIES = ../util/libpgu.a" >> macros_pregrid ; \
>> macros_regridder ; \
echo "FC = ifort" >> macros_regridder ; \
echo "FCFLAGS = -FR -pc 32 -convert big_endian -DDEC_ALPHA">> macros_regridder ; \
echo "LDFLAGS = -i_dynamic" >> macros_regridder ; \
echo "CCFLAGS = -DDEC -DBIT32 -I. -DSGI_IA64" >> macros_regridder ; \
echo "LOCAL_LIBRARIES = " >> macros_regridder ; \
( $(CD) regridder ; $(MAKE) all ) ; \
2.编译
# make intel>&make.out
如果编译成功会生成四个文件pregrid_on84.exe、pregrid_navy.exe、pregrid_ncep.exe、pregrid_grib.exe
3.编辑运行pregrid.csh
# cd pregrid
# gedit pregrid.csh
根据输入的数据编辑 pregrid.csh 修改以下内容
set DataDir = /mm5/REGRID/pregrid/MM5DATA
# set SRC3D = ON84 # Old ON84-formatted NCEP GDAS analyses
# set SRC3D = NCEP # Newer GRIB-formatted NCEP GDAS analyses
set SRC3D = GRIB # Many GRIB-format datasets
set InFiles = ( ${DataDir}/fnl* )
# Specify the source of SST analyses
# set SRCSST = ON84
# set SRCSST = NCEP
# set SRCSST = NAVY
set SRCSST = $SRC3D
set InSST = ( )
# Select the source of snow-cover analyses (entirely optional)
set SRCSNOW = $SRC3D
# set SRCSNOW = ON84
# set SRCSNOW = GRIB
set InSnow = ()
# Select the source of soil model analyses (entirely optional)
# set SRCSOIL = $SRC3D
# set InSoil = ()
&record1
# Set the starting date of the time period you want to process:
START_YEAR = 2003 # Year (Four digits)
START_MONTH = 07 # Month ( 01 - 12 )
START_DAY = 04 # Day ( 01 - 31 )
START_HOUR = 00 # Hour ( 00 - 23 )
END_YEAR = 2003 # Year (Four digits)
END_MONTH = 07 # Month ( 01 - 12 )
END_DAY = 06 # Day ( 01 - 31 )
END_HOUR = 00 # Hour ( 00 - 23 )
# Define the time interval to process.
INTERVAL = 10800 # Time interval (seconds) to process/
End_Of_Namelist
# table表修改内容
set VT3D = ( grib.misc/Vtable.AVN3D )
set VTSST = ( grib.misc/Vtable.AVNSST )
set VTSNOW = ( grib.misc/Vtable.AVNSNOW )
set VTSOIL = ( grib.misc/Vtable.xxxSOIL )
修改完成后输入
# ./pregrid.csh
如果成功,最后会显示
Normal termination of program PREGRID_****
4.编辑namelist.input
# cd ../regridder
根据输入数据编辑 namelist.input
&record1
start_year = 2003
start_month = 07
start_day = 04
start_hour = 00
end_year = 2003
end_month = 07
end_day = 06
end_hour = 00
interval = 10800 /
&record2
ptop_in_Pa = 10000
new_levels_in_Pa = 95000 , 92500 , 90000 , 80000 , 75000 , 65000 , 60000 ,55000 , 45000 , 35000
sst_to_ice_threshold = -9999
linear_interpolation = .FALSE. /
&record3
root = '../pregrid/FILE' '../pregrid/SST_FILE' '../pregrid/SNOW_FILE'
terrain_file_name = '../../TERRAIN/TERRAIN_DOMAIN1' /
constants_full_name = './ALMX_FILE' '../pregrid/SST_FILE:2003-07-04_00'
5.运行regridder
编辑完成namelist.input后输入
# ./regridder
如果成功,regridder目录下会出现
-rw-r--r-- 1 mesouser users 2177888 Mar 17 18:26 REGRID_DOMAIN1
3.2.3编译运行Little_r
1.修改Makefile
将原文中的代码
intel:
echo "FC = pgf90" >> macros_little_r ; \
echo "FCFLAGS = -I. -byteswapio -pc 32 " >> macros_little_r ; \
echo "LDFLAGS = -pc 32" >> macros_little_r ; \
echo "CCFLAGS = -I." >> macros_little_r ; \
echo "LOCAL_LIBRARIES = -L$(NCARG_ROOT)/lib -L/usr/X11R6/lib -lncarg -lncarg_gks -lncarg_c -lX11 -L/usr/lib/gcc-lib/i386-redhat-linux/3.3.2 -lf2c"
改为
intel:
echo "FC = ifort" >> macros_little_r ; \
echo "FCFLAGS = -FR -pc 32 -convert big_endian" >> macros_little_r ; \
echo "LDFLAGS = -i_dynamic" >> macros_little_r ; \
echo "CCFLAGS = -DDEC -I." >> macros_little_r ; \
echo "LOCAL_LIBRARIES = -L$(NCARG_ROOT)/lib -L/usr/X11R6/lib -lncarg -lncarg_gks -lncarg_c -lX11 -L/usr/lib/gcc/x86_64-redhat-linux/4.1.1 -lgfortran"
2.编译
#make intel>&make.out
如果编译成功会生成可执行文件little_r
3.编辑namelist.input
根据实际情况修改下列参数:起始日期,地面观测资料、探空资料的目录
&record1
start_year = 2003
start_month = 07
start_day = 04
start_hour = 00
end_year = 2003
end_month = 07
end_day = 06
end_hour = 00
interval = 10800/
&record2
fg_filename = '../REGRID/regridder/REGRID_DOMAIN1'
obs_filename = '/mm5/REGRID/pregrid/MM5DATA/OBS-2003070400'
'/mm5/REGRID/pregrid/MM5DATA/OBS-2003070406'
'/mm5/REGRID/pregrid/MM5DATA/OBS-2003070412'
sfc_obs_filename = '/mm5/REGRID/pregrid/MM5DATA/SURFACE_OBS_2003070400' '/mm5/REGRID/pregrid/MM5DATA/SURFACE_OBS_2003070406' '/mm5/REGRID/pregrid/MM5DATA/SURFACE_OBS_2003070412'/
4.运行
./little_r>&log
如果成功则会生成log文件,在log文件的结尾会显示STOP 99999
同时在little_r目录下会生成LITTLE_R_DOMAIN文件
-rw-r--r-- 1 mesouser users 1825164 Jan 7 08:13 LITTLE_R_DOMAIN1
3.2.4编译运行INTERPF
1.修改Makefile
将原文中代码
intel:
echo "Compiling for Linux with INTEL compiler" ; \
echo "FC = pgf90" >> macros_interpf ; \
echo "FCFLAGS = -Mfreeform -pc 32 -byteswapio" >> macros_interpf ; \
echo "LDFLAGS = " >> macros_interpf ; \
改为
intel:
echo "Compiling for Linux with INTEL compiler" ; \
echo "FC = ifort" >> macros_interpf ; \
echo "FCFLAGS = -FR -pc 32 -convert big_endian" >> macros_interpf ; \
echo "LDFLAGS = -i_dynamic" >> macros_interpf ; \
2.编译
#cd interpf
# ./make intel>&make.out
如果编译成功会生成可执行文件interpf
3.修改namelist.input
根据实际情况,修改namelist.input ,
&record0
input_file = '../LITTLE_R/LITTLE_R_DOMAIN1' / ! pressure-level data file name
&record1
start_year = 2003 ! The starting and
start_month = 07 ! ending dates to
start_day = 04 ! process
start_hour = 00
end_year = 2003
end_month = 07
end_day = 06
end_hour = 00
interval = 10800 ! time difference (s)
less_than_24h = .FALSE. / ! if input is less than 24 h
&record2
sigma_f_bu = 1.00,0.99,0.98,0.96,0.93,0.89, ! full sigma, bottom-up,
0.85,0.80,0.75,0.70,0.65,0.60, ! start with 1.0, end
0.55,0.50,0.45,0.40,0.35,0.30, ! with 0.0
0.25,0.20,0.15,0.10,0.05,0.00
ptop = 10000 ! top pressure if need to be redefined
isfc = 1 / ! # sigma levels to spread surface information
4.运行
# ./interpf>&log
若成功,log文件最后显示
-------------------------------------------------
FINISHED INTERPF FOR DOMAIN ID #1
-------------------------------------------------
STOP 99999
在INTERPF目录下也会产生三个文件
-rw-r--r-- 1 mesouser users 1825164 Jan 7 08:13 BDYOUT_DOMAIN1
-rw-r--r-- 1 mesouser users 170936 Jan 7 08:13 LOWBDY_DOMAIN1
-rw-r--r-- 1 mesouser users 2889044 Jan 7 08:13 MMINPUT_DOMAIN1
3.2.5编译运行MM5
1.MM5 输入数据
要运行MM5需要以下数据,并要把数据复制或者链接到 MM5/Run/中:
INTERPF的输出数据MMINPUT_DOMAIN1、BDYOUT_DOMAIN1、LOWBDY_DOMAIN1
TERRAIN的输出数据TERRAIN_DOMAIN*
注:其中“*”为 2、3、4……
2.编辑 configure.user
# gedit configure.user
找到下面这段,把"#"去掉
#--------------------------------------------------------------------------
# 3i2. PC_INTEL (LINUX/INTEL)
#--------------------------------------------------------------------------
#RUNTIME_SYSTEM = "linux"
#FC = ifort
#FCFLAGS = -I$(LIBINCLUDE) -O2 -tp p6 -pc 32 -convert big_endian
#CPP = /lib/cpp
#CFLAGS = -O
#CPPFLAGS = -I$(LIBINCLUDE)
#LDOPTIONS = -i_dynamic -O2 -tpp6 -pc32
#LOCAL_LIBRARIES =
#MAKE = make -i -r
找到以下段,一般需要根据TERRAIN的设置修改。MAXNES 为区域的数量,MIX和MJX 为最大网格数
#--------------------------------------------------------------------------
# 5. Options for making ./include/parame.incl
#-----------------------------------------------------------------------------
# FDDAGD (integer) - "1" -> FDDA gridded run
FDDAGD = 0
# FDDAOBS (integer) - "1" -> FDDA obs run
FDDAOBS = 0
# MAXNES (integer) - Max Number of Domains in simulation
MAXNES = 2
# MIX,MJX (integer) - Maximum Dimensions of any Domain
MIX = 49
MJX = 52
# MKX (integer) - Number of half sigma levels in model
MKX = 23
3.编译
# make>&make.out
若编译成功在Run目录下会生成可执行文件mm5.exe
4.编辑mm5.deck
#make mm5.deck
根据需要编辑 mm5.deck ,一般需要更改一下两项内容
************* FORECAST TIME AND TIME STEP ******************
TIMAX = 720., ; forecast length in minutes
TISTEP = 60., ; coarse domain DT in model, use 3*DX
************** NEST AND MOVING NEST OPTIONS ***************
LEVIDN = 0,1,1,1,1,1,1,1,1,1, ; level of nest for each domain
NUMNC = 1,1,1,1,1,1,1,1,1,1, ; ID of mother domain for each nest
NESTIX = 88, 97, 31, 46, 46, 46, 46, 46, 46, 46, ; domain size i
NESTJX = 97, 97, 31, 61, 61, 61, 61, 61, 61, 61, ; domain size j
NESTI = 1, 29, 8, 1, 1, 1, 1, 1, 1, 1, ; start location i
NESTJ = 1, 35, 9, 1, 1, 1, 1, 1, 1, 1, ; start location i
XSTNES = 0., 0.,900., 0., 0., 0., 0., 0., 0., 0., ; domain initiation
XENNES =1440.,1440.,1440.,720.,720.,720.,720.,720.,720.,720.; domain termination
IOVERW = 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, ; overwrite nest input
; 0=interpolate from coarse mesh (for nest domains);
; 1=read in domain initial conditions
; 2=read in nest terrain file
IACTIV = 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, ;
; in case of restart: is this domain active?
;
5.运行
# ./mm5.deck
# cd Run
# ./mm5.exe
如果成功则会出现:
--- MODEL OUTPUT IS WRITTEN AT TIME = 720.00 MINUTES FOR DOMAIN 1
--- MODEL OUTPUT IS WRITTEN AT TIME = 720.00 MINUTES FOR DOMAIN 2
+++ REWINDING SAVE FILE FOR DOMAIN 1
+++ RESTART FILE IS WRITTEN AT TIME = 720.00 MINUTES FOR DOMAIN1. IXTIMR = 720
+++ REWINDING SAVE FILE FOR DOMAIN 2
+++ RESTART FILE IS WRITTEN AT TIME = 720.00 MINUTES FOR DOMAIN2. IXTIMR = 720
FORTRAN STOP 99999
并且可以在 MM5/Run下面看到 MMOUT_DOMAIN*文件 ,其中“*”为1,2,3……