Index: /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting.sh
===================================================================
--- /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting.sh	(revision 5423)
+++ /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting.sh	(revision 5424)
@@ -51,9 +51,12 @@
 [ $( echo ${NEMO_VERS} | tr -d '[:alpha:][:punct:]' ) ] && SVN_CMD='svn update -r '$( echo ${NEMO_VERS} | tr -d '[:alpha:][:punct:]' )
 
-datestr1=$( LC_ALL=C date -d"${DATE_STR}" +%Y-%m-%dT%H:%M )
 . ./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%s\n"       $datestr1 > mesg_01_date_${CFG_USER}_${CFG_ARCH}.txt
 # Only at end status will change to OK
@@ -65,5 +68,5 @@
 printf "Step......................\nGet softwares release\n"                     | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
 . ${ARCH_ENV} > /dev/null    # Sourcing architecture environment
-get_rel
+get_soft_rel
 sed -n 2p model.log | sed 'i\Fortran compiler' | tee mesg_05_compiler_${CFG_USER}_${CFG_ARCH}.txt
 sed -n 3p model.log | sed 'i\MPI libraries   ' | tee mesg_06_mpi_${CFG_USER}_${CFG_ARCH}.txt
@@ -74,6 +77,6 @@
 #---------------------------------------------------
 printf "Step......................\nGet NEMO SVN revision with: ${SVN_CMD}\n"    | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
-get_rev
-sed -n 6p model.log | sed 'i\NEMO revision' > mesg_02_nemo_${CFG_USER}_${CFG_ARCH}.txt
+get_nemo_rev
+sed -n 6p model.log | sed 'i\NEMO revision'    | tee  mesg_02_nemo_${CFG_USER}_${CFG_ARCH}.txt
 
 
@@ -83,5 +86,5 @@
 cd ${NEMO_CONF}
 #[ -d ${TEST_CONF} ] && ./makenemo -n ${TEST_CONF} clean
-./makenemo -n ${TEST_CONF} -r ${REFE_CONF} -m $ARCH -j $NPROC > /dev/null 2>&1
+./makenemo -n ${TEST_CONF} -r ${REFE_CONF} -m $ARCH -j $NPROC >& /dev/null
 [ ! -e ${TEST_CONF}/BLD/bin/nemo.exe ] && get_out
 
@@ -165,4 +168,5 @@
     real_cpu_time=$( ${JOB_VIEW} ${job_num} | awk 'END{print $9}' )
     printf "Real CPU time\n%s\n" ${real_cpu_time} | tee mesg_08_realcputime_${CFG_USER}_${CFG_ARCH}.txt
+    printf "Input files\nNA"                      | tee mesg_09_inputfiles_${CFG_USER}_${CFG_ARCH}.txt
 else
     printf "Step......................\nTest input files difference\n"           | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
Index: /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting_func.sh
===================================================================
--- /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting_func.sh	(revision 5423)
+++ /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting_func.sh	(revision 5424)
@@ -19,5 +19,5 @@
     stat=100; file1=$1; file2=$2
 
