NetCDF (Network Common Data Form) is an open standard for self-describing, machine-independent data formats for array-oriented scientific data. The standard and a good deal of associated software are developed by the Unidata program at the University Corporation for Atmospheric Research (UCAR).

I needed one of their libraries (ucar.ma2) to build HDFView from source. Because I have very little Java experience, figuring out how to do this took the better part of today. Here are my notes, so things will be faster the next time around…

Note that the hdf-java source (containing the HDFView source) comes with a few precompiled JARs, including netcdf.jar. However, Gentoo wants to compile everything from source), so we remove those JARs before compiling hdf-java, forcing a reliance on versions that have already been installed from source using Portage.

Java develoment kit

You'll need both a Java development kit (JDK, think "compiler") and runtime environment (JRE, think "bytecode interpreter"). Install the default implementations with

# emerge virtual/jdk

The Gentoo Java team publishes a Java guide with more details if you're interested.

Maven

You'll also need Maven, Apache's Java pacakge manager.

# emerge dev-java/maven-bin

There's a from-source dev-java/maven in java-overlay, but I'll wait until that has been merged into the main Portage tree before checking it out. NetCDF will probabaly not depend on any bleeding-edge Maven features.

NetCDF

NetCDF is currently versioned with Git (hosted on GitHub), so you can grab the source with

$ git clone git://github.com/Unidata/thredds.git

Unfortunately, this repository bundles a number of related Unidata packages besides netCDF, so the 95 megabyte cdm directory comes with an additional 432 megabytes of additional stuff. This means that it's a good idea to run the clone over a fast connection, and probably useful to use git clone --depth 10 or similar to limit the amount of history you clone.

Now that you've got the source, just tell Maven to install it for you. First, you'll need to install the `common utilities:

$ cd thredds/common
$ mvn-2.2 install

Next, install the cdm module itself

$ cd thredds
$ mvn-2.2 install

For more details, see the netCDF documentation and build instructions.

Compiling HDFView

To install HDFView on Gentoo, just emerge dev-java/hdf-java from my wtk overlay with the hdfview USE flag enabled.