Index: trunk/tools/model_graphics.bash
===================================================================
--- trunk/tools/model_graphics.bash	(revision 974)
+++ trunk/tools/model_graphics.bash	(revision 975)
@@ -1057,6 +1057,4 @@
   fname='compute_combos'
 
-  set -x
-
   Iwdir=$1
   Owdir=$2
@@ -1108,4 +1106,114 @@
 
   return
+}
+
+function createlist_plots(){
+# Function to create the list of plots to draw
+#   Drawplots= ':' separated list of plots to draw
+#   KindPlots= ':' list of plots to draw this time
+
+  fname='createlist_plots'
+
+  Drawplots=$1
+  KindPlots=$2
+
+  drwplts=`echo ${Drawplots} | tr ':' ' '`
+  ikp=1
+  plots=''
+  for drw in ${drwplts}; do
+    if $(isInlist ${KindPlots} ${drw}); then
+      case ${drw} in
+        'map2Dsfc')
+          plts=${pltmap2Dsfc}
+        ;;
+        'map3D')
+          plts=${pltmap3D}
+        ;;
+        'shadcont2Dsfc')
+          plts=${pltshadcont2Dsfc}
+        ;;
+        'shadconthovmsfc')
+          plts=${pltshadconthovmsfc}
+        ;;
+        'shadcont2Dzsec')
+          plts=${pltshadcont2Dzsec}
+        ;;
+        *)
+          echo ${errmsg}
+          echo "  "${main}": plot kind '"${drw}"' not ready !!"
+          exit
+      esac
+      # Do we have plots for this kind?
+      Lkplots=`expr length ${plts}'0'`
+      if test ${Lkplots} -lt 2; then
+        ferrmsg 1 ${main} "plot!kind!"${drw}"!without!variables"
+      fi
+      kplots=`list_add_label ${plts} ${drw} + beg`
+      if test ${ikp} -eq 1; then
+        plots=${kplots}
+      else
+        plots=${plots}':'${kplots}
+      fi
+      ikp=`expr ${ikp} + 1`
+    fi
+# End of coincident direct plots
+  done
+
+  echo ${fname}" listplots= "${plots}_${ikp}
+}
+
+function createlist_diffplots(){
+# Function to create the list of diff plots to draw
+#   Drawplots= ':' separated list of plots to draw
+#   KindPlots= ':' list of plots to draw this time
+
+  fname='createlist_diffplots'
+
+  Drawplots=$1
+  KindPlots=$2
+
+  drwplts=`echo ${Drawplots} | tr ':' ' '`
+  ikp=1
+  plots=''
+  for drw in ${drwplts}; do
+    if $(isInlist ${KindPlots} ${drw}); then
+      case ${drw} in
+        'map2Dsfc')
+          plts=${pltdiffmap2Dsfc}
+        ;;
+        'map3D')
+          plts=${pltdiffmap3D}
+        ;;
+        'shadcont2Dsfc')
+          plts=${pltdiffshadcont2Dsfc}
+        ;;
+        'shadconthovmsfc')
+          plts=${pltdiffshadconthovmsfc}
+        ;;
+        'shadcont2Dzsec')
+          plts=${pltdiffshadcont2Dzsec}
+        ;;
+        *)
+          echo ${errmsg}
+          echo "  "${main}": plot kind '"${drw}"' not ready !!"
+          exit
+      esac
+      # Do we have plots for this kind?
+      Lkplots=`expr length ${plts}'0'`
+      if test ${Lkplots} -lt 2; then
+        ferrmsg 1 ${main} "plot!kind!"${drw}"!without!variables"
+      fi
+      kplots=`list_add_label ${plts} ${drw} + beg`
+      if test ${ikp} -eq 1; then
+        plots=${kplots}
+      else
+        plots=${plots}':'${kplots}
+      fi
+      ikp=`expr ${ikp} + 1`
+    fi
+# End of coincident direct plots
+  done
+
+  echo ${fname}" listplots= "${plots}_${ikp}
 }
 
@@ -1615,5 +1723,5 @@
 files: ${files}
 varcompute: ${varcompute}
-itotv: $itotv}
+itotv: ${itotv}
 testfs: ${testfiles}
 combo: ${combo}
@@ -1626,5 +1734,5 @@
       itotv=`cat ${owdir}/varcompute.inf | grep itotv | awk '{print $2}'`
       testfiles=`cat ${owdir}/varcompute.inf | grep testfs | awk '{print $2}'`
-      combo=`cat ${owdir}/varcompute.inf | grep combo | awk '{print $2}'`
+      combo=`cat ${owdir}/varcompute.inf | grep 'combo:' | awk '{print $2}'`
 # End of avoiding to repeat all the experiment search
     fi
@@ -1639,11 +1747,9 @@
 
     # Computing combos
-    if ${combo}; then
+    if test ${combo}; then
       echo "      Computing combos: "${varcombo}
       compute_combos ${iwdir} ${owdir} ${files} ${testfiles} ${moddims} ${modvdims}  \
         ${varcombo} ${filescratch}
     fi
-
-    exit
 
     echo "  "${main}": "${ic}" variables has been computed"
@@ -1657,45 +1763,9 @@
 
     if test ! -f directplotsdraw.inf; then
-      drwplts=`echo ${drawplots} | tr ':' ' '`
-      ikp=1
-      plots=''
-      for drw in ${drwplts}; do
-        if $(isInlist ${directplots} ${drw}); then
-          case ${drw} in
-            'map2Dsfc')
-              plts=${pltmap2Dsfc}
-            ;;
-            'map3D')
-              plts=${pltmap3D}
-            ;;
-            'shadcont2Dsfc')
-              plts=${pltshadcont2Dsfc}
-            ;;
-            'shadconthovmsfc')
-              plts=${pltshadconthovmsfc}
-            ;;
-            'shadcont2Dzsec')
-              plts=${pltshadcont2Dzsec}
-            ;;
-            *)
-              echo ${errmsg}
-              echo "  "${main}": plot kind '"${drw}"' not ready !!"
-              exit
-          esac
-          # Do we have plots for this kind?
-          Lkplots=`expr length ${plts}'0'`
-          if test ${Lkplots} -lt 2; then
-            ferrmsg 1 ${main} "plot!kind!"${drw}"!without!variables"
-          fi
-          kplots=`list_add_label ${plts} ${drw} + beg`
-          if test ${ikp} -eq 1; then
-            plots=${kplots}
-          else
-            plots=${plots}':'${kplots}
-          fi
-          ikp=`expr ${ikp} + 1`
-        fi
-# End of coincident direct plots
-      done
+      listplots=`createlist_plots ${drawplots} ${directplots} | grep listplots | awk '{print $3}'`
+
+      plots=`echo ${listplots} | tr '_' ' ' | awk '{print $1}'`
+      ikp=`echo ${listplots} | tr '_' ' ' | awk '{print $2}'`
+
       cat << EOF > directplotsdraw.inf
 Nkinds= ${ikp}
@@ -1722,5 +1792,5 @@
     done
 
-    echo "  "${main}": "${idp}" direct plots hav been computed"
+    echo "  "${main}": "${idp}" direct plots have been computed"
     cd ${rootsh}
 
@@ -1728,40 +1798,28 @@
   done
 
+### ## #
 # Experiment differences
-## 
+## # ## #
+
   diffexperiments=`list_pairs $(echo ${exps} | tr ' ' ':') | grep -v newlists | awk '{print $3}'`
   diffexps=`echo ${diffexperiments} | tr ':' ' '`
 
