Statistiques
| Branche: | Révision :

meplib / 00model / prepareForPipPL.sh @ master

Historique | Voir | Annoter | Télécharger (3,26 ko)

1
#! /bin/sh
2
#
3
# Prepare data for PIP...
4
# with a user given list in the "pointsList.txt" file 
5
# or in a file given on the command line
6
#
7
CONFIG_FILE=config.txt
8
DIGITS_FILE=digits.txt
9
PREPARE_POINTS_FILE=extractedPointsList.txt
10
INV_FILE=inv.txt
11
W_FILE=w.txt
12
MKLOOPS_FILE=mkloops.txt
13
BOUNDS_FILE=mkloops-bounds.txt
14
BIN_DIR=./bin
15
W_GENERATOR=$BIN_DIR/generate-w-vector-01
16
MKLOOPS_GENERATOR=$BIN_DIR/mkloops-with-w
17
ARGS_FOR_VANDERMONDE=`argsForVandermonde.sh`
18
ARGS_FOR_POINTS_LIST=pointsList.txt
19
MAX_ERROR=`awk '{if(FNR==1) print $2}' < $CONFIG_FILE`
20
CREATE_VANDERMONDE=$BIN_DIR/createVandermonde.pl
21
INV_VANDERMONDE=$BIN_DIR/invVandermonde.pl
22
PRINT_GENERATOR_VECTOR=$BIN_DIR/printGeneratorVector.pl
23
PRINT_POINTS_LIST=cat
24
ADD_BOUNDS_TO_MKLOOPS=$BIN_DIR/addBoundsToMkloops-01.pl
25
COMPUTE_BOUNDS_FOR_MKLOOPS=$BIN_DIR/computeBoundsForMkloops-01.pl
26
CREATE_DIGITS_FILE=createDigitsFile.sh
27
#
28
#
29
# Check out whether a file name is given on the command line
30
# and whether it is a valid file.
31
if [ ! -z "$1" ]
32
  then
33
    if [ -e "$1" -a -s "$1" ]
34
      then
35
        USER_POINTS_LIST_FILE=`basename $1`
36
	if [ $USER_POINTS_LIST_FILE == $PREPARE_POINTS_FILE ]
37
	  then
38
	    echo
39
	    echo
40
	    echo -n `basename $0`": you can't use $PREPARE_POINTS_FILE "
41
	    echo "as your points "
42
	    echo -n "list file. "
43
	    echo "Aborting the program!"
44
	    echo
45
	    echo
46
	    exit 1
47
	fi
48
        ARGS_FOR_POINTS_LIST=$1
49
      else
50
        echo
51
        echo
52
        echo `basename $0`": \"$1\" is not a valid points list file."
53
        echo "Aborting the program!"
54
        echo
55
        echo
56
        exit 1
57
    fi
58
fi
59
#
60
#echo $MAX_ERROR $ARGS_FOR_VANDERMONDE
61
$CREATE_DIGITS_FILE $CONFIG_FILE $DIGITS_FILE
62
if [ $? != 0 ]
63
 then
64
   echo
65
   echo
66
   echo The creation of the digits file failed.
67
   echo Aborting the program!
68
   echo
69
   exit 1
70
fi
71
$CREATE_VANDERMONDE $ARGS_FOR_VANDERMONDE | $INV_VANDERMONDE > $INV_FILE
72
if [ $? != 0 ]
73
 then
74
   echo
75
   echo
76
   echo The creation and the inversion of the Vandermonde matrix failed.
77
   echo Aborting the program!
78
   echo
79
   exit 1
80
fi
81
ARGS=`$PRINT_GENERATOR_VECTOR $ARGS_FOR_VANDERMONDE`
82
if [ $? != 0 ]
83
 then
84
   echo
85
   echo
86
   echo Could not create the generator for the offset vector.
87
   echo Aborting the program!
88
   echo
89
   exit 1
90
fi
91
ARGS="$INV_FILE $DIGITS_FILE $MAX_ERROR $ARGS"
92
$W_GENERATOR $ARGS > $W_FILE
93
if [ $? != 0 ]
94
 then
95
   echo
96
   echo
97
   echo Could not compute the offset vector.
98
   echo Aborting the program!
99
   echo
100
   exit 1
101
fi
102
$PRINT_POINTS_LIST $ARGS_FOR_POINTS_LIST > $PREPARE_POINTS_FILE
103
if [ $? != 0 ]
104
 then
105
   echo
106
   echo
107
   echo Could not get the points list.
108
   echo Aborting the program!
109
   echo
110
   exit 1
111
fi
112
ARGS=`cat $PREPARE_POINTS_FILE`
113
ARGS="$W_FILE $DIGITS_FILE $MAX_ERROR $ARGS"
114
$MKLOOPS_GENERATOR $ARGS > $MKLOOPS_FILE
115
if [ $? != 0 ]
116
 then
117
   echo
118
   echo
119
   echo Could not generate the data for PIP.
120
   echo Aborting the program!
121
   echo
122
   exit 1
123
fi
124
#
125
# For debuging
126
#
127
if [ ! -z $1 ]
128
  then
129
    cat $MKLOOPS_FILE
130
fi
131
$ADD_BOUNDS_TO_MKLOOPS $MKLOOPS_FILE
132
if [ $? != 0 ]
133
 then
134
   echo
135
   echo
136
   echo Could not add the bounds to data for PIP.
137
   echo Aborting the program!
138
   echo
139
   exit 1
140
fi
141
$COMPUTE_BOUNDS_FOR_MKLOOPS $MKLOOPS_FILE
142
if [ $? != 0 ]
143
  then
144
    echo
145
    echo
146
    echo Could not compute valid loops.
147
    echo Aborting the program!
148
    echo
149
    cat $BOUNDS_FILE
150
    exit 1
151
fi