WRF, the Weather Research and Forecasting Model, is a mesoscale numerical weather prediction system for meteorological applications across scales from tens of meters to thousands of kilometers. There are two main dynamical solvers, the ARW (Advanced Research WRF) core and the NMM (Nonhydrostatic Mesoscale Model) core. The WRF-ARW 3.8 was released in April 2016.

These are some installation notes taken in the process of installing WRF-ARW version 3.8 on a new Intel-based i7 8-core computer with Linux Ubuntu 16.04 LTS.

Install required software

Install csh:

 roberto@linux:~$ sudo apt-get install csh 

Install gfortran:

 roberto@linux:~$ sudo apt-get install gfortran 

Install m4:

 roberto@linux:~$ sudo apt-get install m4 

Install mpich:

 roberto@linux:~$ sudo apt-get install mpich 

Install HDF - MPICH version:

 roberto@linux:~$ sudo apt-get install libhdf5-mpich-dev 

Install libpng:

 roberto@linux:~$ sudo apt-get install libpng-dev 

Install JasPer JPEG-2000 library:

 roberto@linux:~$ sudo apt-get install libjasper-dev 

Install netCDF for Fortran:

 roberto@linux:~$ sudo apt-get install libnetcdff-dev 

Install ncdump:

 roberto@linux:~$ sudo apt-get install netcdf-bin 

Install ncl:

 roberto@linux:~$ sudo apt-get install ncl-ncarg 

Set environment variables

Update the database used by locate:

 roberto@linux:~$ sudo updatedb 

and locate the netcdf.inc file and the mpich/lib directory:

roberto@linux:~$ locate netcdf.inc
/usr/include/netcdf.inc

roberto@linux:~$ locate mpich/lib
/usr/lib/mpich/lib
...
                    

Modify the file .bashrc in the home directory of current user to set the environment variable NETCDF to the path preceeding include/netcdf.inc (in this case it is /usr).

At the bottom of the file .bashrc add these lines so that they will be set for future logins:

export NETCDF=/usr
export WRFIO_NCD_LARGE_FILE_SUPPORT=1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/mpich/lib
                    

Then source the file to make these settings active for current session:

 roberto@linux:~$ source .bashrc 

These settings can be checked by opening a new terminal and seeing if they are output by env:

roberto@linux:~$ env | grep NETC
NETCDF=/usr
roberto@linux:~$ env | grep WRF
WRFIO_NCD_LARGE_FILE_SUPPORT=1
roberto@linux:~$ env | grep LD
LD_LIBRARY_PATH=:/usr/lib/mpich/lib
                    

Download and compile WRF

In order to download the source code, it is necessary to be a registered user. This link provides the access to the registration as well as to the download for returning registered users.

The tar file with the WRF source code can be retrieved with wget from that directory, with the command

 roberto@linux:~/mod/WRF$ wget http://www2.mmm.ucar.edu/wrf/src/WRFV3.8.TAR.gz 

and it can be decompressed and its content extracted:

 roberto@linux:~/mod/WRF$ tar -ztfv WRFV3.8.TAR.gz 

After that, change to the WRFV3 directory and execute the configure script:

roberto@linux:~/mod/WRF/WRFV3$ ./configure
checking for perl5... no
checking for perl... found /usr/bin/perl (perl)
Will use NETCDF in dir: /usr
HDF5 not set in environment. Will configure WRF for use without.
PHDF5 not set in environment. Will configure WRF for use without.
Will use 'time' to report timing information
$JASPERLIB or $JASPERINC not found in environment, configuring to build without grib2 I/O...
------------------------------------------------------------------------
Please select from among the following Linux x86_64 options:

