Debian Codegraph @

bin/mkthreadsafe

raw
1 #!/usr/bin/env bash
2
3 if test $# = 0 ; then
4 files="`ls *.mod`"
5 else
6 files="$*"
7 fi
8 echo $files
9
10 t=temp
11 words="EXTERNAL discontinuity LINEAR DISCRETE PARTIAL ERROR"
12
13 for i in $files ; do
14
15 f="`echo $i | sed 's/\.mod//'`"
16 nocmodl $f.mod 2>&1 | sed '/^Translating/d' > $t
17 nline=`wc -l $t`
18 rm $f.c
19 thread_safe=""
20 for word in $words ; do
21 if grep -q "$word"' is not thread safe' $t ; then
22 thread_safe=no
23 fi
24 done
25 if grep -q 'Complain to hines' $t ; then
26 thread_safe=no
27 fi
28
29 echo "
30 $f.mod:"
31 if test "$nline" = "0 temp" ; then
32 echo "$f.mod is Thread Safe"
33 elif grep -q '^Thread Safe$' $t ; then
34 echo "$f.mod is Thread Safe"
35 elif test "$thread_safe" = "no" ; then
36 cat $t
37 echo -n "Continue:"
38 read a
39 elif grep -q 'POINTER is not thread safe' $t ; then
40 cat $t
41 echo "$f.mod should be examined and if, in fact, it is
42 or can be modified to be thread safe, the THREADSAFE keyword can be
43 prepended to the NEURON block."
44 echo -n "Continue:"
45 read a
46 elif grep -q 'Assignment to the GLOBAL' $t ; then
47 sed -n '/NEURON *{/,/}/p' $f.mod
48 sed -n '/VERBATIM/,/ENDVERBATIM/p' $f.mod
49 cat $t
50 a="n"
51 echo "If you know that this model is in fact thread safe when
52 the GLOBAL variables that are written to are promoted to thread instance
53 variables, and therefore it is ok to add the THREADSAFE keyword, then ..."
54 echo "Add THREADSAFE? [y][n]: $a"
55 read a
56 if test "$a" = "y" ; then
57 sed '/NEURON *{/a \
58 THREADSAFE
59 ' $f.mod > $t
60 cp $t $f.mod
61 fi
62 elif grep -q 'VERBATIM' $t ; then
63 sed -n '/VERBATIM/,/ENDVERBATIM/p' $f.mod
64 cat $t
65 a="n"
66 echo "If you know that this model is in fact thread safe so
67 that it is ok to add the THREADSAFE keyword, then ..."
68 echo "Add THREADSAFE? [y][n]: $a"
69 read a
70 if test "$a" = "y" ; then
71 sed '/NEURON *{/a \
72 THREADSAFE
73 ' $f.mod > $t
74 cp $t $f.mod
75 fi
76 else
77 cat $t
78 echo -n "Continue:"
79 read a
80 fi
81 rm $t
82 done