#!/bin/bash
#

source /opt/modules/init/bash
module load intel/2013sp1
module load hdf5/1.8.11 
module load szip/2.1
module load netcdf/4.1.3 
module list

set -xuve
date

DST=../bin; mkdir -p $DST

F90=ifort

F90FLAGS="-g -traceback -r8 -static -O3 -debug all -check all"

HDF5=/scratch/cfu/opt/hdf5-1.8.8/intel13
NetCDF=/scratch/cfu/opt/netcdf-4.1.3/intel13
UDUNITS=/scratch/cfu/opt/udunits-2.1.24/intel-13
UUID=/scratch/cfu/models/specs2cmor-1.0/lib/
CMOR=../../../lib/
EMOS=/gpfs/projects/ecm86/opt/gribex_000370/intel-13
SZLIB=/share/libs/szip/2.1/intel
ZLIB=/scratch/cfu/opt/zlib-1.2.5

$F90  $F90FLAGS  cmor-atm.F90 -o cmor-atm.exe \
      -L${CMOR}/lib -lcmor \
      -I${CMOR}/include \
      -L${UUID}/lib -luuid \
      -I${UUID}/include \
      -L${UDUNITS}/lib -ludunits2 -lexpat \
      -I${UDUNITS}/include \
      -L${NetCDF}/lib -lnetcdff -lnetcdf \
      -I${NetCDF}/include \
      -L${HDF5}/lib -lhdf5_hl -lhdf5 \
      -I${HDF5}/include \
      -L${ZLIB}/lib -lsz -lz \
      -I${ZLIB}/include \
      -L${SZLIB}/lib -lz \
      -I${SZLIB}/include

mv cmor-oce.exe $DST/cmor-oce.exe


#      -L${EMOS}/lib -lgribexR64 \
$F90  $F90FLAGS  cmor-oce.F90 -o cmor-oce.exe \
      -L${CMOR}/lib -lcmor \
      -I${CMOR}/include \
      -L${UUID}/lib -luuid \
      -I${UUID}/include \
      -L${UDUNITS}/lib -ludunits2 -lexpat \
      -I${UDUNITS}/include \
      -L${NetCDF}/lib -lnetcdff -lnetcdf \
      -I${NetCDF}/include \
      -L${HDF5}/lib -lhdf5_hl -lhdf5 \
      -I${HDF5}/include \
      -L${ZLIB}/lib -lsz -lz \
      -I${ZLIB}/include \
      -L${SZLIB}/lib -lz\
      -I${SZLIB}/include

mv cmor-atm.exe $DST/cmor-atm.exe
