forked from zerothi/fdict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·108 lines (100 loc) · 2.47 KB
/
setup.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# Ensure that we get the default var_N by
# first deleting any previous settings
rm -f current_settings.sh
source settings.sh
function quick_setup {
local n=$1 ; shift
while [ $# -gt 0 ]; do
if [ $(var_N $1) -ne $n ]; then
echo "Updating number of dimensions for: $(var_name $1) to $n"
echo "# Updating number of dimensions for: $(var_name $1) to $n" >> current_settings.sh
fi
echo "$1) _ps $n ;;" >> current_settings.sh
shift
done
}
function _help {
echo "Helper routine for compilation setup"
echo " Call by:"
echo " $0 <options>"
echo ""
echo " Several options are allowed to control how many dimensions that will"
echo " be accesible in type(var) and type(dict)."
echo " currently you cannot ask for more than 7 dimensions without"
echo " changing this file and settings.inc"
echo ""
echo " The following options control how the dimensions are allocated:"
for v in -s -d -c -z -b -h -i -l ; do
echo " $v <num> : allows 0-<num> dimensions of $(var_name ${v:1})"
done
echo " -A <num> : short for all the above options simultaneously"
echo " -R <num> : short for -s <num> -d <num>"
echo " -C <num> : short for -c <num> -z <num>"
echo " -I <num> : short for -h <num> -i <num> -l <num>"
echo " The above options can be combined with the last option taking precedence."
echo ""
echo "Example"
echo " Allowing all variables to have 2 dimensions but the"
echo " double precision reals to have 3 can be done with:"
echo " $0 -A 2 -d 3"
echo ""
}
[ $# -eq 0 ] && _help && exit
{
echo "function var_N {"
echo "local var=\"\$1\""
echo "case \$var in"
} > current_settings.sh
while [ $# -gt 0 ]; do
opt=$1 ; shift
case $opt in
--*)
opt=${opt:1} ;;
-*)
;;
*)
echo "Error, could not recognize option"
_help ; exit
;;
esac
case $opt in
-h)
if [ $# -eq 0 ]; then
# This will capture if only -h is supplied
_help
exit
fi
n=${opt:1}
quick_setup $1 $n
shift ;;
-s|-d|-c|-z|-b|-i|-l)
n=${opt:1}
quick_setup $1 $n
shift ;;
-A)
quick_setup $1 s d c z b h i l
shift ;;
-R)
quick_setup $1 s d
shift ;;
-C)
quick_setup $1 c z
shift ;;
-I)
quick_setup $1 h i l
shift ;;
-help)
_help ; exit ;;
*)
;;
esac
done
# In a
for v in VAR V a s d c z b h i l ; do
quick_setup $(var_N $v) $v
done
{
echo "esac"
echo "}"
} >> current_settings.sh