#!/bin/bash # Set defaults #--------------------------------------------------- NEMO_TRUS=$( pwd $( dirname $0 ) ) DEBUG=0; PUBLISH=0 STATUS='FAILED'; STEP=''# Only at end status will change to OK # Get options for replacing some initials settings #--------------------------------------------------- while [ $# -ne 0 ]; do case $1 in -b|--branch ) NEMO_BRAN=$2 ; shift 2;; -d|--debug ) set -vx; DEBUG=1 ; shift ;; -e|--email ) MAIL=$2 ; shift 2;; -j|--job ) NPROC=$2 ; shift 2;; -h|--help ) cat trusting_help.txt; exit 1;; -m|--machine) CFG_ARCH=$2 ; shift 2;; -n|--newconf) TEST_CONF=$2 ; shift 2;; -r|--refconf) REFE_CONF=$2 ; shift 2;; -t|--time ) TIME_LIMI=$2 ; shift 2;; -p|--publish) PUBLISH=1 ; shift ;; -u|--user ) CFG_USER=$2 ; shift 2;; -v|--version) NEMO_VERS=$2 ; shift 2;; *) cat trusting_help.txt; exit 1;; esac done # Initialization (super-computer & user environment) #--------------------------------------------------- if [[ ! -z "${CFG_ARCH}" && ! -z "${CFG_USER}" ]]; then if [ ! $( find ${NEMO_TRUS}/config -name ${CFG_USER}.cfg ) ]; then echo 'No configuration file in '${NEMO_TRUS}'/config for '${CFG_USER}; exit 1 elif [ ! $( find ${NEMO_TRUS}/config -name ${CFG_ARCH}.cfg ) ]; then echo 'No configuration file in '${NEMO_TRUS}'/config for '${CFG_ARCH}; exit 1 else . ${NEMO_TRUS}/trusting.env fi else cat ${NEMO_TRUS}/trusting_help.txt; exit 1 fi . ./trusting_func.sh # #--------------------------------------------------- mkdir -p ${TEST_DIR} ${REFE_DIR} echo ${TEST_DIR} && cd ${TEST_DIR} datestr1=$( LC_ALL=C date -d"${DATE_STR}" +%Y-%m-%dT%H:%M ) printf "Date\n$datestr1\n" > mesg_01_date_${CFG_USER}_${CFG_ARCH}.txt # SVN action on XIOS & NEMO essentials directories #--------------------------------------------------- print_step 'Get NEMO code state / repository' get_nemo_rev # Check softwares versions (source arch environment) #--------------------------------------------------- print_step 'Get softwares release' . ${ARCH_ENV} > /dev/null get_soft_rel cat env.log # XIOS compiling #--------------------------------------------------- print_step 'Compiling XIOS' cd ${DIR_XIOS} ./make_xios --full --arch $ARCH -job $NPROC #>& /dev/null [ ! -e ${DIR_XIOS}/lib/libxios.a ] && get_out $STATUS $STEP # NEMO config compiled from scratch #--------------------------------------------------- print_step "Compiling ${CONF_REF} configuration" cd ${NEMO_CONF} [ -d ${TEST_CONF} ] && ./makenemo -n ${TEST_CONF} clean ./makenemo -n ${TEST_CONF} -r ${REFE_CONF} -m $ARCH -j $NPROC #>& /dev/null [ ! -e ${TEST_CONF}/BLD/bin/nemo.exe ] && get_out $STATUS $STEP # Get namelists, xml & forced files for running #--------------------------------------------------- print_step "Preparing job by copying ${CONF_REF} input files" cd ${TEST_DIR} find ${NEMO_CONF}/${TEST_CONF}/EXP00 -regex '.*\(cfg\|opa\|ref\|xml\)' -exec cp {} . \; if [ ! -z "${FORC_TAR}" ]; then cmd_iol="tar -tvf ${NEMO_FORC}/${FORC_TAR}"; cmd_iof="tar -vxf ${NEMO_FORC}/${FORC_TAR}" else cmd_iol="ls ${NEMO_FORC}/*" ; cmd_iof="\cp ${NEMO_FORC}/* ." fi ${cmd_iol} > inputs_list.txt && ${cmd_iof} > /dev/null [ $? -ne 0 ] && get_out $STATUS $STEP [ $( find . -name '*.gz' -print -quit ) ] && gunzip *.gz # Check input files in all cases #--------------------------------------------------- print_step 'Difference between input files' diff_inputs # Job submission & computing #--------------------------------------------------- print_step 'Submitting job' JOB_ID=$( ${JOB_SUBM} | awk '{print $NF}' ) [ $? -ne 0 ] && get_out $STATUS $STEP print_step 'Pending/Running job' time_elapsed=0; time_increment=30 sleep ${time_increment} while [[ $( ${JOB_LIST} | grep ${JOB_ID} ) && ${time_elapsed} -lt ${TIME_LIMI} ]]; do printf "\n####################################################" >> computation.log ${JOB_VIEW} ${JOB_ID} >> computation.log sleep ${time_increment} let time_elapsed+=${time_increment} done sleep ${time_increment} if (( ${time_elapsed} = ${TIME_LIMI} )); then print_step 'Killing job' ${JOB_DELE} ${JOB_ID} &> /dev/null get_out $STATUS 'Job timeout' fi print_step 'Job finished' # Eventual crash during computing #--------------------------------------------------- print_step 'Test if job crashed' if [[ ! -e ocean.output || $( grep 'E R R O R' ocean.output ) ]]; then comments 'E R R O R' get_out $STATUS $STEP else STATUS='OK' # Inspect output text files #--------------------------------------------------- print_step 'Test ASCII output files diff' for file in ocean.output solver.stat tracer.stat; do diff $file ${REFE_DIR}/$file [ $? -ne 0 ] && get_out 'FAILED' 'ASCII output file differ' done # Inspect output NetCDF files #--------------------------------------------------- print_step 'Test last restart NetCDF files diff' diff_restart [ $? -ne 0 ] && get_out 'FAILED' "$CDO diff failed" # Get computation duration #--------------------------------------------------- print_step 'Get real CPU time' get_cpu_time comments 'W A R N I N G' fi # End #--------------------------------------------------- [ $STATUS == 'OK' ] && STEP='Code is reliable' get_out $STATUS $STEP