1. (serial)   2. (smpar)   3. (dmpar)   4. (dm+sm)   PGI (pgf90/gcc)
5. (serial)   6. (smpar)   7. (dmpar)   8. (dm+sm)   PGI (pgf90/pgcc): SGI MPT
9. (serial)  10. (smpar)  11. (dmpar)  12. (dm+sm)   PGI (pgf90/gcc): PGI accelerator
13. (serial)  14. (smpar)  15. (dmpar)  16. (dm+sm)   INTEL (ifort/icc)
17. (dm+sm)   INTEL (ifort/icc): Xeon Phi (MIC architecture)
18. (serial)  19. (smpar)  20. (dmpar)  21. (dm+sm)   INTEL (ifort/icc): Xeon (SNB with AVX mods)
22. (serial)  23. (smpar)  24. (dmpar)  25. (dm+sm)   INTEL (ifort/icc): SGI MPT
26. (serial)  27. (smpar)  28. (dmpar)  29. (dm+sm)   INTEL (ifort/icc): IBM POE
30. (serial)               31. (dmpar)                PATHSCALE (pathf90/pathcc)
32. (serial)  33. (smpar)  34. (dmpar)  35. (dm+sm)   GNU (gfortran/gcc)
36. (serial)  37. (smpar)  38. (dmpar)  39. (dm+sm)   IBM (xlf90_r/cc_r)
40. (serial)  41. (smpar)  42. (dmpar)  43. (dm+sm)   PGI (ftn/gcc): Cray XC CLE
44. (serial)  45. (smpar)  46. (dmpar)  47. (dm+sm)   CRAY CCE (ftn/cc): Cray XE and XC
48. (serial)  49. (smpar)  50. (dmpar)  51. (dm+sm)   INTEL (ftn/icc): Cray XC
52. (serial)  53. (smpar)  54. (dmpar)  55. (dm+sm)   PGI (pgf90/pgcc)
56. (serial)  57. (smpar)  58. (dmpar)  59. (dm+sm)   PGI (pgf90/gcc): -f90=pgf90
60. (serial)  61. (smpar)  62. (dmpar)  63. (dm+sm)   PGI (pgf90/pgcc): -f90=pgf90
64. (serial)  65. (smpar)  66. (dmpar)  67. (dm+sm)   INTEL (ifort/icc): HSW/BDW
68. (serial)  69. (smpar)  70. (dmpar)  71. (dm+sm)   INTEL (ifort/icc): KNL MIC

Enter selection [1-71] : 34
------------------------------------------------------------------------
Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]: 

Configuration successful!
------------------------------------------------------------------------
testing for MPI_Comm_f2c and MPI_Comm_c2f
MPI_Comm_f2c and MPI_Comm_c2f are supported
testing for fseeko and fseeko64
fseeko64 is supported
------------------------------------------------------------------------
...
                    

This generates a file named configure.wrf, where it is necessary to specify the information on the netcdf external libraries. This is done via the LIB_EXTERNAL variable:

 LIB_EXTERNAL    = \
     -L$(WRF_SRC_ROOT_DIR)/external/io_netcdf -lwrfio_nf -L/usr/local/lib -lnetcdff -lnetcdf
                    

Once this is set, it is possible to compile WRF for real cases

 roberto@linux:~/mod/WRF$ ./compile em_real >& compile.log & 

The ongoing compilation can be checked with:

roberto@linux:~/mod/WRF$ tail -f compile.log 

Download geographical dataset

The same procedure used for WRF can be used for WPS, the WRF Preprocessing System. Download and extract the WPS file:

roberto@linux:~/mod/WRF$ wget http://www2.mmm.ucar.edu/wrf/src/WPSV3.8.TAR.gz
roberto@linux:~/mod/WRF$ tar -zxvf WPSV3.8.TAR.gz
                    

Then create a directory named WPS_GEOG, and download into that directory the WPS geographical input dataset:

 roberto@linux:~/mod/WRF/WPS_GEOG$ wget http://www2.mmm.ucar.edu/wrf/src/wps_files/geog_complete.tar.bz2 

In alternative to the complete dataset, a reduced set of geographical dataset is available. Both archives are described in this page.

Compile WPS

WPS, the WRF Preprocessing System, can be compiled with the same procedure used for WRF. Serial compilation is sufficient.

roberto@linux:~/mod/WRF/WPS$ ./configure
Will use NETCDF in dir: /usr
$JASPERLIB or $JASPERINC not found in environment. Using default values for library paths...
------------------------------------------------------------------------
Please select from among the following supported platforms.

