Making your own weather forecast Part 1

It’s totally possible given the WRF model (which stands for the Weather Research and Forecast). Here I’m going to give you a step-by-step guide to downloading the 3.6.1 version of the software, installing it, and then also downloading the needed data to make your own custom forecast. Since I live in Nebraska, I’m going to set it up to do a model run for Lincoln (the capital), but you can easily make the necessary changes to do the run for whatever location you’d like.

The Prerequisites: 

First, a few things need to be in order. This stuff is meant for Linux. You can apparently run it on Windows using Cygwin, but it appears to be happiest when installed and ran under a Linux distribution. Mine is Ubuntu 14.04, 64-bit. Your mileage may vary depending on which flavor of Linux you use, but for any Debian-based systems these instructions should go smoothly. It’s worth noting I’m by no means an expert in Linux and I was able to get this thing going just fine; so hopefully this guide will help for even novices.

You’re going to need some disk space, not a lot, but you will need a few Gig to spare. That’s because the data you’ll be downloading to get this thing to run isn’t insignificant, and neither is the data it generates.

One final thing to bear in mind is this system, as is common for many “systems” running on Linux it seems, is made up of multiple programs, all working in concert with one another. Typically the output from one is taken and fed into another, and so the chain continues. It can be slightly daunting at first to know who is talking to whom, so I recommend glancing around this page and reading up on the 30,000-foot view (I won’t talk about it here since it’s fairly well described in the link provided). The reason I bring this up is because there is no single source code package, you’ll need to download and compile and setup multiple programs (such is life); yet they all fall under the title of the “Model System” as I’m describing it.

The Setup: 

One final thing before we get started — I wrote this guide alongside doing another install (for a second time on a different Linux box). The order isn’t necessarily important as it’s just how I did it…if you notice any irregularities and would like to mix it up a bit, it’s likely you’ll be able to do so.

  1. Download the source for the latest version of the WPS program here.
  2. Download the source for the latest version of the WRF program here.
  3. Download the geographical input data for the model system here. A couple things to note about this step — first, what you’re downloading here is terrain data, etc. that allows the model to properly build a view of the environment around which it’s generating its predictions. Second, it’s really not important to know what this data contains (unless you really want to). And finally, they don’t make it easy to know what, exactly, you are to download (as there are different versions of this for different versions of the software). If the page to which I link to above hasn’t changed much, the link to click for the data is titled “Download Complete Dataset”, and it’s actually the header for a table column.
  4. Now untar/gzip the files you’ve downloaded. I downloaded everything into a single directory to make management easier. Once all is unpackaged, there are three folders for me named geog, WPS and WRFV3 (hint, to stay in sync with this tutorial, you should rename and folders appropriately).
  5. Next we download some third-party packages needed for building the WPS/WRF programs. Start by downloading HDF5 (a library for manipulating data formats used by WRF) from here. Once again, untar/gzip the file. Move into the directory and configure the install by typing ./configure –prefix=/usr/local. Once this is done, type make install to install the package. NOTE: Make sure you’re running sudo.
  6. There’s also a third party package called NetCDF also used for processing specialized data formats used by WRF. There appears to be a version for both the C and Fortran compilers, for completeness I downloaded and installed both (though I have a suspicion only the Fortran version is needed). To download the C and Fortran versions go here. Unpackage them and for each ./configure –prefix=/usr/local.  And, yet again for each, make install.
  7. Before proceeding you’ll have to set an environment variable that’ll be used by the compilation scripts to locate netcdf. If you’re using bash as your shell, type export NCARG_ROOT=/usr/local. 
  8. NOTE: If you don’t have gfortran –the GNU Fotran compiler — installed, you should do so now (on Ubuntu, you can use the aptitude or apt-get package manager to do so). NOTE: The following compile scripts are written for CSH, not bash, so you’ll have to make sure you have csh installed (again, use apt-get, aptitude or your package manager of choice to get it).
  9. Now cd into the WRFV3 directory and type ./configure. When executing the script for me I am prompted twice, once for the location to the /include directories for NetCDF and again for the /lib directories to NetCDF. Type them in accordingly. Next you’ll be prompted for the build chain to use when compiling the WRFV3 package – I chose option #32 (x86_64 Linux, gfortran compiler with gcc   (serial)). One final prompt comes your way, asking for nesting options (I chose option #1, or basic). Now you’ll want to actually do the compilation, and since we’ll be running real world simulations, we’ll tell the build system to set things up accordingly by typing ./compile em_real. And away it goes….
  10. Now to install some more third-party packages required for compiling the WPS package. Go here and search for the phrase “external libraries”, you’ll see three: Jasper, PNG and zlib. Download each of them, ./configure –prefix=/usr/local and make install each accordingly (seriously, this was a pretty easy setup for me).
  11. Next cd into the WPS directory and type ./configure. Like with the WRFV3 script, this will prompt you for the location of the netcdf include and library directories, which you will specify just the same. It will then prompt you for the compilers (both Fortran and C) to use for building WPS. On my system (see above) I chose option #1 (Linux x86_64, gfortran    (serial)). Once you select your option, it’ll prompt you to type “compile” to start the compilation process and you should do that now.
  12. If all compiled well, you’re done!

In my next post I’ll describe how to download data and actually stitch all of these programs together.