#! /bin/bash

###
### marche aussi en 64 bits
###

#wget http://www.lmd.jussieu.fr/~hourdin/PATCH_LMDZ4OR_G95/netcdf-3.6.1.tar.gz
#gunzip netcdf-3.6.1.tar.gz
tar xvf netcdf-3.6.1.tar

cd netcdf-3.6.1

# On modifie les options de compilation
#export FC=g95
#export F90=g95
#export CC=gcc 
#export F90FLAGS=" -cpp -ffree-form"
#export FFLAGS=" -cpp "



export CC=gcc 
export CXX=g++ 
export CPP='gcc -E' 
export FC=g95 
export F77=g95 
export F90=g95 
export CFLAGS='-O2 -DpgiFortran' 
export CXXFLAGS='-O2 -DpgiFortran' 
export CPPFLAGS='-DpgiFortran' 
export FFLAGS='-O2 -fno-second-underscore' 
export FCFLAGS='-O2 -fno-second-underscore' 
export F90FLAGS='-O2 -fno-second-underscore'



cd src
cd fortran


# Correction d'un petit probleme de netcdf
sed -e '83s/^$/\#define f2cFortran/' cfortran.h >| tmp
\mv tmp cfortran.h
cd ..

# Compilation
./configure
make check
make install

