File: generate-cubes.sh

package info (click to toggle)
cadical 2.1.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,224 kB
  • sloc: cpp: 36,901; ansic: 4,521; sh: 1,770; makefile: 91
file content (37 lines) | stat: -rwxr-xr-x 684 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
usage () {
cat <<EOF 2>&1
usage: generate-cubes.sh [-h] <input> [ <output> [ <march_cu option> ... ] ]
EOF
exit 0
}
[ "$1" = -h ] && usage
die () {
  echo "generate-cubes.sh: error: $*" 1>&2
  exit 1
}
[ $# -lt 1 ] && die "expected DIMACS file argument"
output=""
options=""
[ -f "$1" ] || die "first argument is not a DIMACS file"
input="$1"
shift
while [ $# -gt 0 ]
do
  case "$1" in
    -*) options="$options $1";;
    *) exec 1>"$1";;
  esac
  shift
done
prefix=/tmp/generate-cubes-$$
cleanup () {
  rm -f $prefix*
}
trap "cleanup" 2 11
cubes=$prefix.cubes
march_cu $input -o $cubes $options 1>&2 || exit 1
sed -e 's,^p cnf.*,p inccnf,' $input
cat $cubes
cleanup
exit 0