Index: branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/config/arch_template.cfg
===================================================================
--- branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/config/arch_template.cfg	(revision 5459)
+++ branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/config/arch_template.cfg	(revision 5464)
@@ -4,18 +4,23 @@
 
 # Available softwares:
-CDO=''           			  # CDO (Climate Data Operators) (root directory name in $LOADEDMODULES or $PATH)
-COMPILER=''      			  # ifort/gfortran/pgfortran/... ( ""     " "     ""  ""       ""       ""  " " )
-MPI=''           			  # MPI    libraries             ( ""     " "     ""  ""       ""       ""  " " )
-NETCDF=''        			  # NetCDF    " "                ( ""     " "     ""  ""       ""       ""  " " )
+CDO=''           			  # CDO (Climate Data Operators)
+                                           # (root directory name in $LOADEDMODULES or $PATH)
+COMPILER=''      			  # ifort/gfortran/pgfortran/...
+                                           # (to get compiler release with command `$COMPILER --version`)
+MPI=''           			  # MPI    libraries
+                                           # ( ""     " "     ""  ""       ""       ""  " " )
+NETCDF=''        			  # NetCDF    " "   
+                                           # ( ""     " "     ""  ""       ""       ""  " " )
 
-# Job commands:
+# Job commands (works with job ID):
 JOB_SUBM=''   	 			  # Submit a job && get his ID in return
-JOB_LIST=''    	 			  # List submitted jobs  (to know if the job is in progress with his ID)
-JOB_VIEW=''   	 			  # Get job informations (to increment a log during computing from job ID)
-JOB_DELE=''   	 			  # Stop a job           (not used currently)
+JOB_LIST=''    	 			  # List all submitted jobs to search for job ID with `grep`
+JOB_VIEW=''   	 			  # Get job informations (to fill in a log during computing)
+JOB_DELE=''   	 			  # Kill a job (in case of crash or time limit reaching)
 
 # Compiling & computing settings
-[ -z "$NPROC"       ] && NPROC=1          # Number of processing units
-[ -z "${TIME_LIMI}" ] && TIME_LIMI=''     # Timeout in s (pending & running)
+[ -z "$NPROC"       ] && NPROC=1          # Processing units for compilation
+[ -z "${TIME_LIMI}" ] && TIME_LIMI=''     # Utmost time in seconds to wait for finished job
+                                           # (pending & running)
 
 # Architecture environment (be careful with compliance with XIOS)
Index: branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting.env
===================================================================
--- branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting.env	(revision 5459)
+++ branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting.env	(revision 5464)
@@ -4,5 +4,5 @@
 # Time-stamp
 date_test=$( date )
-export DATE_STR=$( LC_ALL=C date -d"${date_test}" +%Y%m%dT%H%M )
+export DATESTR=$( date -ud "${date_test}" +%Y%m%d%Z%H%M )
 
 # Sourcing user configuration
@@ -14,4 +14,5 @@
 export DIR_XIOS  #DIR_OASI
 export NEMO_FORC FORC_TARF
+export EMAIL
 
 # Only interest for essential NEMO directories
Index: branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting.sh
===================================================================
--- branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting.sh	(revision 5459)
+++ branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting.sh	(revision 5464)
@@ -6,5 +6,5 @@
 NEMO_TRUS=$( pwd $( dirname $0 ) )
 DEBUG=0; PUBLISH=0
-STATUS='FAILED'; STEP=''# Only at end status will change to OK
+STATUS='FAILED'; STEP='' # Only at end status will change to OK
 
 # Get options for replacing some initials settings
@@ -13,5 +13,5 @@
     case $1 in
         -b|--branch ) NEMO_BRAN=$2         ; shift 2;; -d|--debug  ) set -vx; DEBUG=1     ; shift  ;;
-	-e|--email  ) MAIL=$2              ; shift 2;; -j|--job    ) NPROC=$2             ; shift 2;;
+	-e|--email  ) EMAIL=$2             ; shift 2;; -j|--job    ) NPROC=$2             ; shift 2;;
 	-h|--help   ) cat trusting_help.txt; exit  1;; -m|--machine) CFG_ARCH=$2          ; shift 2;;
 	-n|--newconf) TEST_CONF=$2         ; shift 2;; -r|--refconf) REFE_CONF=$2         ; shift 2;;
@@ -44,6 +44,6 @@
 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$datestr1\n" > mesg_01_date_${CFG_USER}_${CFG_ARCH}.txt
