#!/bin/ksh
#

source /opt/modules/init/bash
#module load intel/13.0.1
module load intel
module load hdf5/1.8.10 
module load szip/2.1
#module load netcdf/4.1.3 
module load netcdf 
module list

set -xuve
date


F90=ifort

F90FLAGS="-g -traceback -r8 -static -O0 -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/opt/uuid-1.6.2/intel-13
CMOR=../../../lib/cmor-2.7.1-specs_update/intel13
EMOS=/scratch/cfu/opt/gribex_000370/intel-13
SZLIB=/share/libs/szip/2.1/intel
ZLIB=/scratch/cfu/opt/zlib-1.2.5/intel13/

$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 /scratch/cfu/opt/specs2cmor-1.0/models/ecearth/bin/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 /scratch/cfu/opt/specs2cmor-1.0/models/ecearth/bin/cmor-atm.exe
