#!/bin/bash
#

module load intel szip craype cray-hdf5 netcdf4/4.3.2 udunits

UUID=../../../lib
UDUNITS=/usr/local/apps/udunits/2.2.17
NetCDF=/usr/local/apps/netcdf4/4.3.2/INTEL/150
HDF5=/usr/local/apps/hdf5/1.8.17/GNU/53
ZLIB=/usr/local/apps/szip/2.1/INTEL/150/

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=../../../lib/
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

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


#      -L${EMOS}/lib -lgribexR64 \
$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

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