NetCDF Help

What the heck is netCDF?

NetCDF stands for network Common Data Form, and it is a machine-independent file format for storing scientific data. All WRFDA output files are in netCDF format, so the libraries for reading and creating netCDF files are necessary for using WRFDA. That's all you really need to know about netCDF in order to use WRFDA; if you are curious and would like to find out more, you can go to Unidata's netCDF webpage.

Do I need to install netCDF?

Chances are, if your computer is on a university or research laboratory network, you already have access to the needed netCDF libraries. So your first step should be to determine whether the libraries are already installed or not. If you are sure that you need to install the libraries yourself, you can skip to the next section.

By default, netCDF libraries are installed in "/usr/local". Run the following command to see if the netCDF libraries are installed there:

> ls -d /usr/local/netcdf*

If you see results (for example: "/usr/local/netcdf-4.1.1"), then netCDF is already installed. If not, you can either ask your system administrator if netCDF libraries are installed elsewhere, or you can skip to the next section and install them yourself.

If you've determined that netCDF is already installed on your system, you still must endure that the installed libraries were compiled with the same compilers with which you intend to compile WRF and/or WRFDA. You should find out what Fortran and C compilers are installed on your system (or, if multiple compilers are available, which ones you'd prefer to use). If you are not sure which compilers to use, or don't know which compilers are installed on your system, see the Configuration Help Page for guidance.

To determine what compilers were used to compile your netCDF libraries, you should type the following command:

> /usr/local/netcdf/bin/nc-config --all

This netCDF 4.1.1 has been built with the following features:
  --cc        -> pgcc
  --cflags    -> -I/usr/local/netcdf-4.1.1-pgi/include
  --libs      -> -L/usr/local/netcdf-4.1.1-pgi/lib -lnetcdf -L/usr/kerberos/lib -lcurl -ldl -lgssapi_krb5 -lkr b5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz
  --cxx       -> c++
  --has-c++   -> no
  --fc        -> pgf90
  --fflags    -> -g -I/usr/local/netcdf-4.1.1-pgi/include
  --flibs     -> -L/usr/local/netcdf-4.1.1-pgi/lib -lnetcdf -L/usr/kerberos/lib -lcurl -ldl -lgssapi_krb5 -lkr b5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz
  --has-f77   -> yes
  --has-f90   -> yes
  --has-dap   -> yes
  --has-nc2   -> yes
  --has-nc4   -> no
  --has-hdf5  -> no
  --has-hdf4  -> no
  --has-szlib -> no
  --prefix    -> /usr/local/netcdf-4.1.1-pgi
  --includedir-> /usr/local/netcdf-4.1.1-pgi/include
  --version   -> netCDF 4.1.1

You should of course change the text "/usr/local/netcdf" to the location of your netCDF installation (for instance, in the earlier example, "/usr/local/netcdf-4.1.1").

You should pay close attention to the following lines:

  • --cc and --fc: These are your C- and FORTRAN-compilers respectively. These should be the same as those you intend to use to compile WRF/WRFDA
  • --version and --has-nc4: If your version number is 4.0 or later, the "has-nc4" flag must be set to "no". WRFDA is not yet fully compatible with NetCDF4 libraries, so this could lead to problems.

If you've gotten to this point and everything looks good, you should be able to use your existing netCDF libraries! You can press "Back" to return to where you were previously, or go to the tutorial home page.

How do I install netCDF?

Installing netCDF can be slightly more difficult than installing WRFDA itself, but it is still quite simple. First, you should find out what Fortran and C compilers are installed on your system (or, if multiple compilers are available, which ones you'd prefer to use). If you are not sure which compilers to use, or don't know which compilers are installed on your system, see the Configuration Help Page for guidance.

The choice of compiler is important because you MUST use the same compilers to compile netCDF as you use to compile WRFDA. If, for example, you compiled your netcdf libraries with gfortran and gcc, attempting to compile WRFDA with (for example) pgf90 and pgcc will not work.

The netCDF installation process only takes about 30 minutes, and the libraries only take up around 11 Mb of space, so this should not be burdensome even for those on a tight computing and/or time budget.

Step 1: Download and unzip the netCDF source code

NetCDF can be downloaded from the Unidata netCDF download page. WRFDA is not yet compatible with the most recent version of netCDF, so you should scroll down to the bottom section titled "Old netCDF Bundled C/C++/Fortran Releases" and select the most recent link in that section. As of October 2012, this is version 4.1.3. From that page, click the link to download the most recent stable release of the netCDF source code, and save it to a convenient folder.

Now that you have downloaded the netCDF source code, it is time to configure the code to your environment and compile. In a terminal window, navigate to the directory in which you saved the netCDF tarball (netcdf-4.1.3.tar.gz) and un-tar it.

> tar -xvf netcdf-4.1.3.tar.gz

Step 2: Configure and compile

Now, navigate to the folder you just un-tarred. Now it is time to select your compilers (again, if you are unsure of which compilers to use, see the Configuration Help Page). Set the environment variable "FC" to the name of the Fortran compiler you will be using, and set "CC" to the name of the C compiler you will be using. We recommend using Gnu, Intel, or PGI compilers if possible.

> setenv FC gfortran
> setenv CC gcc

Tip When typing the "setenv" command, I receive a "not found" or similar error
You are using a shell other than csh or tcsh. Please see the "Shells Help Page" for solutions.

Finally, you should configure netCDF so it will install in the correct folder. Typically netCDF will install in the /usr/local directory by default, but if you do not have administrative privileges on your machine, you will need to set your own directory. Any directory that you can write to will suffice; for demonstration purposes, we will use /user/home/jdoe/netcdf_4.1.3 as our installation directory. Ensure that you are in the netcdf source directory that you just unpacked, and enter the following:

> ./configure --prefix=/user/home/jdoe/netcdf_4.1.3 --disable-netcdf-4

The "--disable-netcdf-4" option is very important, as omitting it introduces many complications which are beyond the scope of this tutorial.

The ./configure script will run a large number of checks, and if successful will end with no error messages. Once the script is finished, complete the installation by entering the following:

> make check install

If everything works correctly, a long series of "make" commands will end with a message beginning with "Congratulations! You have successfully installed netCDF!". If you see this message, you are done, and can move on to the tutorial branch that best suits you.

If you receive a "Permission denied" error, ensure that your installation directory (the "--prefix=" statement) is set to a directory for which you have write permissions. If the error persists, or if you receive other errors, contact wrfhelp@ucar.edu.


Note: This website is currently under construction. If you notice any problems with the website, including but not limited to broken links, formatting errors, or incorrect information, please submit an email to the or wrfhelp@ucar.edu so that we can address the problem. We appreciate your feedback!

   

 

NOTE: These pages makes use of Java Script. Enable Java on your computer to make use of all the functionality.