#!/bin/bash


# Time-stamp
date_test=$( date )
export DATE_STR=$( LC_ALL=C date -d"${date_test}" +%Y%m%dT%H%M )

# Sourcing user configuration
[ ! find ./cfg        -name ${CFG_USER}.cfg ] && { echo 'No configuration file in ./cfg for '${CFG_USER}; exit; }
. cfg/${CFG_USER}.cfg
export DIR_WORK  DIR_SCRA  DIR_STOR
export NEMO_HOME NEMO_BRAN CONF_REFE CONF_TEST
export DIR_REFE  DIR_TEST
export DIR_XIOS  DIR_OASI
export NEMO_FORC FORC_TARF

NEMO_ARCH=${NEMO_HOME}/ARCH         ; NEMO_CONF=${NEMO_HOME}/CONFIG         ; NEMO_ENGI=${NEMO_HOME}/NEMO
NEMO_EFCM=${NEMO_HOME}/EXTERNAL/fcm ; NEMO_IPSL=${NEMO_HOME}/EXTERNAL/IOIPSL; NEMO_TRUS=${NEMO_HOME}/SETTE
NEMO_TCMP=${NEMO_HOME}/TOOLS/COMPILE
export NEMO_ARCH NEMO_CONF NEMO_EFCM
export NEMO_ENGI NEMO_IPSL NEMO_TRUS
export NEMO_TCMP

# Sourcing super-computer configuration
[ ! find ./cfg        -name ${CFG_ARCH}.cfg ] && { echo 'No configuration file in ./cfg for '${CFG_ARCH}; exit; }
. cfg/${CFG_ARCH}.cfg
export CDO      COMPILER  MPI      NETCDF
export JOB_SUBM JOB_LIST  JOB_VIEW JOB_DELE
export NPROC    TIME_LIMI
export ARCH_ENV

[ ! find ${NEMO_ARCH} -name arch-$ARCH.fcm  ] && { echo 'No fcm file in '${NEMO_ARCH}' for '$ARCH       ; exit; }