+date_str=$( date -ud ${DATESTR} +"%F %R %Z" )
+printf "Date\n${date_str}\n" > mesg_01_date_${CFG_USER}_${CFG_ARCH}.txt
 
 # SVN action on XIOS & NEMO essentials directories
@@ -57,5 +57,5 @@
 . ${ARCH_ENV} > /dev/null
 get_soft_rel
-cat arch_env.log
+cat model.log
 
 # XIOS compiling
@@ -79,19 +79,11 @@
 cd ${TEST_DIR}
 find ${NEMO_CONF}/${TEST_CONF}/EXP00 -regex '.*\(cfg\|opa\|ref\|xml\)' -exec cp {} . \;
-
-if [ ! -z "${FORC_TAR}" ]; then
-    cmd_iol="tar -tvf ${NEMO_FORC}/${FORC_TAR}"; cmd_iof="tar -vxf ${NEMO_FORC}/${FORC_TAR}"
-else
-    cmd_iol="ls ${NEMO_FORC}/*"                ; cmd_iof="\cp ${NEMO_FORC}/* ."
-fi
-
-${cmd_iol} > inputs_list.txt && ${cmd_iof} > /dev/null
+get_inputs
 [ $? -ne 0 ] && get_out $STATUS $STEP
-
 [ $( find . -name '*.gz' -print -quit ) ] && gunzip *.gz
 
 # Check input files in all cases
 #---------------------------------------------------
-print_step 'Difference between input files'
+print_step 'Difference with standard input files list'
 diff_inputs
 
@@ -101,21 +93,6 @@
 JOB_ID=$( ${JOB_SUBM} | awk '{print $NF}' )
 [ $? -ne 0 ] && get_out $STATUS $STEP
-
-print_step 'Pending/Running job'
-time_elapsed=0; time_increment=30
-sleep ${time_increment}
-while [[ $( ${JOB_LIST} | grep ${JOB_ID} ) && ${time_elapsed} -lt ${TIME_LIMI} ]]; do
-    printf "\n####################################################" >> computation.log
-    ${JOB_VIEW} ${JOB_ID}                                           >> computation.log
-    sleep ${time_increment}
-    let time_elapsed+=${time_increment}
-done
-sleep ${time_increment}
-
-if [ ${time_elapsed} -eq ${TIME_LIMI} ]; then
-    print_step 'Killing job'
-    ${JOB_DELE} ${JOB_ID} &> /dev/null
-    get_out $STATUS 'Job timeout'
-fi
+print_step 'Holding-Running job'
+job_pending
 print_step 'Job finished'
 
@@ -128,12 +105,8 @@
 fi
 
-STATUS='OK'
 # Inspect output text files
 #---------------------------------------------------
 print_step 'Test ASCII output files diff'
-for file in ocean.output solver.stat tracer.stat; do
-    diff $file ${REFE_DIR}/$file
-    [ $? -ne 0 ] && get_out 'FAILED' 'ASCII output file diff'
-done
+diff_textfiles
 
 # Inspect output NetCDF files
@@ -141,5 +114,4 @@
 print_step 'Test last restart NetCDF files diff'
 diff_restart
-[ $? -ne 0 ] && get_out 'FAILED' "$CDO diff failed"
 
 # Get computation duration
@@ -148,5 +120,5 @@
 get_cpu_time
 
-# Get comments (ocean.output & diff arch_env.log)
+# Get comments (ocean.output & diff model.log)
 #---------------------------------------------------
 comments 'W A R N I N G'
Index: branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting_func.sh
===================================================================
--- branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting_func.sh	(revision 5459)
+++ branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting_func.sh	(revision 5464)
@@ -16,6 +16,6 @@
     fi
 
-    if [ $( diff -q arch_env.log ${REFE_DIR}/arch_env.log ) ]; then
-	line=$( diff arch_env.log ${REFE_DIR}/arch_env.log  | tr -d '\n' )
+    if [ $( diff -q model.log ${REFE_DIR}/model.log ) ]; then
+	line=$( diff model.log ${REFE_DIR}/model.log  | tr -d '\n' )
     fi
 
@@ -29,4 +29,15 @@
 }
 
