Index: /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/SETTE/trusting.env
===================================================================
--- /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/SETTE/trusting.env	(revision 5268)
+++ /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/SETTE/trusting.env	(revision 5268)
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+
+# Time-stamp
+date_test=$( date )
+export DATESTR=$( LC_ALL=C date -d"${date_test}" +%Y%m%dT%H%M )
+
+# Super-computers configuration
+if   [ $USER == ${IDRIS_ID} ]; then 
+    ID=${IDRIS_ID}      ; ARCH='X64_ADA'
+    JOB_SUB=llsubmit    ; JOB_VIEW=''                  ; JOB_DEL=llcancel                          ; JOB_LIST=llq
+    DIR_WORK=$WORKDIR   ; DIR_SCRA=$TMPDIR/trusting    ; DIR_STOR=$HOME/Workspace/NEMO/trusting_sav
+elif [ $USER == ${TGCC_ID}  ]; then
+    ID=${TGCC_ID}       ; ARCH='X64_CURIE'
+    JOB_SUB=ccc_msub    ; JOB_VIEW=ccc_macct           ; JOB_DEL=ccc_mdel                          ; JOB_LIST=ccc_mpp
+    DIR_WORK=$CCCWORKDIR; DIR_SCRA=$SCRATCHDIR/trusting; DIR_STOR=$CCCSTOREDIR/trusting_sav
+else
+    ID=''           	; ARCH=''
+    JOB_SUB=''      	; JOB_VIEW=''                  ; JOB_DEL=''
+    DIR_WORK=''     	; DIR_SCRA=''                  ; DIR_STOR=''
+fi
+
+export ID       ARCH
+export JOB_SUB  JOB_VIEW JOB_DEL  JOB_LIST
+export DIR_WORK DIR_SCRA DIR_STOR 
+
+
+# NEMO compilation config
+NEMO_BRAN=trunk; NEMO_HOME=${DIR_WORK}/NEMO/${NEMO_BRAN}/NEMOGCM # dev_r5092_CNRS_SETTE dev_v3_4_STABLE_2012
+export NEMO_HOME NEMO_BRAN
+NEMO_ARCH=${NEMO_HOME}/ARCH        ; NEMO_CONF=${NEMO_HOME}/CONFIG         ; NEMO_ENGI=${NEMO_HOME}/NEMO
+NEMO_EFCM=${NEMO_HOME}/EXTERNAL/fcm; NEMO_IPSL=${NEMO_HOME}/EXTERNAL/IOIPSL; NEMO_TCMP=${NEMO_HOME}/TOOLS/COMPILE
+export NEMO_ARCH NEMO_CONF NEMO_EFCM NEMO_ENGI NEMO_IPSL NEMO_TCMP
+
+
+# NEMO inputs config
+export NEMO_FORC=${DIR_WORK}/NEMO/FORC FORC_TAR=ORCA2_LIM_nemo_v3.6.tar
+
+
+# External softs directories
+export DIR_XIOS=${DIR_WORK}/XIOS/xios-1.0 DIR_OASI=${DIR_WORK}/OASIS
+
+
+# Environment architecture
+. ${DIR_XIOS}/arch/arch-${ARCH}_trust.env
+
+
+# Comparatives directories localization
+DIR_REFE=${DIR_STOR}/${CONF_REF}/${NEMO_BRAN}
+DIR_TEST=${DIR_SCRA}/${CONF_REF}/${NEMO_BRAN}/trusting_${DATESTR}
+export DIR_REFE DIR_TEST
Index: /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/SETTE/trusting.sh
===================================================================
--- /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/SETTE/trusting.sh	(revision 5268)
+++ /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/SETTE/trusting.sh	(revision 5268)
@@ -0,0 +1,153 @@
+#!/bin/bash
+
+
+PUBLISH=0; DEBUG=0; status='OK'
+
+while [ $# -ne 0 ]; do
+    case $1 in
+        -d|--debug     ) set -vx; DEBUG=1     ; shift;;
+        -p|--publish   ) PUBLISH=1            ; shift;;
+        -h|--help|-help) cat trusting_help.txt; exit ;;
+	*)                                      break;;
+    esac
+done
+export PUBLISH DEBUG
+[ $# -ne 1 ] && { ./trusting.sh -h && exit; }
+# suspend debug mode (too verbose)
+#[ $debug -eq 1 ] && set +vx
+
+# Initialization
+#=============================================
+CONF_REF=$1; conf_ref_dir=${CONF_REF}_trust
+export CONF_REF
+
+. trusting.env
+echo ${DIR_TEST}
+mkdir -p ${DIR_TEST} ${DIR_REFE}
+cd ${DIR_TEST}
+datestr1=$( LC_ALL=C date -d"$DATESTR" +%Y-%m-%dT%H:%M )
+printf "Date\n%s\n"       $datestr1 > mesg_01_date.txt
+
+printf "Status\nFAILED\n"           > mesg_02_status.txt # Only at end status will change to OK
+
+. trusting_func.sh
+#=============================================
+
+
+# 
+#=============================================
+for rel in intel bullxmpi netcdf; do
+    printf "Step......................\nGet $rel release\n" > mesg_03_step.txt
+    arch_rel=$( echo $LOADEDMODULES | sed "s/.*:$rel\/\([^:]*\).*/\1/" )
+    [ $? -ne 0 ] && getout
+    echo $rel ${arch_rel} >> model.log
+done
+
+sed -n 1p model.log | sed 'i\Fortran compiler' > mesg_04_curiec.txt
+sed -n 2p model.log | sed 'i\MPI             ' > mesg_05_mpicurie.txt
+sed -n 3p model.log | sed 'i\NetCDF          ' > mesg_06_netcdf_curie.txt
+
+
+#---------------------------------------------
+printf "Step......................\nCheckout XIOS, FCM-make(/EXTERNAL/fcm), NEMO engines (/NEMO) & configuration (/CONFIG)\n" > mesg_03_step.txt
+rev=0
+for dir in ${DIR_XIOS} ${NEMO_ARCH} ${NEMO_CONF} ${NEMO_EFCM} ${NEMO_ENGI} ${NEMO_IPSL} ${NEMO_TCMP}; do
+    svn up $dir
+    rev_loc=$( svn info $dir | awk '(NR == 9) {print $NF}' )
+    [ $dir == ${DIR_XIOS} ] && echo 'XIOS '${rev_loc} >> model.log && continue
+    (( ${rev_loc} >= $rev )) && rev=${rev_loc}
+done
+echo 'NEMO '$rev >> model.log
+
+
+#---------------------------------------------
+#printf "Step......................\nCompilation NEMO configuration %s\n" ${CONF_REF} > mesg_03_step.txt
+#cd ${NEMO_CONF}
+#./makenemo -n ${conf_ref_dir} clean
+#./makenemo -n ${conf_ref_dir} -r ${CONF_REF} -m X64_CURIE_trust -j 16 #> /dev/null 2>&1
+#[ ! -e ${conf_ref_dir}/BLD/bin/nemo.exe ] && getout
+
+
+#---------------------------------------------
+printf "Step......................\nPreparing job\n" > mesg_03_step.txt
+cd ${DIR_TEST}
+find ${NEMO_CONF}/${conf_ref_dir}/EXP00 -regex '.*\(cfg\|opa\|ref\|xml\)' -exec cp {} . \;
+cp ${NEMO_FORC}/${FORC_TAR} . && tar -tvf ${FORC_TAR} > inputs_list.txt && tar -vxf ${FORC_TAR}
+[ $? -ne 0 ] && getout
+gunzip *.gz
+
+
+#---------------------------------------------
+printf "Step......................\nRunning\n"       > mesg_03_step.txt
+#${JOB_SUB} ${DIR_TEST}/../../batch.sh
+job_num=$( ${JOB_SUB} ${DIR_TEST}/../../batch.sh | awk '{print $NF}')
+[ $? -ne 0 ] && getout
+
+output_test=ocean.output   ; output_refe=${DIR_REFE}/ocean.output
+solver_test=solver.stat    ; solver_refe=${DIR_REFE}/solver.stat
+tracer_test=tracer.stat    ; tracer_refe=${DIR_REFE}/tracer.stat
+inputs_test=inputs_list.txt; inputs_refe=${DIR_REFE}/inputs_list.txt
+
+#time_elapsed=0; time_limit=10800; time_increment=300
+time_elapsed=0; time_limit=1080; time_increment=30
+sleep ${time_increment}
+while [[ $( ${JOB_LIST} | grep $job_num ) && ${time_elapsed} -lt ${time_limit} ]] ; do
+#while [[ ! -f ${solver_test} && ${time_elapsed} -lt ${time_limit} ]] ; do
+    printf "\n####################################################" >> ${DIR_TEST}/mpp.log
+    ${JOB_VIEW} $job_num >> mpp.log
+#   ${JOB_VIEW} $id >> mpp.log
+    sleep ${time_increment}
+    let time_elapsed+=time_increment
+done
+
+
+#---------------------------------------------
+printf "Step......................\nTest if solver exists\n"   > mesg_03_step.txt
+if [ ! -f ${solver_test} ]; then
+    grep 'E R R O R' ocean.output    >> mesg_11_comments.txt
+    sed 's/^/Time step :/' time.step >> mesg_11_comments.txt
+    getout
+fi
+
+
+#---------------------------------------------
+printf "Step......................\nTest solvers difference\n" > mesg_03_step.txt
+diff ${output_refe} ${output_test}
+[ $? -ne 0 ] && status='FAILED'
+diff ${solver_refe} ${solver_test}
+[ $? -ne 0 ] && status='FAILED'
+diff ${tracer_refe} ${tracer_test}
+[ $? -ne 0 ] && status='FAILED'
+
+
+#---------------------------------------------
+printf "Step......................\nTest outputs difference\n" > mesg_03_step.txt
+#diff_trusting 2>/dev/null
+#[ $? -ne 0 ] && status='FAILED'
+
+
+#---------------------------------------------
+printf "Comments\n\n"              >  mesg_11_comments.txt
+grep 'W A R N I N G:' ocean.output >> mesg_11_comments.txt
+
+
+#---------------------------------------------
+if [ $status != 'FAILED' ]; then
+    printf "Step......................\nGet Real CPU time\n" > mesg_03_step.txt
+    real_cpu_time=$( ${JOB_VIEW} $job_num | awk 'END{print $9}')
+    [ $? -ne 0 ] && getout
+    printf "Real CPU time\n%s\n" ${real_cpu_time} > mesg_08_realcputime.txt
+else
+    printf "Step......................\nTest InputFiles difference\n" > mesg_03_step.txt
+    diff ${inputs_refe} ${inputs_test}
+    { [ $? -ne 0 ] && printf "InputFiles\n%s\n" "Different" > mesg_09_inputfiles.txt } || printf "InputFiles\n%s\n" "Same" > mesg_09_inputfiles.txt
+    getout
+fi
+
+
+#---------------------------------------------
+printf "Status\nOK\n" > mesg_02_status.txt
+printf "Step......................\nCode is reliable\n" > mesg_03_step.txt
+
+#---------------------------------------------
+getout
Index: /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/SETTE/trusting_func.sh
===================================================================
--- /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/SETTE/trusting_func.sh	(revision 5268)
+++ /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/SETTE/trusting_func.sh	(revision 5268)
@@ -0,0 +1,106 @@
+#!/bin/bash
+
+function mesg_make { 
+    paste -d ';' mesg_*.txt > trusting_${DATESTR}.txt
+    cat trusting_${DATESTR}.txt
+}
+
+#=============================================
+function mesg_publish { 
+  
+if [ $PUBLISH -eq 1 ]; then
+
+  if [ -f ${DIR_TEST}/trusting.txt ] ; then
+      tail -1 trusting_${DATESTR}.txt >> ${DIR_TEST}/trusting.txt
+  else
+      cp      trusting_${DATESTR}.txt    ${DIR_TEST}/trusting.txt
+  fi
+
+  cp trusting_${DATESTR}.txt ${DIR_TEST}
+#  chmod o+r ${DIR_TEST}/trusting_${DATESTR}.txt
+  
+#  rm -rf              ${DIR_WORK}/../../dods/public/${LOGNAME}/trusting/${CONF_REF}
+#  cp -alf ${DIR_TEST} ${DIR_WORK}/../../dods/public/${LOGNAME}/trusting/${CONF_REF}
+#  chmod o+rX          ${DIR_WORK}/../../dods/public/${LOGNAME}/trusting/${CONF_REF}
+  
+  # Send mail only when FAILED
+  if [ grep 'FAILED' mesg_02_status.txt ]; then
+      cat << END_MAIL > ${DIR_TEST}/trusting.mail
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+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.txt`
+Directory : ${DIR_TEST}
+
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+
+END_MAIL
+      mail -s "[trusting ${CONF_REF}] FAILED" ntmlod@locean-ipsl.upmc.fr < ${DIR_TEST}/trusting.mail
+  fi
+
+fi
+
+}
+
+#=============================================
+function getout { 
+	cd ${DIR_TEST}
+        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_REFE}/${CONF_REF}.tar ] && \rm ${DIR_STOR}/${CONF_REF}.tar
+        tar -cf ${DIR_REFE}/trusting_${DATESTR}.tar .
+
+        exit
+}
+
+#=============================================
+function diffnc {
+    stat=100; file1=$1; file2=$2
+
+    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
+
+    return $stat
+} 
+
+#---------------------------------------------
+function diff_trusting {
+
+    name_first=${JOB_NAME}
+    name_second=EXP00C
+    rep_ref=EXP00C_REFE
+    experiment_name=trusting
+    tagname=TEST
+    #listcomp="ATM SBG SRF CPL ICE MBG OCE"
+    listcomp="ATM SRF CPL ICE MBG OCE"
+    result_final=0
+
+# Output  
+    cd ${DIR_SCRA}/IGCM_OUT/${CONFIG_WORK}/${tagname}/${experiment_name}/${name_first}
+    for comp in ${listcomp}; do
+	echo ${comp}
+	cd ${DIR_SCRA}/IGCM_OUT/${CONFIG_WORK}/${tagname}/${experiment_name}/${name_first}/${comp}/Output
+	listfreq=$(ls -d MO/ DA/)
+	for freq in ${listfreq}; do
+            echo ${freq}
+            cd ${DIR_SCRA}/IGCM_OUT/${CONFIG_WORK}/${tagname}/${experiment_name}/${name_first}/${comp}/Output/${freq}
+            listfile=$( ls *.nc )
+            for file in ${listfile}; do
+		var=$( echo $file | sed -e "s/^${name_first}//" )
+		result=$( diffnc ${name_first}${var} ${DIR_SCRA}/IGCM_OUT/${CONFIG_WORK}/${tagname}/${CONFIG_WORK}/${rep_ref}/${comp}/Output/${freq}${name_second}${var} )
+		result=$?
+		echo 'diffnc '${name_first}${var} ${DIR_SCRA}/IGCM_OUT/${CONFIG_WORK}/TEST/${CONFIG_WORK}/${rep_ref}/${comp}/Output/${freq}${name_second}${var}
+		echo $result
+		(( result_final = result_final + result ))
+            done
+	done
+    done
+    return $result_final
+
+}
Index: /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/SETTE/trusting_help.txt
===================================================================
--- /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/SETTE/trusting_help.txt	(revision 5268)
+++ /branches/2015/dev_r5092_CNRS_SETTE/NEMOGCM/SETTE/trusting_help.txt	(revision 5268)
@@ -0,0 +1,21 @@
+----------------------------------------------------------------------------
+Usage: trusting [-h] [-d] [-p] configuration
+
+Options:
+   -h, --help, -help
+       Print this manual
+   -d, --debug
+       set -v
+   -p, --publish
+       Publish on dods server
+
+Examples:"
+   $ trusting -p ORCA2_LIM3
+
+Notes:
+   - To reset the trusting dashboard, type manually :
+     $ rm -rf $CCCWORKDIR/trusting/configuration
+     $ rm -rf $CCCWORKDIR/../../dods/public/${LOGNAME}/trusting/configuration
+   - Output will be saved at :
+     $ ls $CCCSTOREDIR/IGCM_OUT
+