1.  Linux x86_64, gfortran    (serial)
2.  Linux x86_64, gfortran    (serial_NO_GRIB2)
3.  Linux x86_64, gfortran    (dmpar)
4.  Linux x86_64, gfortran    (dmpar_NO_GRIB2)
5.  Linux x86_64, PGI compiler   (serial)
6.  Linux x86_64, PGI compiler   (serial_NO_GRIB2)
7.  Linux x86_64, PGI compiler   (dmpar)
8.  Linux x86_64, PGI compiler   (dmpar_NO_GRIB2)
9.  Linux x86_64, PGI compiler, SGI MPT   (serial)
10.  Linux x86_64, PGI compiler, SGI MPT   (serial_NO_GRIB2)
11.  Linux x86_64, PGI compiler, SGI MPT   (dmpar)
12.  Linux x86_64, PGI compiler, SGI MPT   (dmpar_NO_GRIB2)
13.  Linux x86_64, IA64 and Opteron    (serial)
14.  Linux x86_64, IA64 and Opteron    (serial_NO_GRIB2)
15.  Linux x86_64, IA64 and Opteron    (dmpar)
16.  Linux x86_64, IA64 and Opteron    (dmpar_NO_GRIB2)
17.  Linux x86_64, Intel compiler    (serial)
18.  Linux x86_64, Intel compiler    (serial_NO_GRIB2)
19.  Linux x86_64, Intel compiler    (dmpar)
20.  Linux x86_64, Intel compiler    (dmpar_NO_GRIB2)
21.  Linux x86_64, Intel compiler, SGI MPT    (serial)
22.  Linux x86_64, Intel compiler, SGI MPT    (serial_NO_GRIB2)
23.  Linux x86_64, Intel compiler, SGI MPT    (dmpar)
24.  Linux x86_64, Intel compiler, SGI MPT    (dmpar_NO_GRIB2)
25.  Linux x86_64, Intel compiler, IBM POE    (serial)
26.  Linux x86_64, Intel compiler, IBM POE    (serial_NO_GRIB2)
27.  Linux x86_64, Intel compiler, IBM POE    (dmpar)
28.  Linux x86_64, Intel compiler, IBM POE    (dmpar_NO_GRIB2)
29.  Linux x86_64 g95 compiler     (serial)
30.  Linux x86_64 g95 compiler     (serial_NO_GRIB2)
31.  Linux x86_64 g95 compiler     (dmpar)
32.  Linux x86_64 g95 compiler     (dmpar_NO_GRIB2)
33.  Cray XE/XC CLE/Linux x86_64, Cray compiler   (serial)
34.  Cray XE/XC CLE/Linux x86_64, Cray compiler   (serial_NO_GRIB2)
35.  Cray XE/XC CLE/Linux x86_64, Cray compiler   (dmpar)
36.  Cray XE/XC CLE/Linux x86_64, Cray compiler   (dmpar_NO_GRIB2)
37.  Cray XC CLE/Linux x86_64, Intel compiler   (serial)
38.  Cray XC CLE/Linux x86_64, Intel compiler   (serial_NO_GRIB2)
39.  Cray XC CLE/Linux x86_64, Intel compiler   (dmpar)
40.  Cray XC CLE/Linux x86_64, Intel compiler   (dmpar_NO_GRIB2)
Enter selection [1-40] : 1
------------------------------------------------------------------------
Configuration successful. To build the WPS, type: compile
------------------------------------------------------------------------
                    

It is then necessary to edit the configure.wps file generated and add -lnetcdff to the WRF_LIB variable:

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  -lnetcdf -lnetcdff
                    

The code can be now compiled:

 roberto@linux:~/mod/WRF/WPS$ ./compile >& compile.log & 

Now all is ready for running WRF in the usual sequence of operations.

The command for using all the 8 threads from the 4 cores is:

 roberto@linux:~/mod/WRF/WRFV3/test/em_real$ mpirun -np 8 ./wrf.exe 

Grib2 I/O support

If you want to use the GRIB2 I/O you will need the jasper library. These should be the steps required (not tested):

Install JasPer JPEG-2000 library:

sudo apt-get install libjasper-dev
locate jasper lib and include directories:
roberto@linux:~$ locate jasper
/usr/include/jasper
/usr/lib/x86_64-linux-gnu/libjasper.a
(extra removed)
...

Modify the file .bashrc in the home directory of current user to set the environment variable NETCDF to the path preceeding include/netcdf.inc (in this case it is /usr).

At the bottom of the file .bashrc add these lines so that they will be set for future logins:

export JASPERLIB=/usr/lib/x86_64-linux-gnu
export JASPERINC=/usr/include

Then source the file to make these settings active for current session:

roberto@linux:~$ source .bashrc

Change to the WRFV3 directory and execute the configure script:

roberto@linux:~/mod/WRF/WRFV3$ ./configure
checking for perl5... no
checking for perl... found /usr/bin/perl (perl)
Will use NETCDF in dir: /usr
HDF5 not set in environment. Will configure WRF for use without.
PHDF5 not set in environment. Will configure WRF for use without.
Will use 'time' to report timing information

 If you REALLY want Grib2 output from WRF, modify the arch/Config_new.pl script. Right now you are not getting the Jasper lib, from the environment, compiled into WRF.

...

Edit file arch/Config_new.pl.

Around line 234 the Perl code is:

# The jasper library is required to build Grib2 I/O.  User must set
# environment variables JASPERLIB and JASPERINC to paths to library and
# include files to enable this feature prior to running configure.

 $I_really_want_to_output_grib2_from_WRF = "FALSE" ;

 if ( $ENV{JASPERLIB} && $ENV{JASPERINC} && $I_really_want_to_output_grib2_from_WRF eq "TRUE" )
The next step would be to change the line 234 to:
  $I_really_want_to_output_grib2_from_WRF = "TRUE" ;

and run the configure script again.

Once you have WRF up and running you may want to plot the results in KML for Google Earth with the free software WRF Browser.