Basilisk source code (http://basilisk.fr/src/)

root / src / sequence

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
#!/bin/bash

gfvpair() {
    if awk -v t=$1 '
    BEGIN { ts = -1; ss = ""; } {
      for (i = 1; i <= NF; i++) {
        te = $i*1.; se = $i;
        if (ts >= 0 && t >= ts && t <= te)
          break;
        ts = te; ss = se;
      }
      if (ss == "" || ts == te)
        exit (1);
      print ss,se;
    }'; then
	return 0;
    fi
    return 1;
}

gfv() {
    t=$1
    shift
    files=""
    while test $# -gt 0; do
	files="$files $1"
	shift
    done
    if ! pair=`echo $files | gfvpair $t`; then
	return 1
    fi

    echo Clear
    start=`echo $pair | awk '{print $1}'`
    end=`echo $pair | awk '{print $2}'`
    ts=`echo $pair | awk '{print substr($1,0,index($1,":")-1)}'`
    te=`echo $pair | awk '{print substr($2,0,index($2,":")-1)}'`
    txs=`grep 'tx =' $start | awk '{print $3}'`
    tys=`grep 'tx =' $start | awk '{print $6}'`
    fovs=`grep 'fov =' $start | awk '{print $3}'`
    txe=`grep 'tx =' $end | awk '{print $3}'`
    tye=`grep 'tx =' $end | awk '{print $6}'`
    fove=`grep 'fov =' $end | awk '{print $3}'`
    awk -v txs=$txs -v tys=$tys -v txe=$txe -v tye=$tye \
	-v fovs=$fovs -v fove=$fove \
	-v t=$t -v ts=$ts -v te=$te '{
      if (te > ts)
        a = (t - ts)*1./(te - ts);
      else
        a = 0.;
      if ($1 == "tx")
        print "  tx = " txs + (txe - txs)*a " ty = " tys + (tye - tys)*a; 
      else if ($1 == "fov")
        print "  fov = " fovs + (fove - fovs)*a;
      else 
        print $0;
    }' < $start
}

gfs=""
gfv=""
command=""
while test $# -gt 0; do
    case "$1" in
	*.gfv) gfv="$gfv $1" ;;
	*.gfs) gfs="$gfs $1" ;;
	*) command="$command $1" ;;
    esac
    shift
done

for f in $gfs; do
    t=`grep -a "Time { t = " $f | awk '{print $5}'`
    if gfv $t $gfv; then
	gerris3D -e "Init { istep = 1 } { f = (f < 1e-3 ? 0 : f > 1. - 1e-3 ? 1. : f) }" $f
	echo $command
    fi
done