-  set -x
-
-  vdiffs=`echo ${vardiff} | tr ':' ' '`
-  ivd=1
-  for vdiff in ${vdiffs}; do
-    echo ${vdiff}" ..."
-    if test $(expr index ${vdiff} '|') -ne -1; then
-      vn=`echo ${vdiff} | tr '|' ' ' | awk '{print $1}'`
-      ops=`echo ${vdiff} | tr '|' ' ' | awk '{print $2}'`
-    else
-      vn=`echo ${vdiff} | tr '|' ' ' | awk '{print $1}'`
-      ops='None'
-    fi  
-    fileh=`echo ${varcompute} | tr ';' '\n' | grep ${vdiff} | tr '|' ' ' | awk '{print $3}'`
-
-    filen=`stats_filename ${vn} ${ops} ${fileh}`
-    opss=`echo ${ops} | tr '@' ' '`
-    for op in ${opss}; do
-      # Adding 'surnames' to the variable's name
-      if test ${op} = 'turb'; then
-        vn=${vn}'turb'
-      fi
-      if $(isInlist ${varmeanname} ${op}); then
-        vn=${vn}'mean'
-      fi
-    done
-
-    for diffexp in ${diffexps}; do
-      echo "  "${diffexp}
-      difexp1=`echo ${diffexp} | tr '|' ' ' | awk '{print $1}'`
-      difexp2=`echo ${diffexp} | tr '|' ' ' | awk '{print $2}'`
+  for diffexp in ${diffexps}; do
+    echo "  "${diffexp}
+    difexp1=`echo ${diffexp} | tr '|' ' ' | awk '{print $1}'`
+    difexp2=`echo ${diffexp} | tr '|' ' ' | awk '{print $2}'`
+
+    vdiffs=`echo ${vardiff} | tr ':' ' '`
+    ivd=1
+    for vdiff in ${vdiffs}; do
+      echo ${vdiff}" ..."
+      if test $(expr index ${vdiff} '|') -ne -1; then
+        vn=`echo ${vdiff} | tr '|' ' ' | awk '{print $1}'`
+        ops=`echo ${vdiff} | tr '|' ' ' | awk '{print $2}'`
+      else
+        vn=`echo ${vdiff} | tr '|' ' ' | awk '{print $1}'`
+        ops='None'
+      fi  
+      fileh=`echo ${varcompute} | tr ';' '\n' | grep ${vdiff} | tr '|' ' ' | awk '{print $3}'`
 
       owdir=${ofold}/${mod}/${difexp1}-${difexp2}
@@ -1769,4 +1827,6 @@
         mkdir -p ${owdir}
       fi
+
+      filen=${vn}_${fileh}.nc
 
       if ${filescratch}; then rm ${owdir}/${filen} >& /dev/null; fi
@@ -1786,11 +1846,82 @@
       fi
 
-    # end experiment pairs
+      echo "      Computing diff statistics ..."
+
+      cfdims='lon:lat:pres:time'
+      cfvdims='lon:lat:pres:time'
+      cdiffvn=`echo ${filen} | tr '_' ' ' | awk '{print $1}'`
+      cdiffh=`echo ${filen} | tr '_' ' ' | awk '{print $2}' | tr '.' ' ' | awk '{print $1}'`
+
+      cdiffvar=${cdiffvn}'|'${ops}'|'${cdiffh}'|None|None'
+
+      compute_statistics ${owdir} ${filen} ${owdir} ${cdiffvar} ${cfdims} ${cfvdims} \
+        ${filescratch}
+
+      # Computing combos
+      if test $(expr index ${ops} '@') -ne -1; then
+        echo "      Computing combos: "${ops}
+        combs=`echo ${ops} | tr ';' ' ' | awk '{print $2}' | tr '@' ' '`
+        ifile=${cdiffvn}_${fhead}
+        for comb in ${combs}; do
+          combcvar=${cdiffvn}'|'${comb}'|'${cdiffh}'|None|None'
+          compute_statistics ${owdir} ${ifile}.nc ${owdir} ${combcvar} ${cfdims}     \
+            ${cfvdims} ${filescratch} ${ifile}.nc
+          ifile=${ifile}_${comb}
+
+          # Adding 'surnames' to the variable's name
+          if test ${comb} = 'turb'; then
+            cdiffvn=${cdiffvn}'turb'
+          fi
+          if $(isInlist ${varmeanname} ${comb}); then
+            cdiffvn=${cdiffvn}'mean'
+          fi
+
+        # End of combo 
+        done
+      fi
+      ivd=`expr ${ivd} + 1`
+    # end of variable diff
     done
