#!/bin/bash
#


module load ictce/6.1.5
#module load netCDF/4.3.1.1-ictce-6.1.5
#module load Szip/2.1-ictce-6.1.5
#module load netCDF-Fortran/4.2-ictce-6.1.5
#module load cURL/7.34.0-ictce-6.1.5
#module load UDUNITS/2.1.24-ictce-6.1.5

set -xuve
date

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

#F90=ifort
#F90FLAGS="-g -traceback -r8 -static -O0 -debug all -check all "
F90=gfortran
#F90FLAGS="-g -traceback -r8 -static -O0 -debug all -check all "
#export F90FLAGS='-g -fdefault-real-8 -fdefault-double-8  -O0 -ffree-line-length-none'
export F90FLAGS='-g -fdefault-real-8 -fdefault-double-8 -O0 -ffree-line-length-none'
#export F90FLAGS='-g  -static -O0 -ffree-line-length-none'

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

export LDFLAGS="-ludunits2 -lnetcdf -lnetcdff"
export F90FLAGS="${F90FLAGS} -ludunits2 -lnetcdf -lnetcdff"
#      -L${UDUNITS}/lib/x86_64-linux-gnu -ludunits2  \
#      -I${UDUNITS}/include \

#      -L${UDUNITS}/lib -ludunits2 -lexpat \

$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

#      -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
