Index: branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/inc/trusting_func.sh
===================================================================
--- branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/inc/trusting_func.sh	(revision 8780)
+++ branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/inc/trusting_func.sh	(revision 8797)
@@ -4,5 +4,5 @@
 ## Messenger filenames
 file_date=mesg_01_date.txt  ; file_rslt=mesg_02_result.txt
-file_stat=mesg_03_state.txt ; file_nemo=mesg_04_nemo.txt
+file_stat=mesg_03_status.txt; file_nemo=mesg_04_nemo.txt
 file_xios=mesg_05_xios.txt  ; file_cmpf=mesg_06_compiler.txt
 file_lmpi=mesg_07_mpi.txt   ; file_ncdf=mesg_08_netcdf.txt
@@ -10,7 +10,4 @@
 file_memy=mesg_11_memory.txt; file_note=mesg_12_comments.txt
 
-## Trusting timestamped logfile & archive
-TRUS_FILE=trusting_${TRUS_DATE}_$TRUS_NAME.txt; TRUS_ARCH=trusting_${TRUS_DATE}_$TRUS_NAME.tgz
-
 
 ## Functions in order of use
@@ -24,5 +21,5 @@
 init_files() {
     echo 'Date'        	      > ${file_date}; echo 'Result'           > ${file_rslt}
-    echo 'State'      	      > ${file_stat}; echo 'NEMOGCM rev.'     > ${file_nemo}
+    echo 'Status'      	      > ${file_stat}; echo 'NEMOGCM rev.'     > ${file_nemo}
     echo 'XIOS rev.'   	      > ${file_xios}; echo 'Fortran compiler' > ${file_cmpf}
     echo 'MPI libs'    	      > ${file_lmpi}; echo 'NetCDF libs'      > ${file_ncdf}
@@ -118,12 +115,27 @@
 
 get_inputs() {
-    ## Extract archive or copy files in case of personal inputs
-    [ -z "${TRUS_TARF}" ] && get_io="cp ${TRUS_FORC}/* ." || get_io="tar -vxf ${TRUS_FORC}/${TRUS_TARF}"
-
-    ${get_io} > /dev/null
-    [ $? -ne 0 ] && get_out 3 || echo 'Success'
-    [ $( find -name '*.gz' -print -quit ) ] && find . -name '*.gz' -exec gzip -d {} \;
-
-    ls -lh > inputs_list.txt
+    # List archive content & extract it by default
+    local get_iol=$( eval "
+	for archive in ${TRUS_TARF}; do
+	    tar -tvf ${TRUS_FORC}/\$archive >> inputs_list.txt;
+	done
+	" )
+    local get_iof=$( eval "
+	for archive in ${TRUS_TARF}; do
+	    tar -vxf ${TRUS_FORC}/\$archive > /dev/null;
+	done
+	" )
+
+    ## List & copy files in case of personal inputs
+    if [ -z "${TRUS_TARF}" ]; then
+	get_iol="ls ${TRUS_FORC}/*"
+	get_iof="\cp ${TRUS_FORC}/* ."
+    fi
+
+    ${get_iol}; ${get_iof}
+
+    if [ `find -name '*.gz' -print -quit` ]; then
+	find . -name '*.gz' -exec gzip -d {} \;
+    fi
 }
 
@@ -196,70 +208,53 @@
 
 diff_restart() {
-    local base_name comp dif file list_comp list_tmsp nb_dom time_step tmsp
-    local files_list='' dif_sum=0
-
-    ## Stop if no benchmark files (ie time.step)
-    [ ! -e ${TRUS_STOR}/time.step ] && { TRUS_RSLT='FAILED'; get_out 7; }
-    time_step=$( cat ${TRUS_STOR}/time.step | tr -d [:space:] )
+    local dif filebase filebases ndomain out
+    local files_list='' dif_sum='undef'
 
     ## Find all restart files to rebuild
     if [ $( find -regex ".*_restart.*[0-9]\.nc" -print -quit ) ]; then
-	base_name=$( find -regex ".*_restart.*[0-9]\.nc"                       \
-	             | sed "s#^\./\(.*\)_[0-9]*_restart.*#\1#"       | sort -u   )
-	list_comp=$( find -regex ".*_restart.*[0-9]\.nc"                       \
-	             | sed "s#^.*\(restart[a-z_]*\)_[0-9].*\.nc#\1#" | sort -u   )
-	list_tmsp=$( find -regex ".*_restart.*[0-9]\.nc"                       \
-	             | sed "s#^.*\([0-9]\{8\}\)_restart.*#\1#"       | sort -u   )
-
-	## Loop on each time step
-	for tmsp in ${list_tmsp}; do
-
-	    for comp in ${list_comp}; do
-		file=${base_name}_${tmsp}_${comp}
-		nb_dom=$( find -name "${file}_[0-9]*.nc" | wc -l | awk '{ print $1 }' )
-
-		if   [ ${nb_dom} -gt 1 ]; then
-		    ${TRUS_NGCM}/TOOLS/REBUILD_NEMO/rebuild_nemo -t ${TRUS_NPRO} $file ${nb_dom} \
-			> /dev/null
-
-		     ## Possibility of remaining decomposed restarts (even after rebuild)
-		    [ $? -eq 0 ] && rm -f ${file}_[0-9]*.nc \
-                        > /dev/null
-
-		elif [ ${nb_dom} -eq 0 ]; then
-		    TRUS_RSLT='FAILED' && get_out 8
+	filebases=$( find -regextype sed -regex ".*_[0-9]\{4\}\.nc" \
+	             | sed 's/\(.*\)_.*/\1/' | sort -u                )
+
+	for filebase in ${filebases}; do
+
+	    ndomain=$( find -regex ".*${name}_[0-9]*.nc" | wc -l | awk '{print $1}' )
+
+	    [ ${ndomain} -eq 0 ] && TRUS_RSLT='FAILED' && get_out 8
+
+	    ${TRUS_NGCM}/TOOLS/REBUILD_NEMO/rebuild_nemo \
+		-t ${TRUS_NPRO} $filebase ${ndomain}     \
+		> /dev/null
+
+	    ## Possibility of remaining decomposed restarts (even after rebuild)
+	    [ $? -eq 0 ] && rm -f ${file}_[0-9]*.nc \
+                > /dev/null
+
+	    dif=''
+
+            ## Stop if no benchmark files (restart file)
+	    if [ -e ${TRUS_STOR}/$file.nc ]; then
+
+		out=$( $TRUS_CDOD $name.nc ${TRUS_STOR}/$name.nc 2>&1 )
+		dif=$( echo $out | grep -o "[0-9]* of [0-9]* records" )
+
+		## Fix for cdo aborting on restarts with different inputs
+		if [[ $out =~ 'Abort' ]]; then
+		    dif=$( echo $out | awk -F: '{print $NF}' )
 		fi
 
-		## Compare restart files at same time step
-		if [ $tmsp -eq ${time_step} ]; then
-
-                    ## Stop if no benchmark files (restart file)
-		    if [ -e ${TRUS_STOR}/$file.nc ]; then
-
-	                ## UNIX `cmp` not suitable (timestamp in .nc file)
-			dif=$( $TRUS_CDOD $file.nc ${TRUS_STOR}/$file.nc 2> /dev/null          \
-			       | awk '/records/ {print $0}' | sed '2 s/^/,/' | tr -d '\n' )
-
-			## CDO can return void stdout with no difference
-			if [[ -n "$dif" && $( echo $dif | awk '{print $1}' ) -ne 0 ]]; then
-			    TRUS_RSLT='FAILED'
-			    files_list+=$comp' ' && let dif_sum+=$( echo $dif | awk '{print $1}' )
-			    echo $file.nc': '$dif
-			fi
-
-		    else
-			TRUS_RSLT='FAILED' && get_out 7
-		    fi
-
-		else
-		    continue
+		if [ -n "$dif" ]; then
+		    export TRUS_RSLT='FAILED'
+		    files_list+=$name' ' && echo $name'.nc: '$dif
+		    let dif_sum+=$( echo $dif | awk '{print $1}' )
 		fi
 
-	    done
-
 	done
 
+    ## Stop if no benchmark files (ie time.step)
+	if   [ ${dif_sum} == 'undef' ]; then
+	    TRUS_RSLT='FAILED'
+	    get_out 7
         ## List different files for web comment with sum of different records
-	if [ ${dif_sum} -ne 0 ]; then
+	elif [ ${dif_sum} -ne 0      ]; then
 	    echo 'Restarts: '${files_list}${dif_sum}' record(s) differ<br>' \
 		>> temp_${file_note}
@@ -328,8 +323,8 @@
 
 	## Create or append trusting logfile
-	if [ -f ${TRUS_STOR}/trusting_$TRUS_NAME.txt ]; then cmd='tail -1'; else cmd='cat'; fi
-
-	$cmd ${TRUS_FILE}                            \
-	    >> ${TRUS_STOR}/trusting_$TRUS_NAME.txt
+	if [ -f ${TRUS_HIST} ]; then cmd='tail -1'; else cmd='cat'; fi
+
+	$cmd ${TRUS_FILE}   \
+	    >> ${TRUS_HIST}
 
         ## Send mail only when FAILED
