Sunteți pe pagina 1din 18

How to Install WRF Model

On Ubuntu

Compute System.

Technological development and Digitization.

Hydro and Agro Informatics Institute (HAII).

Compute System. 2 January 2019


CONTENTS
1. Objective.................................................................................................................................................................3
2. Scope.......................................................................................................................................................................3
3. Definition.................................................................................................................................................................3
4. Device......................................................................................................................................................................3
5. Operating Procedures..........................................................................................................................................4
5.1. Open ssh client for connect Linux Ubuntu...........................................................................................4
5.2. Install Preferred software...........................................................................................................................4
5.3. Install gcc compiler, version 5..................................................................................................................4
5.4. Install C++ compiler, version 5.................................................................................................................4
5.5. Install gfortran compiler, version 5..........................................................................................................5
5.6. Directory Structure.......................................................................................................................................5
5.7. Install Preferred Library..............................................................................................................................5
5.7.1 Install netcdf Library............................................................................................................................5
5.7.2 Install mpich Library............................................................................................................................6
5.7.3 Install zlib Library.................................................................................................................................7
5.7.4 Install libpng Library............................................................................................................................8
5.7.5 Install Jasper Library............................................................................................................................8
5.7.6 Install ncl Library..................................................................................................................................9
5.8. Install WRF...................................................................................................................................................11
5.8.1 install WRF...........................................................................................................................................11
5.8.2 Install WPS...........................................................................................................................................12
5.9. Create Directory for Geography Data....................................................................................................13
5.10. Create directory for Real-time Data....................................................................................................14
5.11. Run WPS and WRFV3..............................................................................................................................14
5.11.1. Running WPS....................................................................................................................................14
5.11.2. Running WRF....................................................................................................................................15
5.11.3. list data inside wrfout....................................................................................................................17
5.11.4. Create pdf from wrfout.................................................................................................................17
5.12. Summary...................................................................................................................................................18
How to Install WRF Model On Ubuntu Version 18.04.

1. Objective.
To understand about WRF installation.

2. Scope.
Installation WRF Model On Ubuntu.

