#!/bin/bash

#Get number of cpus on current platform
NUMCPUS=`grep -c processor /proc/cpuinfo`;

#version of netcdf
version=`echo *.tar.gz | sed 's/\.tar\.gz//g' | sed 's/netcdf-//g'`

#Some cleanup
rm -rf install netcdf-$version

#Create install directories
mkdir install

#Untar 
tar -zxvf  netcdf-$version.tar.gz

#Move netcdf to install directory
rm -rf install/*
mv netcdf-$version/* install/
rm -rf netcdf-$version

#Configure netcdf
cd install
./configure  --prefix="$ISSM_DIR/packages/netcdf/install" 

#Compile netcdf
make  -j $NUMCPUS

#Install
make install
