#!/bin/bash function mesg_make { paste -d ';' mesg_*_${CFG_USER}_${CFG_ARCH}.txt > trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt cat trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt } #============================================= function mesg_publish { if [ $PUBLISH -eq 1 ]; then if [ -f ${TEST_DIR}/trusting_${CFG_USER}_${CFG_ARCH}.txt ] ; then tail -1 trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt >> ${TEST_DIR}/trusting_${CFG_USER}_${CFG_ARCH}.txt else cp trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt ${TEST_DIR}/trusting_${CFG_USER}_${CFG_ARCH}.txt fi cp trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt ${TEST_DIR} # chmod o+r ${TEST_DIR}/trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt # rm -rf ${DIR_WORK}/../../dods/public/${LOGNAME}/trusting/${CONF_REF} # cp -alf ${TEST_DIR} ${DIR_WORK}/../../dods/public/${LOGNAME}/trusting/${CONF_REF} # chmod o+rX ${DIR_WORK}/../../dods/public/${LOGNAME}/trusting/${CONF_REF} # Send mail only when FAILED if [[ $( grep 'FAILED' mesg_02_status_${CFG_USER}_${CFG_ARCH}.txt ) && ! -z $MAIL ]]; then cat << END_MAIL > ${TEST_DIR}/trusting.mail XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Dear $USER, The trusting sequence for ${CONF_REF} has failed. Please consult http://webservices.ipsl.fr/trusting/ Failed at step: `tail -n 1 mesg_03_step_${CFG_USER}_${CFG_ARCH}.txt` Directory : ${TEST_DIR} XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX END_MAIL mail -s "[trusting ${CONF_REF}] FAILED" $MAIL < ${TEST_DIR}/trusting.mail fi fi } #============================================= function get_out { cd ${TEST_DIR} mesg_make; mesg_publish # Add tar saved into {DIR_STOR} find ${DIR_SCRA}/trusting/${CONF_REF}/* -prune -mtime +7 -exec /bin/rm -rf {} \; > /dev/null 2>&1 [ -f ${DIR_STOR}/${CONF_REF}.tar ] && \rm ${DIR_STOR}/${CONF_REF}.tar tar -cf ${DIR_STOR}/${CONF_REF}.tar . exit } #============================================= function diff_nc { stat=100; file1=$1; file2=$2 cdo diffv $file1 $file2 > out_tmp ( [ $? -ne 0 ] && stat=100 ) || stat=$( grep -m 1 'records differ' out_tmp | awk -Fof '{print $1}' ) [ -f out_tmp ] && rm out_tmp return $stat } #--------------------------------------------- function diff_restart { last_time_step=$( cat ${REFE_DIR}/time.step ) result_final=0 echo 'Last time step: '${last_time_step} if [ $( find ${REFE_DIR} -name *restart*_${last_time_step}.nc ) ]; then for file in find ${REFE_DIR} -name *restart*_${last_time_step}.nc; do echo ${TEST_DIR}'/*'${file}'_'${last_time_step}'.nc: ' result=$( diff_nc $file ) printf "diffnc $result\n" (( result_final = result_final + result )) done else echo 'No restart files found for comparison' fi return ${result_final} }