+get_inputs() {
+    if [ ! -z "${FORC_TAR}" ]; then
+	cmd_iol="tar -tvf ${NEMO_FORC}/${FORC_TAR}"; cmd_iof="tar -vxf ${NEMO_FORC}/${FORC_TAR}"
+    else
+	cmd_iol="ls ${NEMO_FORC}/*"                ; cmd_iof="\cp ${NEMO_FORC}/* ."
+    fi
+
+    ${cmd_iol} > inputs_list.txt
+    ${cmd_iof} > /dev/null
+}
+
 diff_inputs() {
     mesg='Same'
@@ -56,14 +67,14 @@
 	    fi
 
-	    cmp ${TEST_DIR}/${base_name}_$comp.nc ${REFE_DIR}/${base_name}_$comp.nc
+	    # UNIX `cmp` not suitable (filename & timestamp in .nc file)
+	    $CDO diffn ${TEST_DIR}/${base_name}_$comp.nc ${REFE_DIR}/${base_name}_$comp.nc 2> /dev/null
 	    if [ $? -ne 0 ]; then
 		STATUS='FAILED'; STEP='Restart files different'
-		printf "$CDO diffn\n"
-		$CDO diffn ${TEST_DIR}/${base_name}_$comp.nc ${REFE_DIR}/${base_name}_$comp.nc 2> /dev/null
+		#printf "$CDO diffn\n"
 	    else
 		printf "identical\n"
 	    fi
 
-	    \rm  ${TEST_DIR}/${base_name}_${comp}_[0-9]*.nc
+	    rm -f ${TEST_DIR}/${base_name}_${comp}_[0-9]*.nc &> /dev/null
 	done
 
@@ -73,5 +84,11 @@
     fi
 
-    [ $STATUS == 'FAILED'] && get_out $STATUS $STEP
+}
+
+diff_textfiles() {
+    for file in ocean.output $( ls *.stat ); do
+	diff $file ${REFE_DIR}/$file
+	[ $? -ne 0 ] && STATUS='FAILED' && STEP='ASCII output file diff'
+    done
 }
 
@@ -81,10 +98,10 @@
 	[ -z "${arch_rel}"  ] && arch_rel=$( echo $PATH          | sed  "s#.*$rel/\([^/]*\).*#\1#" )
 	[ $rel == $COMPILER ] && arch_rel=$( $rel --version      | grep -m1 -o ' [0-9.]* '         )
-	echo $rel ${arch_rel} >> arch_env.log
-    done
-
-    sed -n 3p arch_env.log | sed 'i\Compiler'    > mesg_05_compiler_${CFG_USER}_${CFG_ARCH}.txt
-    sed -n 4p arch_env.log | sed 'i\MPI libs'    > mesg_06_mpi_${CFG_USER}_${CFG_ARCH}.txt
-    sed -n 5p arch_env.log | sed 'i\NetCDF libs' > mesg_07_netcdf_${CFG_USER}_${CFG_ARCH}.txt
+	echo $rel ${arch_rel} >> model.log
+    done
+
+    sed -n 4p model.log | sed 'i\Compiler'    > mesg_05_compiler_${CFG_USER}_${CFG_ARCH}.txt
+    sed -n 5p model.log | sed 'i\MPI libs'    > mesg_06_mpi_${CFG_USER}_${CFG_ARCH}.txt
+    sed -n 6p model.log | sed 'i\NetCDF libs' > mesg_07_netcdf_${CFG_USER}_${CFG_ARCH}.txt
 }
 
@@ -102,10 +119,12 @@
 
     rev=0
-    for dir in ${DIR_XIOS}  ${NEMO_ARCH} ${NEMO_CONF} ${NEMO_ENGI} \
-	       ${NEMO_EIOI} ${NEMO_EFCM} ${NEMO_TCMP} ${NEMO_TRBD}  ; do
+    for dir in ${NEMO_ARCH} ${NEMO_CONF} ${NEMO_ENGI} \
+               ${NEMO_EIOI} ${NEMO_EFCM}              \
+	       ${NEMO_TCMP} ${NEMO_TRBD}              \
+	       ${DIR_XIOS}                             ; do
 
 	# For time being, just get revision number from XIOS
 	if [ $dir == ${DIR_XIOS} ]; then
-	    echo 'XIOS '$( svn info $dir | awk '(NR == 5) {print $NF}' ) >> arch_env.log
+	    echo 'XIOS '$( svn info $dir | awk '(NR == 5) {print $NF}' ) >> model.log
 	    continue
 	fi
@@ -116,10 +135,11 @@
     done
 
