Getting ready for netCDF (4)

This is a handy scrip to get your Linux box ready for using NetCDF. I’m not planning on maintaining this script, so if you want to use it head over to the Unidata website and make sure it is fetching the software versions you want.

Expect another post in a month or so on working with NetCDF in R.

# NetCDF
mkdir ~/temp
cd ~/temp
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.3.3.1.tar.gz
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/zlib-1.2.8.tar.gz
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/hdf5-1.8.13.tar.gz
# Extract tars
for a in 'ls -1 *.tar.gz'; do tar -zxvf $a; done
# Build and install zlib
cd zlib-1.2.8
./configure --prefix=/usr/local
sudo make check install
# Build and install hdf5
cd ../hdf5-1.8.13
./configure --with-zlib=/usr/local --prefix=/usr/local
sudo make check install
# Build and install NetCDF
cd ../netcdf-4.3.3.1/
CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./configure --prefix=/usr/local
sudo make check install
cd ~/
sudo rm -r ~/temp

When you’ve run the above, you can then use David Pierce’s ncdf4 package in R:

install.packages("ncdf4")
library(ncdf4)
Advertisements