Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Install netCDF4 in Ubuntu
#!/bin/bash
# Script to install hdf5 and netCDF4 libraries on a Linux Ubuntu system
# After: https://code.google.com/p/netcdf4-python/wiki/UbuntuInstall
# And http://unidata.github.io/netcdf4-python/
# You can check for newer version of the programs on
# ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/
# and other sources
BASHRC="~/.bashrc"
# Install zlib
v=1.2.8
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/zlib-${v}.tar.gz
tar -xf zlib-${v}.tar.gz && cd zlib-${v}
./configure --prefix=/usr/local
#sudo make check install
sudo make install
cd ..
# Install HDF5
v=1.8.13
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/hdf5-${v}.tar.gz
tar -xf hdf5-${v}.tar.gz && cd hdf5-${v}
prefix="/usr/local/hdf5-$v"
if [ $HDF5_DIR != $prefix ]; then
echo "Add HDF5_DIR=$prefix to .bashrc"
echo "" >> $BASHRC
echo "# HDF5 libraries for python" >> $BASHRC
echo export HDF5_DIR=$prefix >> $BASHRC
fi
./configure --enable-shared --enable-hl --prefix=$HDF5_DIR
make -j 2 # 2 for number of procs to be used
sudo make install
cd ..
# Install Netcdf
v=4.1.3
wget http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-${v}.tar.gz
tar -xf netcdf-${v}.tar.gz && cd netcdf-${v}
prefix="/usr/local/"
if [ $NETCDF4_DIR != $prefix ]; then
echo "Add NETCDF4_DIR=$prefix to .bashrc"
echo "" >> $BASHRC
echo "# NETCDF4 libraries for python" >> $BASHRC
echo export NETCDF4_DIR=$prefix >> $BASHRC
fi
CPPFLAGS=-I$HDF5_DIR/include LDFLAGS=-L$HDF5_DIR/lib ./configure --enable-netcdf-4 --enable-shared --enable-dap --prefix=$NETCDF4_DIR
# make check
make
sudo make install
cd ..
# install python's netCDF4
sudo -E pip install netCDF4 --upgrade
@perrette

This comment has been minimized.

Show comment Hide comment
@perrette

perrette Mar 8, 2015

Really, this is an improved copy-paste from: https://code.google.com/p/netcdf4-python/wiki/UbuntuInstall

Owner

perrette commented Mar 8, 2015

Really, this is an improved copy-paste from: https://code.google.com/p/netcdf4-python/wiki/UbuntuInstall

@dhsvendsen

This comment has been minimized.

Show comment Hide comment
@dhsvendsen

dhsvendsen Oct 31, 2016

Thanks! <3

Thanks! <3

@inakioe

This comment has been minimized.

Show comment Hide comment
@inakioe

inakioe Nov 4, 2016

Many thanks! Was very useful!

inakioe commented Nov 4, 2016

Many thanks! Was very useful!

@uanber

This comment has been minimized.

Show comment Hide comment
@uanber

uanber Mar 30, 2017

Thanks a lot! very useful!

uanber commented Mar 30, 2017

Thanks a lot! very useful!

@leonme

This comment has been minimized.

Show comment Hide comment
@leonme

leonme Jun 7, 2017

Thanks a lot, you solve my big problem!

leonme commented Jun 7, 2017

Thanks a lot, you solve my big problem!

@edwintorresmoya

This comment has been minimized.

Show comment Hide comment
@edwintorresmoya

edwintorresmoya Jun 12, 2017

You'r the best thanks a lot, greetings from Colombia

You'r the best thanks a lot, greetings from Colombia

@dendroica

This comment has been minimized.

Show comment Hide comment
@dendroica

dendroica Jun 15, 2017

you might want to add a section to install curl if it's not already installed on the computer; otherwise the dap flag is ignored

you might want to add a section to install curl if it's not already installed on the computer; otherwise the dap flag is ignored

@changeme

This comment has been minimized.

Show comment Hide comment
@changeme

changeme Oct 19, 2017

real hero don't wear capes

thank you!

real hero don't wear capes

thank you!

@markpolarisdesign

This comment has been minimized.

Show comment Hide comment
@markpolarisdesign

markpolarisdesign Nov 5, 2017

Thank a lot

Thank a lot

@azamocn

This comment has been minimized.

Show comment Hide comment
@azamocn

azamocn Mar 21, 2018

thanks

azamocn commented Mar 21, 2018

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment