Index: branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting.sh
===================================================================
--- branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting.sh	(revision 5432)
+++ branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/TRUST/trusting.sh	(revision 5438)
@@ -11,5 +11,5 @@
 #---------------------------------------------------
 NEMO_TRUS=$( pwd $( dirname $0 ) )
-SVN_CMD='svn status'
+SVN_OPT='status'
 DEBUG=0; PUBLISH=0; status='OK'
 
@@ -27,7 +27,4 @@
     esac
 done
-
-#export DEBUG PUBLISH
-
 
 # Initialization (super-computer & user environment)
@@ -47,10 +44,5 @@
 fi
 
-# If -v|--version option has been set, modify svn command
-[ $( echo ${NEMO_VERS} | grep  "up\|update"         ) ] && SVN_CMD='svn update'
-[ $( echo ${NEMO_VERS} | tr -d '[:alpha:][:punct:]' ) ] && SVN_CMD='svn update -r '$( echo ${NEMO_VERS} | tr -d '[:alpha:][:punct:]' )
-
 . ./trusting_func.sh
-
 
 # 
@@ -59,39 +51,30 @@
 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
+printf "Date\n$datestr1\n" > mesg_01_date_${CFG_USER}_${CFG_ARCH}.txt
 # Only at end status will change to OK
-printf "Status\nFAILED\n"           > mesg_03_status_${CFG_USER}_${CFG_ARCH}.txt
+status='FAILED'
 
-
-# Check softwares versions
+# Check softwares versions (source arch environment)
 #---------------------------------------------------
-printf "Step......................\nGet softwares release\n"                     | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
-. ${ARCH_ENV} > /dev/null    # Sourcing architecture environment
+pstep 'Get softwares release'
+. ${ARCH_ENV} > /dev/null
 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
-sed -n 4p model.log | sed 'i\NetCDF libraries' | tee mesg_07_netcdf_${CFG_USER}_${CFG_ARCH}.txt
-
 
 # SVN action on XIOS & NEMO essentials directories
 #---------------------------------------------------
-printf "Step......................\nGet NEMO SVN revision with: ${SVN_CMD}\n"    | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
+pstep "Get NEMO SVN state with: ${SVN_OPT}"
 get_nemo_rev
-sed -n 6p model.log | sed 'i\NEMO revision'    | tee  mesg_02_nemo_${CFG_USER}_${CFG_ARCH}.txt
-
-
+exit 0
 # NEMO config compiled from scratch
 #---------------------------------------------------
-printf "Step......................\nCompiling ${CONF_REF} configuration\n"       | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
+pstep "Compiling ${CONF_REF} configuration"
 cd ${NEMO_CONF}
 #[ -d ${TEST_CONF} ] && ./makenemo -n ${TEST_CONF} clean
 ./makenemo -n ${TEST_CONF} -r ${REFE_CONF} -m $ARCH -j $NPROC >& /dev/null
-[ ! -e ${TEST_CONF}/BLD/bin/nemo.exe ] && get_out
-
+[ ! -e ${TEST_CONF}/BLD/bin/nemo.exe ] && get_out $step $status
 
 # Get namelists, xml & forced files for running
 #---------------------------------------------------
-cd ${TEST_DIR}
-printf "Step......................\nPreparing job\n"                             | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
+pstep 'Preparing job'
 find ${NEMO_CONF}/${TEST_CONF}/EXP00 -regex '.*\(cfg\|opa\|ref\|xml\)' -exec cp {} . \;
 
@@ -103,13 +86,17 @@
 
 ${cmd_iol} > inputs_list.txt && ${cmd_iof} > /dev/null
-[ $? -ne 0 ] && get_out
+[ $? -ne 0 ] && get_out $step $status
 [ $( find . -name '*.gz' -print -quit ) ] && gunzip *.gz
-exit 0
+
+# Check input files in all cases
+#---------------------------------------------------
+pstep 'Test input files difference'
+diff_inputs
 
 # Job submission & computing
 #---------------------------------------------------
