#!/bin/bash
#

module load intel/13.0.1
module load hdf5/1.8.10 
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 -O0 -debug all -check all"

HDF5=/apps/HDF5/1.8.10
NetCDF=/gpfs/projects/ecm86/opt/netcdf-4.1.3/intel-13
UDUNITS=/gpfs/projects/ecm86/opt/udunits-2.1.24/intel-13
UUID=/apps/UUID/1.6.2
CMOR=../../../lib/
EMOS=/gpfs/projects/ecm86/opt/gribex_000370/intel-13
SZLIB=/gpfs/projects/ecm86/opt/szip-2.1/intel-13
ZLIB=/gpfs/projects/ecm86/opt/zlib-1.2.5/intel-13

$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-oce.exe $DST/cmor-oce.exe


$F90  $F90FLAGS  cmor-atm.F90 -o cmor-atm.exe \
      -L${EMOS}/lib -lgribexR64 \
      -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