3. Definition.
Ubuntu is linux operating system.
WRF Model is Weather Research Forecast Model for predict wind direction.
REFERENCES (https://www.enviroware.com/installing-and-running-wrf-3-8-on-linux-ubuntu-lts-16-04-
with-intel-i7-8-core-cpu/) and (https://tool.qlsmc.xyz/blog/2018/11/29/wrf-installation/)

4. Device.
Linux Ubuntu version 18.04 have available space is 80G
5. Operating Procedures.
5.1. Open ssh client for connect Linux Ubuntu.
ssh ubuntu@192.168.150.195
Update repository.
$ sudo apt update

5.2. Install Preferred software.


Install preferred software by command.
$ sudo apt install csh m4 build-essential nasm cmake unzip libxmu-dev libcairo-dev libbz2-
dev libxaw7-dev libx11-dev xorg-dev flex bison libhdf5-mpich-dev libpng-dev libnetcdff-dev
netcdf-bin zlib1g-dev

5.3. Install gcc compiler, version 5.


Install gcc compiler by command.
$ sudo apt install gcc-5
And set symlink gcc version 5 to /usr/bin/gcc
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50
And check version.
$ gcc --version
See version 5 is good.
5.4. Install C++ compiler, version 5.
Install C++ compiler by command.
$ sudo apt install g++-5
And set symlink g++ version 5 to /usr/bin/g++
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 50
$ sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-5 50
And check version.
$ g++ --version
$ cpp --version
See version 5 is good.
5.5. Install gfortran compiler, version 5.
Install gfortran compiler by command.
$ sudo apt install gfortran-5
And set symlink gfortran version 5 to /usr/bin/gfortran
$ sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-5 50
And check version.
$ gfortran --version
See version 5 is good.
5.6. Directory Structure.
Build_WRF Main Directory.
|--LIBRARIES Library Directory.
|--geos Geography Data and mount to /data/geos
|--DATA Directory for Real-time Data.
|--src Directory for Source Code.

5.7. Install Preferred Library.


Preferred Library include
 netcdf
 mpich
 zlib
 libpng
 Jasper

5.7.1 Install netcdf Library.


Define variable for install netcdf library.
$ export DIR=~/Build_WRF/LIBRARIES
$ export CC=gcc
$ export CXX=g++
$ export FC=gfortran
$ export FCFLAGS='-m64'
$ export F77=gfortran
$ export FFLAGS='-m64'
Create source code directory and change to directory.
$ mkdir -p ~/Build_WRF/src
$ cd ~/Build_WRF/src

Download Source Code.


$ wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.1.3.tar.gz

Uncompress Source Code and Compile.


$ tar xzvf netcdf-4.1.3.tar.gz
$ cd netcdf-4.1.3
$ ./configure --prefix=$DIR/netcdf --disable-dap --disable-netcdf-4 --disable-shared
$ make -j2
$ make install

Create PATH variable in file .bash_profile.


$ vi ~/.bash_profile
Type and save.
### netcdf
export PATH=~/Build_WRF/LIBRARIES/netcdf/bin:$PATH
export NETCDF=~/Build_WRF/LIBRARIES/netcdf

update PATH variable.


$ source ~/.bash_profile

5.7.2 Install mpich Library.


Create source code directory and change to directory.
$ cd ~/Build_WRF/src

Download Source Code.


$ wget https://www.mpich.org/static/downloads/3.2/mpich-3.2.tar.gz

Uncompress Source Code and Compile.


$ tar -xzvf mpich-3.2.tar.gz
$ cd mpich-3.2
$ ./configure --prefix=$DIR/mpich
$ make -j2
$ make install
Create PATH variable in file .bash_profile.
$ vi ~/.bash_profile
Type and save.
### mpich
export PATH=~/Build_WRF/LIBRARIES/mpich/bin:$PATH

update PATH variable.


$ source ~/.bash_profile

5.7.3 Install zlib Library.


Define variable for install zlib library.
$ export LDFLAGS='-L$DIR/grib2/lib'
$ export CPPFLAGS='-I$DIR/grib2/include'

change to source code directory.


$ cd ~/Build_WRF/src

Download Source Code


$ wget http://www.zlib.net/fossils/zlib-1.2.8.tar.gz

Uncompress Source Code and Compile.


$ tar xzvf zlib-1.2.8.tar.gz
$ cd zlib-1.2.8
$ ./configure --prefix=$DIR/grib2
$ make -j2
$ make install
5.7.4 Install libpng Library.
change to source code directory.
$ cd ~/Build_WRF/src

Download Source Code


$ wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.34.tar.gz

Uncompress Source Code and Compile.


$ tar xzvf libpng-1.6.34.tar.gz
$ cd libpng-1.6.34
$ export LDFLAGS="-L$DIR/grib2/lib"
$ export CPPFLAGS="-I$DIR/grib2/include"
$ ./configure --prefix=$DIR/grib2
$ make -j2
$ make install

Create PATH variable in file .bash_profile.


$ vi ~/.bash_profile
Type and save.
### libpng
export LD_LIBRARY_PATH=~/Build_WRF/LIBRARIES/grib2/lib:$LD_LIBRARY_PATH

update PATH variable.


$ source ~/.bash_profile

5.7.5 Install Jasper Library.


change to source code directory.
$ cd ~/Build_WRF/src

Download Source Code.


$ wget http://www.ece.uvic.ca/~mdadams/jasper/software/jasper-1.900.1.zip
Uncompress Source Code and Compile.
$ unzip jasper-1.900.1.zip
$ cd jasper-1.900.1
$ ./configure --prefix=$DIR/grib2
$ make -j2
$ make install

Create PATH variable in file .bash_profile.


$ vi ~/.bash_profile
Type and save.
### jasper
export PATH=~/Build_WRF/LIBRARIES/grib2/bin:$PATH

update PATH variable.


$ source ~/.bash_profile

5.7.6 Install ncl Library.


change to source code directory.
$ cd ~/Build_WRF/src

Download ncarg from NCAR web site : http://www.ncl.ucar.edu/Download/


$ wget https://www.earthsystemgrid.org/dataset/ncl.650.src/file/ncl_ncarg-6.5.0.tar.gz

Uncompress ncarg.
$ tar -xvzf ncl_ncarg-6.5.0.tar.gz
$ cd ncl_ncarg-6.5.0
$ sudo ln -sf /usr/include/freetype2/ft2build.h /usr/include/
$ sudo ln -sf /usr/include/freetype2/freetype /usr/include/
Configuration ncarg.
$ ./Configure
Enter Return to continue, or q(quit) >
# options :
Build NCL (y)? y
Parent installation directory : /home/ubuntu/Build_WRF/LIBRARIES/ncl
System temp space directory : /tmp (default)
Build NetCDF4 feature support (optional)? (y) n
Build HDF4 support (optional) into NCL? (y) n
Also build HDF4 support (optional) into raster library? (y) n
Build Triangle support (optional) into NCL (n) n
If you are using NetCDF V4.x, did you enable NetCDF-4 support ? (y) n
Did you build NetCDF with OPeNDAP support ? (n) n
Build GDAL support (optional) into NCL? (y) n
Build EEMD support (optional) into NCL? (y) n
Build Udunits-2 support (optional) into NCL (n) n
Build Vis5d+ support (optional) into NCL (n) n
Build HDF-EOS2 support (optional) into NCL (n) n
Build HDF5 support (optional) into NCL (y) n
Build HDF-EOS5 support (optional) into NCL (n) n
Build GRIB2 support (optional) into NCL (n) n
Enter local library search path(s) : /usr/lib/x86_64-linux-gnu
Enter local include search path(s) : /usr/include/X11
Go back and make more changes or review? (n) n
Save current configuration ? (y) y

Build ncarg.
$ make Everything >& make-output &

Create PATH variable in file .bash_profile.


$ vi ~/.bash_profile
Type and save.
### ncl
export NCARG_ROOT=~/Build_WRF/LIBRARIES/ncl
export PATH=$NCARG_ROOT/bin:$PATH
update PATH variable.
$ source ~/.bash_profile

Test ncl.
$ ncl -V
Show version 6.5.0 is good.

5.8. Install WRF.


5.8.1 install WRF.
Create PATH variable in file .bash_profile.
$ vi ~/.bash_profile
Type and save.
### WRF
ulimit -s unlimited
export MALLOC_CHECK_=0
export WRF_EM_CORE=1
export WRFIO_NCD_LARGE_FILE_SUPPORT=1

update PATH variable.


$ source ~/.bash_profile

Change to WRF directory.


$ cd ~/Build_WRF/

Download Source Code.


$ wget http://www2.mmm.ucar.edu/wrf/src/WRFV3.9.TAR.gz
Uncompress Source Code and Configure WRF.
$ tar -xvzf WRFV3.9.TAR.gz
$ cd WRFV3
$ ./configure

select 34. (dmpar) GNU (gfortran/gcc)


Enter selection [1-75] : 34

and nesting is 1.
Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]: 1

