Compiling WRF and WPPV3 with GNU Fortran (gFortran)

This page explains how to build WRFV2.2 and WPPV3 (wrfpost.exe) using the GNU Fortran compiler. It is a work in progress: although we got WRF successfully compiled and running, we have not extensively cross-checked the results with those produced by one of the officially supported compilers yet (we are going to use PGI 6.2-5 as reference).

For users who are interested in trying out gFortran for themselves, we provide a patch that can be applied against the default distribution of WRFV2.2. This patch is based on suggestions of 'topex' from the WRF Users Forum, with one significant change (the -frecord-marker=4 option to prevent crashing in module_ra_rrtm.f90).

Building WRFV2.2

1. Download the file WRFV2-gfortran-x86_64-2.patch

2. Go to the WRFV2 directory with the original code.

3. To apply the patch, run patch -p1 < WRFV2-gfortran-x86_64-2.patch

4. ./configure should now give you three additional options:

  14.  PC Linux x86_64 (IA64 and AMD Opteron), GNU Fortran compiler, DM-Parallel  (RSL, MPICH, Allows nesting)
  15.  PC Linux x86_64 (IA64 and Opteron), GNU Fortran compiler   (Single-threaded, RSL, Allows nesting)
  16.  PC Linux x86_64 (IA64 and Opteron), GNU Fortran compiler  DM-Parallel (RSL_LITE, OpenMPI, Allows nesting)
If these options do not appear, find them in file arch/configure.defaults and edit the #ARCH header line to match your machine architecture.

5. If you wish to later build WPPV3 (see below), you must configure using the RSL_LITE option (for that you will also need a working version of OpenMPI). If you don't need WPPV3, you can configure and compile using the single-threaded option. The compilation should finish without errors (we tested with gfortran 4.1.0 and 4.1.1, openmpi 1.2.6).

You should be able to run the resulting wrf.exe without problems.

The RSL MPICH variant and RSL_LITE OpenMPI variant should work as well. However, be warned that the results generated by running the model compiled with gfortran can differ substantially from the ones generated by the PGI compiler.

Building WPPV3 (wrfpost.exe)

The following steps assume that you built WRFV2.2 using the RSL_LITE + OpenMPI option as described above:

1. Download the file WPPV3-gfortran-1.patch

2. Go to the WPPV3 directory with the original code.

3. To apply the patch, run patch -p1 < WPPV3-gfortran-1.patch

4. Copy makefile_linux_gfortran to makefile and edit the file to enter WRFPATH (pointing to the previously compiled WRFV2.2) and NETCDFPATH (pointing to your NetCDF directory)

5. Also edit sorc/wrfpost/makefile and replace the hard-coded path /opt/openmpi-gcc/lib with the one pointing to the location of your OpenMPI library.

We have not tested WPPV3 compiled with gfortran extensively. However, a simple test showed no difference between the output of the PGI-compiled and gfortran-compiled version.