#!/bin/bash # # Author: Patrick Brockmann # Contact: Patrick.Brockmann@cea.fr # History: # Modification: Nicolas-thierry.Martin@locean-ipsl.upmc.fr # # Set defaults #--------------------------------------------------- NEMO_TRUS=$( pwd $( dirname $0 ) ) DEBUG=0; PUBLISH=0; STATUS='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}/cfg -name ${CFG_USER}.cfg ) ]; then echo 'No configuration file in '${NEMO_TRUS}'/cfg for '${CFG_USER}; exit 1 elif [ ! $( find ${NEMO_TRUS}/cfg -name ${CFG_ARCH}.cfg ) ]; then echo 'No configuration file in '${NEMO_TRUS}'/cfg 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 # Only at end status will change to OK STATUS='FAILED' # SVN action on XIOS & NEMO essentials directories #--------------------------------------------------- pstep "Get NEMO SVN state with: ${SVN_OPT}" get_nemo_rev # Check softwares versions (source arch environment) #--------------------------------------------------- pstep 'Get softwares release' . ${ARCH_ENV} > /dev/null get_soft_rel cat model.log # XIOS compiling #--------------------------------------------------- pstep 'Compiling XIOS' cd ${DIR_XIOS} #./make_xios --arch $ARCH -job $NPROC >& /dev/null # NEMO config compiled from scratch #--------------------------------------------------- pstep "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 $STEP $STATUS # Get namelists, xml & forced files for running #--------------------------------------------------- pstep 'Preparing job' 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 $STEP $STATUS [ $( find . -name '*.gz' -print -quit ) ] && gunzip *.gz # Check input files in all cases #--------------------------------------------------- pstep 'Test input files difference' diff_inputs get_out $STEP $STATUS # Job submission & computing #--------------------------------------------------- pstep 'Running' job_num=$( ${JOB_SUBM} | awk '{print $NF}' ) [ $? -ne 0 ] && get_out $STEP $STATUS time_elapsed=0; time_increment=30 sleep ${time_increment} while [[ $( ${JOB_LIST} | grep ${job_num} ) && ${time_elapsed} -lt ${TIME_LIMI} ]]; do printf "\n####################################################" >> computation.log ${JOB_VIEW} ${job_num} >> computation.log sleep ${time_increment} let time_elapsed+=${time_increment} done sleep ${time_increment} # Eventual crash during computing #--------------------------------------------------- pstep 'Test if ASCII output files exist' if [[ ! -f ocean.output || $( grep 'E R R O R' ocean.output ) ]]; then ${JOB_DELE} ${job_num} &> /dev/null [ ! -f ocean.output ] && STEP='nemo.exe crashed at initialization' [ $( grep 'E R R O R' ocean.output ) ] && STEP='nemo.exe crashed' comments('E R R O R') ${JOB_DELE} ${job_num} >/dev/null 2>&1 STATUS='FAILED' get_out $STEP $STATUS else STATUS='OK' # Inspect output text files #--------------------------------------------------- pstep 'Test ASCII output files diff' for file in ocean.output solver.stat tracer.stat; do diff $file ${REFE_DIR}/$file [ $? -ne 0 ] && STATUS='FAILED' done # Inspect output NetCDF files #--------------------------------------------------- pstep 'Test last restart NetCDF files diff' diff_restart #2> /dev/null [ $? -ne 0 ] && STATUS='FAILED' # Get computation duration #--------------------------------------------------- pstep 'Get real CPU time' get_cpu_time comments('W A R N I N G') fi # End #--------------------------------------------------- if [ $STATUS == 'FAILED' ]; then STEP='Test outputs difference'; else STEP='Code is reliable'; fi get_out $STEP $STATUS