-    printf "NEMOGCM rev.\n$rev\n" > mesg_02_nemogcm_${CFG_USER}_${CFG_ARCH}.txt
+    echo   "NEMOGCM $rev"         >> model.log
+    printf "NEMOGCM rev.\n$rev\n" >  mesg_02_nemogcm_${CFG_USER}_${CFG_ARCH}.txt
 }
 
 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
+    paste -d ';' mesg_*_${CFG_USER}_${CFG_ARCH}.txt > trusting_${DATESTR}_${CFG_USER}_${CFG_ARCH}.txt
+    cat                                               trusting_${DATESTR}_${CFG_USER}_${CFG_ARCH}.txt
 }
 
@@ -130,8 +150,8 @@
   if [ -f ${REFE_DIR}/trusting_${CFG_USER}_${CFG_ARCH}.txt ]; then cmd='sed -n 2p'; else cmd='cat'; fi
 
-  $cmd trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.txt >> ${REFE_DIR}/trusting_${CFG_USER}_${CFG_ARCH}.txt
+  $cmd trusting_${DATESTR}_${CFG_USER}_${CFG_ARCH}.txt >> ${REFE_DIR}/trusting_${CFG_USER}_${CFG_ARCH}.txt
 
   # Send mail only when FAILED
-  if [[ ! -z $MAIL && $STATUS == 'FAILED' ]]; then
+  if [[ ! -z $EMAIL && $STATUS == 'FAILED' ]]; then
       cat << END_MAIL > trusting.mail
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
@@ -139,5 +159,5 @@
 
 The trusting sequence for ${CONF_REF} has failed at step:
-`tail -n 1 mesg_03_step_${CFG_USER}_${CFG_ARCH}.txt`
+`tail -n 1 ${TEST_DIR}/mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt`
 Directory : ${TEST_DIR}
 
@@ -145,6 +165,8 @@
 
 END_MAIL
-      cat mesg_*_${CFG_USER}_${CFG_ARCH}.txt        >> trusting.mail
-      mail -s "[trusting ${CONF_REF}] FAILED" $MAIL  < trusting.mail
+      if [ -e ${TEST_DIR}/trusting_${DATESTR}_${CFG_USER}_${CFG_ARCH}.txt ]; then
+	  cat ${TEST_DIR}/trusting_${DATESTR}_${CFG_USER}_${CFG_ARCH}.txt  >> trusting.mail
+      fi
+      mail -s "[trusting ${CONF_REF}] $STATUS $STEP" $EMAIL  <  trusting.mail
   fi
 
@@ -152,5 +174,8 @@
 }
 
-print_step() { STEP=$1; export STEP && printf "Step.....\n$TEP\n"; }
+print_step() {
+    [ ! -z "$1" ] && STEP=$1
+    export STEP && printf "Step.....\n$STEP\n"
+}
 
 get_out() {
@@ -162,5 +187,5 @@
 	touch mesg_08_inputfiles_${CFG_USER}_${CFG_ARCH}.txt mesg_09_realcputime_${CFG_USER}_${CFG_ARCH}.txt \
 	      mesg_10_comments_${CFG_USER}_${CFG_ARCH}.txt
-	#tar -czf ${REFE_DIR}/trusting_${DATE_STR}_${CFG_USER}_${CFG_ARCH}.tar.gz *
+	#tar -czf ${REFE_DIR}/trusting_${DATESTR}_${CFG_USER}_${CFG_ARCH}.tar.gz *
     fi
 
@@ -170,2 +195,28 @@
     exit 1
 }
+
+job_pending() {
+    time_elapsed=0; time_increment=30
+    sleep ${time_increment}
+
+    while [[ $( ${JOB_LIST} | grep ${JOB_ID} ) && ${time_elapsed} -lt ${TIME_LIMI} ]]; do
+	printf "\n####################################################" >> computation.log
+	${JOB_VIEW} ${JOB_ID}                                           >> computation.log
+	sleep ${time_increment}
+	let time_elapsed+=${time_increment}
+    done
+
+    sleep ${time_increment}
+
+    if [ ${time_elapsed} -eq ${TIME_LIMI} ]; then
+	STEP='Exceeded time limit'
+
+	if [ $( ${JOB_LIST} | grep ${JOB_ID} ) ]; then
+	    STEP='Job not finished on time: '$(( ${TIME_LIMI}/3600 ))'h'
+	fi
+
+	print_step
+	${JOB_DELE} ${JOB_ID} &> /dev/null
+	get_out $STATUS $STEP
+    fi
+}
