#!/bin/bash
######################################################
# Author : Rachid Benshila for NEMO
# Contact : rblod@locean-ipsl.upmc.fr
#
# Some functions called from makenemo_fcm
# Fcheck_config   : config checking 
######################################################
#set -x
set -o posix
#set -u
#set -e
#+
#
# ================
# Fcheck_config.sh
# ================
#
# --------------------------
# Check the configuration
# --------------------------
#
# SYNOPSIS
# ========
#
# ::
#
#  $ Fcheck_config.sh
#
#
# DESCRIPTION
# ===========
#
#
# Check the choice of the configuration:

# - Two cases
# - One is explicitely set
# - Nothing set, use the previous in use (default ORA2_LIM)
#
# EXAMPLES
# ========
#
# ::
#
#  $ ./Fcheck_config.sh
#
#
# TODO
# ====
#
# option debug
#
#
# EVOLUTIONS
# ==========
#
# $Id$
#
#
# - rblod 2010-06-20T16:11:47Z
#
#   * creation
#
#-

declare -a ZTAB
if [ ${#1} -eq 0 ]; then
   tail -1  ${COMPIL_DIR}/cfg.txt	> ${COMPIL_DIR}/cfg.tmp
   read -a ZTAB < ${COMPIL_DIR}/cfg.tmp
   NEW_CONF=${ZTAB[0]} ; TAB=( ${ZTAB[@]:1} )
   \rm ${COMPIL_DIR}/cfg.tmp
   echo "Warning !!!"
   echo "No configuration specified"
   echo "Use makenemo_fcm -n MYCONFIG"
   echo "or  makenemo_fcm -h for help"
   echo "Using defaut configuration : ${NEW_CONF}"
fi
cat ${COMPIL_DIR}/cfg.txt | grep "${NEW_CONF} " > ${COMPIL_DIR}/cfg.tmp
read -a ZTAB < ${COMPIL_DIR}/cfg.tmp
NEW_CONF=${ZTAB[0]} ; TAB=( ${ZTAB[@]:1} )
\rm ${COMPIL_DIR}/cfg.tmp

unset -v ZTAB
