]> AND Private Git Repository - loba.git/blobdiff - Experimentations/run-all
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Add option to compress output files in run-all.
[loba.git] / Experimentations / run-all
index 9453bc3884f1c867787b48e756028a7fa68cd5d9..9d4354292b0c7fab232ef51bae877ea7f873d6b2 100755 (executable)
@@ -5,11 +5,12 @@ set -e
 
 usage() {
     cat >&2 <<EOF
 
 usage() {
     cat >&2 <<EOF
-Usage: $0 [-c] <parameters file>
+Usage: $0 [OPTION] <parameters file>
 Options:
     -h  print this help
     -n  dry-run mode (for debugging)
     -c  (continue) do not overwrite previous results
 Options:
     -h  print this help
     -n  dry-run mode (for debugging)
     -c  (continue) do not overwrite previous results
+    -z  compress output files with gzip
 EOF
     exit $1
 }
 EOF
     exit $1
 }
@@ -34,11 +35,13 @@ array_check() {
 # read args
 overwrite=1
 debug=0
 # read args
 overwrite=1
 debug=0
-while getopts "chn" c; do
+compress=0
+while getopts "chnz" c; do
     case "$c" in
         'c') overwrite=0 ;;
         'h') usage 0 ;;
         'n') debug=1 ;;
     case "$c" in
         'c') overwrite=0 ;;
         'h') usage 0 ;;
         'n') debug=1 ;;
+        'z') compress=1 ;;
         '?') usage 1 ;;
     esac
 done
         '?') usage 1 ;;
     esac
 done
@@ -49,7 +52,7 @@ parameters="$1"
 log "Running: $0 $@"
 log "Hostname: $(hostname -f)"
 
 log "Running: $0 $@"
 log "Hostname: $(hostname -f)"
 
-declare -a TOPOLOGIES ALGORITHMS PLATFORMS COMMON_OPTS
+declare -a TOPOLOGIES ALGORITHMS PLATFORMS COMMON_OPTS MORE_ARGS
 
 # read parameters
 log "Reading parameters from \"$1\"."
 
 # read parameters
 log "Reading parameters from \"$1\"."
@@ -68,6 +71,7 @@ variable_check DEADLINE
 
 COMMON_OPTS=(
     --cfg=contexts/factory:raw
 
 COMMON_OPTS=(
     --cfg=contexts/factory:raw
+    "${MORE_ARGS[@]}"
 )
 
 log "Results put in: \"$RESULTS\"."
 )
 
 log "Results put in: \"$RESULTS\"."
@@ -78,6 +82,19 @@ outfile() {
     echo "$*" | sed 's,[^ ]*/,,g;s/\.xml//;y/ /_/'
 }
 
     echo "$*" | sed 's,[^ ]*/,,g;s/\.xml//;y/ /_/'
 }
 
+summary() {
+    gzip -cdf "$@" \
+    | sed -n '\!^\[main/INFO\] ,----\[ Results \]!,${
+        /send\|recv\|wall clock\|Simulation succeeded/d;p;
+      }'
+}
+
+if [ $compress = 1 ]; then
+    outsuffix=".gz"
+else
+    outsuffix=""
+fi
+
 for plat in "${PLATFORMS[@]}"; do
     tmp=$(basename "$plat" ".xml")
     plat_output="$RESULTS/plat_$tmp"
 for plat in "${PLATFORMS[@]}"; do
     tmp=$(basename "$plat" ".xml")
     plat_output="$RESULTS/plat_$tmp"
@@ -97,19 +114,28 @@ for plat in "${PLATFORMS[@]}"; do
             for bk in "" "-b"; do
                 tmp=$(outfile "loba" $bk "${args[@]}")
                 out="$algo_output/$tmp.out"
             for bk in "" "-b"; do
                 tmp=$(outfile "loba" $bk "${args[@]}")
                 out="$algo_output/$tmp.out"
+                outf="$out$outsuffix"
                 cmd=( "$LOBA" "${COMMON_OPTS[@]}" $bk "${args[@]}" )
                 cmd=( "$LOBA" "${COMMON_OPTS[@]}" $bk "${args[@]}" )
-                log "Run: ${cmd[@]}"$'\n'"... &> $out"
-                if [ $overwrite = 0 -a -e "$out" ]; then
+                log "Run: ${cmd[@]}"$'\n'"... &> $outf"
+                if [ $overwrite = 0 -a -e "$outf" ]; then
                     log "already run !"
                     log "already run !"
-                    tail -n4 "$out"
+                    summary "$outf"
                     continue
                 fi
                 if [ $debug = 1 ]; then
                     log "skipped (dry-run)"
                     continue
                 fi
                 if [ $debug = 1 ]; then
                     log "skipped (dry-run)"
+                    continue
+                fi
+                rm -f "$outf";
+                echo "# ${cmd[@]}" > "$out"
+                if "${cmd[@]}" >> "$out" 2>&1; then
+                    summary "$out"
                 else
                 else
-                    echo "# ${cmd[@]}" > "$out"
-                    "${cmd[@]}" > "$out" 2>&1
-                    tail -n4 "$out"
+                    grep -v '/INFO\]' "$out"
+                fi
+                if [ $compress = 1 ]; then
+                    log "Compress output file."
+                    gzip --best "$out"
                 fi
             done
         done
                 fi
             done
         done