[5268] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | function mesg_make { |
---|
| 4 | paste -d ';' mesg_*.txt > trusting_${DATESTR}.txt |
---|
| 5 | cat trusting_${DATESTR}.txt |
---|
| 6 | } |
---|
| 7 | |
---|
| 8 | #============================================= |
---|
| 9 | function mesg_publish { |
---|
| 10 | |
---|
| 11 | if [ $PUBLISH -eq 1 ]; then |
---|
| 12 | |
---|
| 13 | if [ -f ${DIR_TEST}/trusting.txt ] ; then |
---|
| 14 | tail -1 trusting_${DATESTR}.txt >> ${DIR_TEST}/trusting.txt |
---|
| 15 | else |
---|
| 16 | cp trusting_${DATESTR}.txt ${DIR_TEST}/trusting.txt |
---|
| 17 | fi |
---|
| 18 | |
---|
| 19 | cp trusting_${DATESTR}.txt ${DIR_TEST} |
---|
| 20 | # chmod o+r ${DIR_TEST}/trusting_${DATESTR}.txt |
---|
| 21 | |
---|
| 22 | # rm -rf ${DIR_WORK}/../../dods/public/${LOGNAME}/trusting/${CONF_REF} |
---|
| 23 | # cp -alf ${DIR_TEST} ${DIR_WORK}/../../dods/public/${LOGNAME}/trusting/${CONF_REF} |
---|
| 24 | # chmod o+rX ${DIR_WORK}/../../dods/public/${LOGNAME}/trusting/${CONF_REF} |
---|
| 25 | |
---|
| 26 | # Send mail only when FAILED |
---|
| 27 | if [ grep 'FAILED' mesg_02_status.txt ]; then |
---|
| 28 | cat << END_MAIL > ${DIR_TEST}/trusting.mail |
---|
| 29 | XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
---|
| 30 | Dear $USER, |
---|
| 31 | |
---|
| 32 | The trusting sequence for ${CONF_REF} has failed. |
---|
| 33 | Please consult http://webservices.ipsl.fr/trusting/ |
---|
| 34 | |
---|
| 35 | Failed at step: `tail -n 1 mesg_03_step.txt` |
---|
| 36 | Directory : ${DIR_TEST} |
---|
| 37 | |
---|
| 38 | XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
---|
| 39 | |
---|
| 40 | END_MAIL |
---|
| 41 | mail -s "[trusting ${CONF_REF}] FAILED" ntmlod@locean-ipsl.upmc.fr < ${DIR_TEST}/trusting.mail |
---|
| 42 | fi |
---|
| 43 | |
---|
| 44 | fi |
---|
| 45 | |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | #============================================= |
---|
| 49 | function getout { |
---|
| 50 | cd ${DIR_TEST} |
---|
| 51 | mesg_make; mesg_publish |
---|
| 52 | |
---|
| 53 | # Add tar saved into {DIR_STOR} |
---|
| 54 | # find ${DIR_SCRA}/trusting/${CONF_REF}/* -prune -mtime +7 -exec /bin/rm -rf {} \; > /dev/null 2>&1 |
---|
| 55 | # [ -f ${DIR_REFE}/${CONF_REF}.tar ] && \rm ${DIR_STOR}/${CONF_REF}.tar |
---|
| 56 | tar -cf ${DIR_REFE}/trusting_${DATESTR}.tar . |
---|
| 57 | |
---|
| 58 | exit |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | #============================================= |
---|
| 62 | function diffnc { |
---|
| 63 | stat=100; file1=$1; file2=$2 |
---|
| 64 | |
---|
| 65 | cdo diffv $file1 $file2 > out_tmp |
---|
| 66 | ( [ $? -ne 0 ] && stat=100 ) || stat=$( grep -m 1 "records differ" out_tmp | awk '-Fof' '{print $1}' ) |
---|
| 67 | [ -f out_tmp ] && rm out_tmp |
---|
| 68 | |
---|
| 69 | return $stat |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | #--------------------------------------------- |
---|
| 73 | function diff_trusting { |
---|
| 74 | |
---|
| 75 | name_first=${JOB_NAME} |
---|
| 76 | name_second=EXP00C |
---|
| 77 | rep_ref=EXP00C_REFE |
---|
| 78 | experiment_name=trusting |
---|
| 79 | tagname=TEST |
---|
| 80 | #listcomp="ATM SBG SRF CPL ICE MBG OCE" |
---|
| 81 | listcomp="ATM SRF CPL ICE MBG OCE" |
---|
| 82 | result_final=0 |
---|
| 83 | |
---|
| 84 | # Output |
---|
| 85 | cd ${DIR_SCRA}/IGCM_OUT/${CONFIG_WORK}/${tagname}/${experiment_name}/${name_first} |
---|
| 86 | for comp in ${listcomp}; do |
---|
| 87 | echo ${comp} |
---|
| 88 | cd ${DIR_SCRA}/IGCM_OUT/${CONFIG_WORK}/${tagname}/${experiment_name}/${name_first}/${comp}/Output |
---|
| 89 | listfreq=$(ls -d MO/ DA/) |
---|
| 90 | for freq in ${listfreq}; do |
---|
| 91 | echo ${freq} |
---|
| 92 | cd ${DIR_SCRA}/IGCM_OUT/${CONFIG_WORK}/${tagname}/${experiment_name}/${name_first}/${comp}/Output/${freq} |
---|
| 93 | listfile=$( ls *.nc ) |
---|
| 94 | for file in ${listfile}; do |
---|
| 95 | var=$( echo $file | sed -e "s/^${name_first}//" ) |
---|
| 96 | result=$( diffnc ${name_first}${var} ${DIR_SCRA}/IGCM_OUT/${CONFIG_WORK}/${tagname}/${CONFIG_WORK}/${rep_ref}/${comp}/Output/${freq}${name_second}${var} ) |
---|
| 97 | result=$? |
---|
| 98 | echo 'diffnc '${name_first}${var} ${DIR_SCRA}/IGCM_OUT/${CONFIG_WORK}/TEST/${CONFIG_WORK}/${rep_ref}/${comp}/Output/${freq}${name_second}${var} |
---|
| 99 | echo $result |
---|
| 100 | (( result_final = result_final + result )) |
---|
| 101 | done |
---|
| 102 | done |
---|
| 103 | done |
---|
| 104 | return $result_final |
---|
| 105 | |
---|
| 106 | } |
---|