hh
This page is meant to provide guidance through the steps of compiling WRF. It will take a beginning user through the processes of ensuring the computer environment is set up correctly, to testing the components and their compatibility with each other, then to installing WRFV3 and WPS, and finally to some guidance for preparing to run WPS and then WRFV3.
Click on a tab below for quick navigation. If you are a beginner, it is recommended to start at the beginning and follow through each step.
**IMPORTANT NOTES: PLEASE READ BEFORE CONTINUING!
In order to use personal machines, you must have all the pre-required programs and compilers built, as well as their functionality/compatibility verified through testing. We cannot be responsible or provide assistance for the installation of Linux, Linux utilities, or the compilers.
We are attempting to walk you through the steps for building necessary libraries (netCDF, MPICH, JasPer, Libpng, and Zlib); however, if you experience errors, we cannot be responsible for helping to correct the errors, as these are related to your particular system, and are not supported by our wrfhelp group. You will need to contact someone in your systems administation office, or go to the library websites to contact someone in their support group for assistance.
All of the examples given here are in tcsh. If you are very familiar with another shell (e.g., bash), and feel comfortable making the necessary alterations to the commands, then feel free to use your other shell. If not, however, we recommend using tcsh.
System Environment Tests
First and foremost, it is very important to have a gfortran compiler, as well as gcc and cpp. To test whether these exist on the system, type the following:
which gfortran
which cpp
which gcc
If you have these installed, you should be given a path for the location of each.
We recommend using gfortran version 4.4.0 or later. To determine the version of gfortran you have, type:
gcc --version
Create a new, clean directory called Build_WRF, and another one called TESTS.
There are a few simple tests that can be run to verify that the fortran compiler is built properly, and that it is compatible with the C compiler. Below is a tar file that contains the tests. Download the tar file and place it in the TESTS directory.
Fortran and C Tests Tar File
To unpack the tar file, type:
tar -xf Fortran_C_tests.tar
There are 7 tests available, so start at the top and run through them, one at a time.
Test #1: Fixed Format Fortran Test: TEST_1_fortran_only_fixed.f
Type the following in the command line:
gfortran TEST_1_fortran_only_fixed.f
Now type:
./a.out
The following should print out to the screen:
SUCCESS test 1 fortran only fixed format
Test #2: Free Format Fortran: TEST_2_fortran_only_free.f90
Type the following in the command line:
gfortran TEST_2_fortran_only_free.f90
and then type:
./a.out
The following should print out to the screen:
Assume Fortran 2003: has FLUSH, ALLOCATABLE, derived type, and ISO C Binding
SUCCESS test 2 fortran only free format
Test #3: C: TEST_3_c_only.c
Type the following in the command line:
gcc TEST_3_c_only.c
and then type:
./a.out
The following should print out to the screen:
SUCCESS test 3 c only
Test #4: Fortran Calling a C Function (our gcc and gfortran have different defaults, so we force both to always use 64 bit [-m64] when combining them): TEST_4_fortran+c_c.c, and TEST_4_fortran+x_f.f90
Type the following in the command line:
gcc -c -m64 TEST_4_fortran+c_c.c
and then type:
gfortran -c -m64 TEST_4_fortran+c_f.f90
and then:
gfortran -m64 TEST_4_fortran+c_f.o TEST_4_fortran+c_c.o
and then issue:
./a.out
The following should print out to the screen:
C function called by Fortran
Values are xx = 2.00 and ii = 1
SUCCESS test 4 fortran calling c
In addition to the compilers required to manufacture the WRF executables, the WRF build system has scripts as the top level for the user interface. The WRF scripting system uses, and therefore having the following is necessary:
csh
perl
sh
To test whether these scripting languages are working properly on the system, there are 3 tests to run. These tests were included in the "Fortran and C Tests Tar File".
Test #5:csh In the command line, type:
./TEST_csh.csh
The result should be:
SUCCESS csh test
Test #6:perl In the command line, type:
./TEST_perl.pl
The result should be:
SUCCESS perl test
Test #7:sh In the command line, type:
./TEST_sh.sh
The result should be:
SUCCESS sh test
Finally, inside the scripts are quite a few UNIX commands that are available regardless of which shell is used. The following standard UNIX commands are mandatory:
ar head sed
awk hostname sleep
cat ln sort
cd ls tar
cp make touch
cut mkdir tr
expr mv uname
file nm wc
grep printf which
gzip rm m4
Go to top of page
<
Building Libraries
Before getting started, you need to make another directory. Go inside your Build_WRF directory:
cd Build_WRF
and then make a directory called "LIBRARIES"
mkdir LIBRARIES
Depending on the type of run you wish to make, there are various libraries that should be installed. Below are 5 libraries. Download all 5 tar files and place them in the LIBRARIES directory.
mpich-3.0.4
netcdf-4.1.3
Jasper-1.900.1
libpng-1.2.50
zlib-1.2.7
It is important to note that these libraries must all be installed with the same compilers as will be used to install WRFV3 and WPS.
NetCDF: This library is always necessary!
setenv DIR path_to_directory/Build_WRF/LIBRARIES
setenv CC gcc
setenv CXX g++
setenv FC gfortran
setenv FCFLAGS -m64
setenv F77 gfortran
setenv FFLAGS -m64
tar xzvf netcdf-4.1.3.tar.gz #or just .tar if no .gz present
cd netcdf-4.1.3
./configure --prefix=$DIR/netcdf --disable-dap
--disable-netcdf-4 --disable-shared
make
make install
setenv PATH $DIR/netcdf/bin:$PATH
setenv NETCDF $DIR/netcdf
cd ..
MPICH: This library is necessary if you are planning to build WRF in parallel. If your machine does not have more than 1 processor, or if you have no need to run WRF with multiple processors, you can skip installing MPICH.
In principle, any implementation of the MPI-2 standard should work with WRF; however, we have the most experience with MPICH, and therefore, that is what will be described here.
Assuming all the 'setenv' commands were already issued while setting up NetCDF, you can continue on to install MPICH, issuing each of the following commands:
tar xzvf mpich-3.0.4.tar.gz #or just .tar if no .gz present
cd mpich-3.0.4
./configure --prefix=$DIR/mpich
make
make install
setenv PATH $DIR/mpich/bin:$PATH
cd ..
zlib: This is a compression library necessary for compiling WPS (specifically ungrib) with GRIB2 capability
Assuming all the "setenv" commands from the NetCDF install are already set, you can move on to the commands to install zlib.
setenv LDFLAGS -L$DIR/grib2/lib
setenv CPPFLAGS -I$DIR/grib2/include
tar xzvf zlib-1.2.7.tar.gz #or just .tar if no .gz present
cd zlib-1.2.7
./configure --prefix=$DIR/grib2
make
make install
cd ..
libpng: This is a compression library necessary for compiling WPS (specifically ungrib) with GRIB2 capability
Assuming all the "setenv" commands from the NetCDF install are already set, you can move on to the commands to install zlib.
tar xzvf libpng-1.2.50.tar.gz #or just .tar if no .gz present
cd libpng-1.2.50
./configure --prefix=$DIR/grib2
make
make install
cd ..
JasPer: This is a compression library necessary