source: branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting_func.sh @ 5402

Last change on this file since 5402 was 5402, checked in by nicolasmartin, 6 years ago

dev_r5092_CNRS_SETTE Nearing initial release by adding namelists & iodef files in comparison

  • Property eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Rev URL
File size: 4.4 KB
Line 
1#!/bin/bash
2
3
4diff_inputs() {
5    for file in inputs_list.txt $( ls namelist_* ) iodef.xml; do
6   diff $file ${REFE_DIR}/$file
7
8   if [ $? -ne 0 ]; then
9       printf "Input files\nDifferent" | tee mesg_09_inputfiles_${CFG_USER}_${CFG_ARCH}.txt
10       get_out
11   fi
12
13    done
14
15    printf "Input files\nSame"              | tee mesg_09_inputfiles_${CFG_USER}_${CFG_ARCH}.txt
16}
17
18diff_nc() {
19    stat=100; file1=$1; file2=$2
20
21    cdo diffv $file1 $file2 > out_tmp
22    ( [ $? -ne 0 ] && stat=100 ) || stat=$( grep -m 1 'records differ' out_tmp | awk -Fof '{print $1}' )
23    [ -f out_tmp ] && rm out_tmp
24
25    return $stat
26} 
27
28diff_restart() {
29    last_time_step=$( cat ${REFE_DIR}/time.step | tr -d [:space:] )
30    result_final=0
31
32    echo 'Last time step: '${last_time_step}
33
34    for file in restart restart_ice restart_trc; do
35   printf "${TEST_DIR}/*${last_time_step}_${file}*.nc: "
36   find ${TEST_DIR} -name *${last_time_step}_$file*.nc && exit 0
37   if [ $( find ${TEST_DIR} -regex .*${last_time_step}_$file[_0-9]*.nc ) ]; then
38       filebase=$( ls *${last_time_step}_$file*.nc | sed "s/^\(.*_\)0*$last_time_step.*/\1/" )
39       ${NEMO_TRBD}/rebuild_nemo -t $NPROC ${filebase}_${last_time_step}_$file $(( ${last_time_step} + 1 )) #>/dev/null
40       result=$( diff_nc ${TEST_DIR}/*${last_time_step}_$file.nc ${REFE_DIR}/*${last_time_step}_$file.nc )
41       printf "cdo diffv $result\n"
42       (( result_final = result_final + result ))
43#      \rm *${last_time_step}_${file}_[0-9]*.nc
44   else
45       printf "no restart files found for comparison\n"
46   fi
47
48    done
49
50    return ${result_final}
51}
52
53get_rel() {
54    for rel in $CDO $COMPILER $MPI $NETCDF; do
55                                arch_rel=$( echo $LOADEDMODULES | sed "s#.*$rel/\([^:]*\).*#\1#" )
56   [ -z "${arch_rel}" ] && arch_rel=$( echo $PATH          | sed "s#.*$rel/\([^/]*\).*#\1#" )
57   [ $( echo $rel | grep $COMPILER ) ] && arch_rel=$( $rel --version | grep -m1 -o ' [0-9.]* ' )
58   echo $rel ${arch_rel} >> model.log
59    done
60}
61
62get_rev() {
63    rev=0
64
65#    for dir in ${DIR_XIOS}  ${NEMO_ARCH} ${NEMO_CONF} ${NEMO_ENGI} ${NEMO_EIOI} \
66    for dir in ${NEMO_ARCH} ${NEMO_CONF} ${NEMO_ENGI} ${NEMO_EIOI} \
67          ${NEMO_EFCM} ${NEMO_TRUS} ${NEMO_TCMP} ${NEMO_TRBD}               ; do
68   # For time being, just get revision number from XIOS
69#  [ $dir == ${DIR_XIOS} ] && echo 'XIOS '$( svn info $dir | awk '(NR == 9) {print $NF}' ) >> model.log && continue
70   ${SVN_CMD} $dir
71   rev_loc=$( svn info $dir | awk '(NR == 9) {print $NF}' )
72   (( ${rev_loc} >= $rev )) && rev=${rev_loc}
73    done
74
75    echo 'NEMO '$rev >> model.log
76}
77
78mesg_make() {
79    paste -d ';' mesg_*_${CFG_USER}_${CFG_ARCH}.txt > trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt
80    cat trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt
81}
82
83mesg_publish() {
84 
85if [ $PUBLISH -eq 1 ]; then
86
87  if [ -f ${TEST_DIR}/trusting_${CFG_USER}_${CFG_ARCH}.txt ] ; then
88      tail -1 trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt >> ${TEST_DIR}/trusting_${CFG_USER}_${CFG_ARCH}.txt
89  else
90      cp      trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt    ${TEST_DIR}/trusting_${CFG_USER}_${CFG_ARCH}.txt
91  fi
92
93  cp trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt ${TEST_DIR}
94#  chmod o+r ${TEST_DIR}/trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt
95 
96#  rm -rf              ${DIR_WORK}/../../dods/public/${LOGNAME}/trusting/${CONF_REF}
97#  cp -alf ${TEST_DIR} ${DIR_WORK}/../../dods/public/${LOGNAME}/trusting/${CONF_REF}
98#  chmod o+rX          ${DIR_WORK}/../../dods/public/${LOGNAME}/trusting/${CONF_REF}
99 
100  # Send mail only when FAILED
101  if [[ $( grep 'FAILED' mesg_02_status_${CFG_USER}_${CFG_ARCH}.txt ) && ! -z $MAIL ]]; then
102      cat << END_MAIL > ${TEST_DIR}/trusting.mail
103XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
104Dear $USER,
105
106The trusting sequence for ${CONF_REF} has failed.
107Please consult http://webservices.ipsl.fr/trusting/
108
109Failed at step: `tail -n 1 mesg_03_step_${CFG_USER}_${CFG_ARCH}.txt`
110Directory : ${TEST_DIR}
111
112XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
113
114END_MAIL
115      mail -s "[trusting ${CONF_REF}] FAILED" $MAIL < ${TEST_DIR}/trusting.mail
116  fi
117
118fi
119}
120
121get_out() {
122   cd ${TEST_DIR}
123        mesg_make; mesg_publish
124
125        # Add tar saved into {DIR_STOR}
126   find ${DIR_SCRA}/trusting/${CONF_REF}/* -prune -mtime +7 -exec /bin/rm -rf {} \; > /dev/null 2>&1
127        [ -f ${DIR_STOR}/${CONF_REF}.tar ] && \rm ${DIR_STOR}/${CONF_REF}.tar
128        tar -cf ${DIR_STOR}/${CONF_REF}.tar .
129
130        exit
131}
Note: See TracBrowser for help on using the repository browser.