edit configure.wrf file.


$ vi configure.wrf
CPP = cpp -P -nostdinc

Complie em_real mode.


$ ./compile em_real >& log.compile

Wait for finish test by


$ ls -lah main/*.exe
If you see real.exe and wrf.exe then correct. Else check Error in log.compile file.
5.8.2 Install WPS.
Change to directory.
$ cd ~/Build_WRF/

Download Source Code.


$ wget http://www2.mmm.ucar.edu/wrf/src/WPSV3.9.TAR.gz

Uncompress Source Code.


$ tar -xvzf WPSV3.9.TAR.gz

Define variable.
$ cd WPS
$ export JASPERLIB=$DIR/grib2/lib
$ export JASPERINC=$DIR/grib2/include
Configure WPS.
$ ./configure

select 3. Linux x86_64, gfortran (dmpar)


Enter selection [1-40] : 3

edit configure.wps file. Change DM_FC to mpif90 and Append -lgomp in WRF_LIB.
$ vi configure.wps
COMPRESSION_LIBS = -L/home/ubuntu/Build_WRF/LIBRARIES/grib2/lib -ljasper -lpng -lz
COMPRESSION_INC = -I/home/ubuntu/Build_WRF/LIBRARIES/grib2/include
DM_FC = mpif90
WRF_LIB = -L$(WRF_DIR)/external/io_grib1 -lio_grib1 \
-L$(WRF_DIR)/external/io_grib_share -lio_grib_share \
-L$(WRF_DIR)/external/io_int -lwrfio_int \
-L$(WRF_DIR)/external/io_netcdf -lwrfio_nf \
-L$(NETCDF)/lib -lnetcdff -lnetcdf -lgomp

Complie WPS.
$ ./compile >& log.compile

Wait for finish test by


$ ls -lah *.exe
If you see geogrid.exe metgrid.exe and ungrib.exe then correct. Else check Error in log.compile file.

5.9. Create Directory for Geography Data.


Change Directory.
$ cd ~/Build_WRF/

Downlaod Geography Data.


$ wget http://www2.mmm.ucar.edu/wrf/src/wps_files/geog_complete.tar.gz

Uncompress Geography Data.


$ tar -xvzf geog_complete.tar.gz
5.10. Create directory for Real-time Data.
Create Real-time Data Directory and Change to Directory.
$ mkdir -p ~/Build_WRF/DATA
$ cd ~/Build_WRF/DATA

Download Data.
$ wget http://hydro.haii.or.th/tmp/WRF/gfs.t00z.pgrb2.0p50.f000
$ wget http://hydro.haii.or.th/tmp/WRF/gfs.t00z.pgrb2.0p50.f006
Or update Real-time from web site ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/

5.11. Run WPS and WRFV3.


5.11.1. Running WPS
Change Directory to WPS directory.
$ cd ~/Build_WRF/WPS

Download namelist.wps file from http://hydro.haii.or.th/tmp/WRF/namelist.wps


$ rm namelist.wps
$ wget http://hydro.haii.or.th/tmp/WRF/namelist.wps

Edit namelist.wps section max_dom, start_date, end_date same Real-time Data and set
geog_data_path to Geography Data.
$ vi namelist.wps
&share
wrf_core = 'ARW',
max_dom = 1,
start_date = '2017-05-17_00:00:00','2006-08-16_12:00:00',
end_date = '2017-05-17_06:00:00','2006-08-16_12:00:00',
interval_seconds = 10800
io_form_geogrid = 2,
/

geog_data_path = '../../Build_WRF/geog/'

Create Geography Data.


$ ./geogrid.exe
Wait for finish test by
$ ls -lah geo_em.d01.nc
If you see geo_em.d01.nc is coreect.

link Real-time Data top WPS.


$ ./link_grib.csh ~/Build_WRF/DATA/gfs.t00z.pgrb2.0p50.f0*

link Vtable
$ ln -sf ungrib/Variable_Tables/Vtable.GFS Vtable

create grib file.


$ ./ungrib.exe

Wait for finish test by


$ ls -lah FILE*
If you see FILE* is coreect.

create met file.


$ ./metgrid.exe

Wait for finish test by


$ ls -lah met_em.*
If you see met_em.* is coreect.

5.11.2. Running WRF.


Change Directory to WRF directory.
$ cd ~/Build_WRF/WRFV3/test/em_real/

link met file from WPS to WRF.


$ ln -sf ~/Build_WRF/WPS/met_em* .

Download namelist.input from http://hydro.haii.or.th/tmp/WRF/namelist.input


$ rm namelist.input
$ wget http://hydro.haii.or.th/tmp/WRF/namelist.input
Edit namelist.input in section run_hours, start_year, start_month, start_day, start_hour, end_year,
end_month, end_day, end_hour and num_metgrid_levels.
$ vi namelist.input
&time_control
run_days = 0,
run_hours = 6,
run_minutes = 0,
run_seconds = 0,
start_year = 2017, 2000, 2000,
start_month = 05, 01, 01,
start_day = 17, 24, 24,
start_hour = 00, 12, 12,
start_minute = 00, 00, 00,
start_second = 00, 00, 00,
end_year = 2017, 2000, 2000,
end_month = 05, 01, 01,
end_day = 17, 25, 25,
end_hour = 06, 12, 12,
end_minute = 00, 00, 00,
end_second = 00, 00, 00,
interval_seconds = 10800

&domains
time_step = 150,
time_step_fract_num = 0,
time_step_fract_den = 1,
max_dom = 1,
e_we = 74, 112, 94,
e_sn = 61, 97, 91,
e_vert = 30, 30, 30,
p_top_requested = 5000,
num_metgrid_levels = 32,

create real case.


$ mpirun -np 1 ./real.exe

Wait for finish test by


$ tail rsl.error.0000
If you see real_em: SUCCESS COMPLETE REAL_EM INIT is coreect.

And see file wrfbdy_d01 wrfinput_d01.


$ ls -alh wrfbdy_d01 wrfinput_d01
If you see wrfbdy_d01 and wrfinput_d01 is coreect.

Run WRF
$ mpirun -np 2 ./wrf.exe

Wait for finish test by


$ tail rsl.error.0000
If you see wrf: SUCCESS COMPLETE WRF is coreect.

And see file wrfout_*


$ ls -alh wrfout_*
If you see wrfout_* is coreect.

5.11.3. list data inside wrfout.


$ ncdump -h wrfout_d01*
$ ncdump -v Times wrfout_d01*
$ ncdump -v U wrfout_d01*

5.11.4. Create pdf from wrfout.


Change Directory
$ cd ~/Build_WRF/

Download ncl script.


$ wget http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Graphics/NCL/Examples/PRECIP/wrf_Precip.ncl
Edit ncl script in section a to location of wrfout file.
$ vi wrf_Precip.ncl
begin
;
; The WRF ARW input file.
; This needs to have a ".nc" appended, so just do it.
a = addfile("~/Build_WRF/WRFV3/test/em_real/wrfout_d01_2017-05-17_00:00:00","r")
; We generate plots, but what kind do we prefer?
; type = "x11"
type = "pdf"
; type = "ps"
; type = "ncgm"

Create PDF
$ ncl wrf_Precip.ncl
Output is plt_Precip.pdf, you can open pdf file from pdf viewer or download to your laptop.

5.12. Summary.

S-ar putea să vă placă și