#!/bin/bash -e

# --------------------------------------------------
# Script to compile CROCO in coupled and uncoupled modes
# --------------------------------------------------
#
# Further Information:   
# http://www.croco-ocean.org
#  
# This file is part of CROCOTOOLS
#
# CROCOTOOLS is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version.
#
# CROCOTOOLS is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA
#
# Copyright (c) 2018 S. Jullien
# swen.jullien@ifremer.fr
# --------------------------------------------------

#=========================================================================
#=======================  USER CHANGES  ==================================
#=========================================================================


# ------------------------------------------
# WARNING ! 
# 
# First edit paths and compilers in jobcomp
# ------------------------------------------

source ../run_env

# define your cppdefs.h extension to be compiled
my_compil_cases=(frc \
                 ow  \
                 oa)

#=========================================================================
#====================== END USER CHANGES  ================================
#=========================================================================

# Count number of cases to compile
NB_cases=${#my_compil_cases[@]}

# Loop on compil cases
for k in `seq 0 $(( ${NB_cases} - 1))` ; do

    mycase=${my_compil_cases[$k]}

    # Check if cppdefs.h.$mycase file is available
    if [ ! -e cppdefs.h.$mycase ]; then
        echo 'ERROR cppdefs.h.'$mycase' file does not exist'
        exit 1
    fi
    ln -sf cppdefs.h.$mycase cppdefs.h
    ./jobcomp &> jobcomp.log.$mycase
    mv -f croco croco.$mycase

done