+
+# Diff plotting
+##
+    set -x
+
+    echo "  "${main}": Plotting diff figures ..."
+    if ${figscratch}; then rm diffplotsdraw.inf; fi
+    if ${addfigures}; then rm diffplotsdraw.inf; fi
+
+    if test ! -f diffplotsdraw.inf; then
+      listplots=`createlist_diffplots ${drawdiffplots} ${directplots} |              \
+        grep listplots | awk '{print $3}'`
+
+      plots=`echo ${listplots} | tr '_' ' ' | awk '{print $1}'`
+      ikp=`echo ${listplots} | tr '_' ' ' | awk '{print $2}'`
+
+      cat << EOF > diffplotsdraw.inf
+Nkinds= ${ikp}
+plots= ${plots}
+EOF
+    else
+      echo ${warnmsg}
+      echo "  "${main}": retrieving direct plots from existing file 'diffplotsdraw.inf' !!"
+      Nkinds=`cat diffplotsdraw.inf | grep Nkinds | awk '{print $2}'`
+      plots=`cat diffplotsdraw.inf | grep plots | awk '{print $2}'`
+    fi
+
+    pts=`echo ${plots} | tr ':' ' '`
+    idp=1
+    for pt in ${pts}; do
+      echo "        "${pt}
+      draw_plot ${pt} ${owdir} ${fileh} ${figscratch}
+      idp=`expr ${idp} + 1`
+    done
+
+    echo "  "${main}": "${idp}" diff plots have been computed"
+    cd ${rootsh}
+
+  # end experiment pairs
+  done
 # LLUIS
-
-    ivd=`expr ${ivd} + 1`
-  # end of variable diff
-  done
 
   exit
Index: trunk/tools/model_graphics_template.dat
===================================================================
--- trunk/tools/model_graphics_template.dat	(revision 974)
+++ trunk/tools/model_graphics_template.dat	(revision 975)
@@ -93,6 +93,7 @@
 varxmean = tas:uas:vas:hfss:hfls:wss
 varpinterp = ta:ua:va:hur:ws:hus
-vardiff = tas|last:tas|xmean:tas|tmean
 varcombo = ta;pinterp@last@xmean:ua;pinterp@last@xmean:va;pinterp@last@xmean:hur;pinterp@last@xmean:ws;pinterp@turb@xmean:hus;pinterp@turb@xmean
+
+vardiff = tas|last:tas|xmean:tas|tmean:wss|last:wss|xmean:wss|tmean
 
 # Operations which attach 'mean' at the end of the variable name
@@ -118,4 +119,5 @@
 #drawplots = shadcont2Dsfc:shadconthovmsfc:sahdcont2Dzsec
 drawplots = shadcont2Dzsec
+drawdiffplots = shadcont2Dsfc
 
 # Figures which can be made directly without another model/experiment output
@@ -126,5 +128,5 @@
 pltshadcont2Dzsec=ua|pinterp@last@xmean#va|pinterp@last@xmean:hur|pinterp@last@xmean#ta|pinterp@last@xmean:ws|pinterp@turb@xmean#hus|pinterp@turb@xmean
 
-pltdiffmap2Dz = uapxmean:vapxmean:tapxmean:huspxmean
+pltdiffshadcont2Dsfc = tas|xmean#wss|xmean:tas|tmean#wss|tmean:tas|last#wss|last
 
 # Specific variable-statistisc graphic parameters (if no value is given, they will be retrieved from 'variables_values.dat')