-printf "Step......................\nRunning\n"                                   | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt; echo ${JOB_SUBM}
+pstep 'Running'
 job_num=$( ${JOB_SUBM} | awk '{print $NF}' )
-[ $? -ne 0 ] && get_out
+[ $? -ne 0 ] && get_out $step $status
 
 time_elapsed=0; time_increment=30
@@ -125,62 +112,40 @@
 # Eventual crash during computing
 #---------------------------------------------------
-printf "Step......................\nTest if ASCII output files exist\n"          | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
-if   [ ! -f ocean.output                  ]; then
-    printf "Step......................\nOpa crashed at initialization\n"         | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
+pstep 'Test if ASCII output files exist'
+if   [[ ! -f ocean.output || $( grep 'E R R O R' ocean.output ) ]]; then
+    ${JOB_DELE} ${job_num} &> /dev/null
+    [ ! -f ocean.output                  ] && step='nemo.exe crashed at initialization'
+    [ $( grep 'E R R O R' ocean.output ) ] && step='nemo.exe crashed'
+    comments('E R R O R')
     ${JOB_DELE} ${job_num} >/dev/null 2>&1
     status='FAILED'
-elif [ $( grep 'E R R O R' ocean.output ) ]; then
-    printf "Step......................\nOpa crashed\n"                           | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
-    grep 'E R R O R'       ocean.output | tee    mesg_10_comments_${CFG_USER}_${CFG_ARCH}.txt
-    sed 's/^/Time step :/' time.step    | tee -a mesg_10_comments_${CFG_USER}_${CFG_ARCH}.txt
-    ${JOB_DELE} ${job_num} >/dev/null 2>&1
-    status='FAILED'
+    get_out $step $status
+else
+    status='OK'
+
+    # Inspect output text files
+    #---------------------------------------------------
+    pstep 'Test ASCII output files diff'
+    for file in ocean.output solver.stat tracer.stat; do
+	diff $file ${REFE_DIR}/$file
+	[ $? -ne 0 ] && status='FAILED'
+    done
+
+    # Inspect output NetCDF files
+    #---------------------------------------------------
+    pstep 'Test last restart NetCDF files diff'
+    diff_restart #2> /dev/null
+    [ $? -ne 0 ] && status='FAILED'
+
+    # Get computation duration
+    #---------------------------------------------------
+    pstep 'Get real CPU time'
+    get_cpu_time
+
+    comments('W A R N I N G')
 fi
-
-
-# Inspect output text files
-#---------------------------------------------------
-printf "Step......................\nTest ASCII output files difference\n"        | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
-for file in ocean.output solver.stat tracer.stat; do
-    diff $file ${REFE_DIR}/$file
-    [ $? -ne 0 ] && status='FAILED'
-done
-
-
-# Inspect output NetCDF files
-#---------------------------------------------------
-printf "Step......................\nTest last restart NetCDF files difference\n" | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
-diff_restart 2>/dev/null
-[ $? -ne 0 ] && status='FAILED'
-
-
-# Finals tests
-#---------------------------------------------------
-if [ $status != 'FAILED' ]; then
-
-    # Comments
-    #---------------------------------------------------
-    echo 'Comments'                    | tee    mesg_10_comments_${CFG_USER}_${CFG_ARCH}.txt
-    grep 'W A R N I N G:' ocean.output | tee -a mesg_10_comments_${CFG_USER}_${CFG_ARCH}.txt
-
-    # Portability !
-    printf "Step......................\nGet real CPU time\n"                     | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
-    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
-    diff_inputs
-    get_out
-fi
-
-
-# So far, everything is good
-#---------------------------------------------------
-printf "Status\nOK\n" > mesg_03_status_${CFG_USER}_${CFG_ARCH}.txt
-printf "Step......................\nCode is reliable\n"                          | tee mesg_04_step_${CFG_USER}_${CFG_ARCH}.txt
-
 
 # End
 #---------------------------------------------------
-get_out
+if [ $status == 'FAILED' ]; then step='Test outputs difference'; else step='Code is reliable'; fi
+get_out $step $status
