#!/bin/bash

module load ictce/6.1.5

set -xuve
date

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

F90=gfortran
export F90FLAGS='-g -fdefault-real-8 -fdefault-double-8 -O0 -ffree-line-length-none'

UUID=/home/pabretonniere/transfer/specs2cmor-1.0/libs
CMOR=../../../lib/
NetCDF=/usr
HDF5=/usr
UDUNITS=/usr
DEBUG="-g -check all -fpe0 -warn -traceback -debug extended -fno-omit-frame-pointer"

export LDFLAGS="-ludunits2 -lnetcdf -lnetcdff"
export F90FLAGS="${F90FLAGS} -ludunits2 -lnetcdf -lnetcdff"

$F90   $F90FLAGS  cmor-oce.F90 -o cmor-oce.exe \
      -L${CMOR}/lib -lcmor \
      -I${CMOR}/include \
      -L${UUID}/lib -luuid \
      -I${NetCDF}/include \
      -L${HDF5}/lib -lhdf5_hl -lhdf5 \
      -I${HDF5}/include \
      -I${UUID}/include


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


$F90  $F90FLAGS  cmor-atm.F90 -o cmor-atm.exe \
      -L${CMOR}/lib -lcmor \
      -I${CMOR}/include \
      -L${UUID}/lib -luuid \
      -I${NetCDF}/include \
      -L${HDF5}/lib -lhdf5_hl -lhdf5 \
      -I${HDF5}/include \
      -I${UUID}/include

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