Index: trunk/tools/model_graphics.bash
===================================================================
--- trunk/tools/model_graphics.bash	(revision 971)
+++ trunk/tools/model_graphics.bash	(revision 972)
@@ -345,4 +345,122 @@
 
   echo "varcomp= "${varcomp}
+}
+
+function compvars_listconstruct() {
+# Function to construct the list of variables to compute
+#   VarKinds= ':' separated list of kind variables to compute
+#   TestFiles= ':' list of files to test how to compute the variable
+##
+  fname='compvars_listconstruct'
+
+  VarKinds=$1
+  TestFiles=$2
+
+  varks=`echo ${VarKinds} | tr ':' ' '`
+
+  combo=false
+  ik=1
+  itotv=1
+  for vark in ${varks}; do
+    if test ! ${vark} = 'diff'; then
+      echo "    "${vark}" ..."
+      case ${vark} in
+        'acc')
+          varvks=${varacc}
+        ;;
+        'combo')
+          combo=true
+          varvcombo=${varcombo}
+          varcos=`echo ${varvcombo} | tr ':' ' '`
+          varvks=''
+          ivco=1
+          for vco in ${varcos}; do
+            vn=`echo ${vco} | tr '@' ' ' | awk '{print $1}'`
+            if test ${ivco} -eq 1; then
+              varvks=${vco}
+            else
+              varvks=${varvks}':'${vco}
+            fi
+            ivco=`expr ${ivco} + 1`
+          done
+        ;;
+        'direct')
+          varvks=${vardirect}
+        ;;
+        'last')
+          varvks=${varlast}
+        ;;
+        'Lmean')
+          varvks=${varLmean}
+        ;;
+        'Lsec')
+          varvks=${varLsec}
+        ;;
+        'lmean')
+          varvks=${varlmean}
+        ;;
+        'lsec')
+          varvks=${varlsec}
+        ;;
+        'pinterp')
+          varvks=${varpinterp}
+        ;;
+        'tmean')
+          varvks=${vartmean}
+        ;;
+        'xmean')
+          varvks=${varxmean}
+        ;;
+        'ymean')
+          varvks=${varymean}
+        ;;
+        'zsum')
+          varvks=${varzsum}
+        ;;
+        '*')
+          echo ${errmsg}
+          echo "  "${main}": variable kind '"${vark}"' not ready!!"
+          exit
+        ;;
+      esac
+
+# Do we have variables for this kind?
+      Lvarvks=`expr length ${varvks}'0'`
+      if test ${Lvarvks} -lt 2; then
+        ferrmsg 1 ${main} "variable!kind!"${vark}"!without!variables"
+      fi
+      if test ${ik} -eq 1; then
+        allvars=${varvks}
+      else
+        allvars=${allvars}':'${varvks}
+      fi
+      ik=`expr ${ik} + 1`
+      vars=`echo ${varvks} | tr ':' ' '`
+
+# Variables loop
+##
+      iv=1
+      for var in ${vars}; do
+        echo "      "${var}
+        # How to compute it?
+        varcomp=`variable_compute ${iwdir} ${var} ${TestFiles} | grep varcomp |  \
+          awk '{print $2}'`
+  
+        if test ${itotv} -eq 1; then
+          varcompute=${varcomp}
+        else
+          varcompute=${varcompute}';'${varcomp}
+        fi
+
+        iv=`expr ${iv} + 1`
+        itotv=`expr ${itotv} + 1`
+
+# end loop of variables
+      done
+    fi
+# end of kind of variables
+  done
+
+  echo ${fname}" varcompute= "${varcompute}_${itotv}
 }
 
@@ -1357,116 +1475,16 @@
       cd ${rootsh}
 
-# Kind variables loop
-##
-      combo=false
-      ik=1
-      itotv=1
-      for vark in ${varks}; do
-        if test ! ${vark} = 'diff'; then
-          echo "    "${vark}" ..."
-          case ${vark} in
-            'acc')
-              varvks=${varacc}
-            ;;
-            'combo')
-              combo=true
-              varvcombo=${varcombo}
-              varcos=`echo ${varvcombo} | tr ':' ' '`
-              varvks=''
-              ivco=1
-              for vco in ${varcos}; do
-                vn=`echo ${vco} | tr '@' ' ' | awk '{print $1}'`
-                if test ${ivco} -eq 1; then
-                  varvks=${vco}
-                else
-                  varvks=${varvks}':'${vco}
-                fi
-                ivco=`expr ${ivco} + 1`
-              done
-            ;;
-            'direct')
-              varvks=${vardirect}
-            ;;
-            'last')
-              varvks=${varlast}
-            ;;
-            'Lmean')
-              varvks=${varLmean}
-            ;;
-            'Lsec')
-              varvks=${varLsec}
-            ;;
-            'lmean')
-              varvks=${varlmean}
-            ;;
-            'lsec')
-              varvks=${varlsec}
-            ;;
-            'pinterp')
-              varvks=${varpinterp}
-            ;;
-            'tmean')
-              varvks=${vartmean}
-            ;;
-            'xmean')
-              varvks=${varxmean}
-            ;;
-            'ymean')
-              varvks=${varymean}
-            ;;
-            'zsum')
-              varvks=${varzsum}
-            ;;
-            '*')
-              echo ${errmsg}
-              echo "  "${main}": variable kind '"${vark}"' not ready!!"
-              exit
-            ;;
-          esac
-
-# Do we have variables for this kind?
-          Lvarvks=`expr length ${varvks}'0'`
-          if test ${Lvarvks} -lt 2; then
-            ferrmsg 1 ${main} "variable!kind!"${vark}"!without!variables"
-          fi
-          if test ${ik} -eq 1; then
-            allvars=${varvks}
-          else
-            allvars=${allvars}':'${varvks}
-          fi
-          ik=`expr ${ik} + 1`
-          vars=`echo ${varvks} | tr ':' ' '`
-
-# Variables loop
-##
-          iv=1
-          for var in ${vars}; do
-            echo "      "${var}
-            # How to compute it?
-            varcomp=`variable_compute ${iwdir} ${var} ${testfiles} | grep varcomp |  \
-              awk '{print $2}'`
-  
-            if test ${itotv} -eq 1; then
-              varcompute=${varcomp}
-            else
-              varcompute=${varcompute}';'${varcomp}
-            fi
-
-            iv=`expr ${iv} + 1`
-            itotv=`expr ${itotv} + 1`
-
-# end loop of variables
-          done
-        fi
-# end of kind of variables
-      done
+      varcompute=`compvars_listconstruct ${varkinds} $(echo ${testfiles} | tr '@' ':')\
+       | grep varcompute | awk '{print $3}'`
 
       # Outwritting the varcompute to avoid next time (if it is not filescratch!)
       cat << EOF > ${owdir}/varcompute.inf
 files: ${files}
-varcompute: ${varcompute}
-itotv: ${itotv}
+varcompute: $(echo ${varcompute} | tr '_' ' ' | awk '{print $1}')
+itotv: $(echo ${varcompute} | tr '_' ' ' | awk '{print $2}')
 testfs: ${testfiles}
 EOF
+
+      exit
     else
       echo $warnmsg