-    cdo diffv $file1 $file2 > out_tmp
+    $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
@@ -27,29 +27,32 @@
 
 diff_restart() {
+    result=0
     last_time_step=$( cat ${REFE_DIR}/time.step | tr -d [:space:] )
-    result_final=0
-
     echo 'Last time step: '${last_time_step}
 
-    for file in restart restart_ice restart_trc; do
-	printf "${TEST_DIR}/*${last_time_step}_${file}*.nc: "
-	find ${TEST_DIR} -name *${last_time_step}_$file*.nc && exit 0
-	if [ $( find ${TEST_DIR} -regex .*${last_time_step}_$file[_0-9]*.nc ) ]; then
-	    filebase=$( ls *${last_time_step}_$file*.nc | sed "s/^\(.*_\)0*$last_time_step.*/\1/" )
-	    ${NEMO_TRBD}/rebuild_nemo -t $NPROC ${filebase}_${last_time_step}_$file $(( ${last_time_step} + 1 )) #>/dev/null
-	    result=$( diff_nc ${TEST_DIR}/*${last_time_step}_$file.nc ${REFE_DIR}/*${last_time_step}_$file.nc )
-	    printf "cdo diffv $result\n"
-	    (( result_final = result_final + result ))
+    if [ $( find ${TEST_DIR} -name "*${last_time_step}_restart*.nc" -print -quit ) ]; then
+	file_base=$( find ${TEST_DIR} -name "*${last_time_step}_restart*.nc" -print -quit | \
+	             sed "s/^\(.*\)0*$last_time_step.*/\1/"                                 )
+
+	for file in restart restart_ice restart_trc; do
+	    printf "${TEST_DIR}/*${last_time_step}_${file}*.nc: "
+
+	    nb_dom=$( find ${TEST_DIR} -name "*${last_time_step}_${file}_[0-9]*.nc" | wc -l | awk '{print $1}' )
+	    if [ ${nb_dom} -gt 1 ]; then
+		${NEMO_TRBD}/rebuild_nemo -t $NPROC ${file_base}${last_time_step}_$file ${nb_dom} >/dev/null
+	    fi
+
+#	    result=$( diff_nc ${TEST_DIR}/*${last_time_step}_$file.nc ${REFE_DIR}/*${last_time_step}_$file.nc )
+	    result=$( diff_nc ${file_base}${last_time_step}_$file.nc ${REFE_DIR}/*${last_time_step}_$file.nc )
+	    printf "$CDO diffv $result\n"
 #	    \rm *${last_time_step}_${file}_[0-9]*.nc
-	else
-	    printf "no restart files found for comparison\n"
-	fi
+	done
 
-    done
-
-    return ${result_final}
+    else
+	printf "no restart files found for comparison\n"
+    fi
 }
 
-get_rel() {
+get_soft_rel() {
     for rel in $CDO $COMPILER $MPI $NETCDF; do
                                 arch_rel=$( echo $LOADEDMODULES | sed "s#.*$rel/\([^:]*\).*#\1#" )
@@ -60,12 +63,11 @@
 }
 
-get_rev() {
+get_nemo_rev() {
     rev=0
 
-#    for dir in ${DIR_XIOS}  ${NEMO_ARCH} ${NEMO_CONF} ${NEMO_ENGI} ${NEMO_EIOI} \
-    for dir in ${NEMO_ARCH} ${NEMO_CONF} ${NEMO_ENGI} ${NEMO_EIOI} \
+    for dir in ${DIR_XIOS}  ${NEMO_ARCH} ${NEMO_CONF} ${NEMO_ENGI} ${NEMO_EIOI} \
 	       ${NEMO_EFCM} ${NEMO_TRUS} ${NEMO_TCMP} ${NEMO_TRBD}               ; do
 	# For time being, just get revision number from XIOS
-#	[ $dir == ${DIR_XIOS} ] && echo 'XIOS '$( svn info $dir | awk '(NR == 9) {print $NF}' ) >> model.log && continue
+	[ $dir == ${DIR_XIOS} ] && echo 'XIOS '$( svn info $dir | awk '(NR == 9) {print $NF}' ) >> model.log && continue
 	${SVN_CMD} $dir
 	rev_loc=$( svn info $dir | awk '(NR == 9) {print $NF}' )
@@ -85,27 +87,16 @@
 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
+  if [ -f ${REFE_DIR}/trusting_${CFG_USER}_${CFG_ARCH}.txt ]; then cmd='sed -n 2p'; else cmd='cat'; 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}
-  
+  $cmd trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt >> ${REFE_DIR}/trusting_${CFG_USER}_${CFG_ARCH}.txt
+
   # 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
+      cat << END_MAIL > 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`
+The trusting sequence for ${CONF_REF} has failed at step:
+`tail -n 1 mesg_03_step_${CFG_USER}_${CFG_ARCH}.txt`
 Directory : ${TEST_DIR}
 
@@ -113,5 +104,6 @@
 
 END_MAIL
-      mail -s "[trusting ${CONF_REF}] FAILED" $MAIL < ${TEST_DIR}/trusting.mail
+      cat mesg_*_${CFG_USER}_${CFG_ARCH}.txt        >> trusting.mail
+      mail -s "[trusting ${CONF_REF}] FAILED" $MAIL  < trusting.mail
   fi
 
@@ -120,12 +112,13 @@
 
 get_out() {
-	cd ${TEST_DIR}
-        mesg_make; mesg_publish
+    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
+    # Save tested configuration if trusting failed
+    if [ $status == 'FAILED' ]; then
+	cd ${REFE_DIR}
+	tar -czf trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.tar.gz ${TEST_DIR}/*
+	cd -
+    fi
+	
+    exit 1
 }
