1 |
#!/bin/bash |
#!/bin/bash |
2 |
|
|
3 |
echo -n "Would you like to use default settings? (y/n): " |
mkdir -p .darwinview |
|
read yn |
|
4 |
|
|
5 |
if echo $yn | grep -q n |
echo -n "What format is the data in? (binary/netcdf): " |
6 |
then |
read nb |
7 |
|
|
8 |
rm .darwinview/filenames |
if [ $nb = 'binary' ]; then |
9 |
|
|
10 |
echo -n "Please enter screen resolution: " |
echo -n "Would you like to use default settings? (y/n): " |
11 |
read win |
read yn |
12 |
echo $win > .darwinview/config |
|
13 |
echo -n "Please enter dimensions of data: " |
if [ $yn = 'n' ]; then |
14 |
read dim |
|
15 |
echo $dim >> .darwinview/config |
rm -f .darwinview/binfilenames |
16 |
echo -n "Please enter dimensions of data sets: " |
rm -f .darwinview/*.datbin |
17 |
read dimset |
|
18 |
echo $dimset >> .darwinview/config |
xrandr | grep '*' | awk -F' ' '{print $1}' > .darwinview/binconfig |
19 |
echo .darwinview/filenames >> .darwinview/config |
echo -n "Please enter dimensions of data: " |
20 |
echo -n "Please enter directory containing data: " |
read dim |
21 |
read dir |
echo $dim >> .darwinview/binconfig |
22 |
|
echo -n "Please enter dimensions of data sets: " |
23 |
name="start" |
read dimset |
24 |
|
echo $dimset >> .darwinview/binconfig |
25 |
while [ $name != 'q' ] |
echo .darwinview/binfilenames >> .darwinview/binconfig |
26 |
do |
|
27 |
echo -n "Please enter name of species: " |
echo -n "Please enter directory containing data: " |
28 |
read name |
read dir |
29 |
if [ $name != 'q' ] |
|
30 |
then |
echo -n "Please enter name of file containing desired species: " |
31 |
echo .darwinview/$name.dat >> .darwinview/filenames |
read fn |
32 |
for i in `ls $dir` |
|
33 |
do |
vn=( `cat $fn` ) |
34 |
touch .darwinview/$name.dat |
|
35 |
echo $dir/$i/`ls $dir/$i | grep $name` >> .darwinview/$name.dat |
for name in ${vn[@]}; do |
36 |
|
touch .darwinview/$name.datbin |
37 |
|
echo .darwinview/$name.datbin >> .darwinview/binfilenames |
38 |
|
for i in `ls $dir`; do |
39 |
|
echo $dir/$i/`ls $dir/$i | grep $name` >> .darwinview/$name.datbin |
40 |
|
done |
41 |
|
done |
42 |
|
|
43 |
|
elif [ `echo $yn | grep -v y` ]; then |
44 |
|
echo "Error: please enter 'y' or 'n.'" |
45 |
|
exit |
46 |
|
fi |
47 |
|
|
48 |
|
elif [ $nb = 'netcdf' ]; then |
49 |
|
|
50 |
|
echo -n "Would you like to use default settings? (y/n): " |
51 |
|
read yn |
52 |
|
|
53 |
|
if [ $yn = 'n' ]; then |
54 |
|
|
55 |
|
rm -f .darwinview/ncfilenames |
56 |
|
rm -f .darwinview/*.datnc |
57 |
|
|
58 |
|
xrandr | grep '*' | awk -F' ' '{print $1}' > .darwinview/ncconfig |
59 |
|
echo -n "Please enter dimensions of data: " |
60 |
|
read dim |
61 |
|
echo $dim >> .darwinview/ncconfig |
62 |
|
echo -n "Please enter dimensions of data sets: " |
63 |
|
read dimset |
64 |
|
echo $dimset >> .darwinview/ncconfig |
65 |
|
echo .darwinview/ncfilenames >> .darwinview/ncconfig |
66 |
|
|
67 |
|
echo -n "Please enter directory containing data: " |
68 |
|
read tmp |
69 |
|
echo $tmp > .darwinview/netcdf |
70 |
|
|
71 |
|
|
72 |
|
echo -n "Please enter directory to write to: " |
73 |
|
read tmp |
74 |
|
echo $tmp >> .darwinview/netcdf |
75 |
|
|
76 |
|
echo -n "Please enter name of file containing desired species: " |
77 |
|
read tmp |
78 |
|
echo $tmp >> .darwinview/netcdf |
79 |
|
|
80 |
|
echo -n "Please enter name of file containing desired tiles: " |
81 |
|
read tmp |
82 |
|
echo $tmp >> .darwinview/netcdf |
83 |
|
|
84 |
|
echo -n "Please enter name of file containing desired time steps: " |
85 |
|
read tmp |
86 |
|
echo $tmp >> .darwinview/netcdf |
87 |
|
|
88 |
|
elif [ `echo $yn | grep -v y` ]; then |
89 |
|
echo "Error: please enter 'y' or 'n.'" |
90 |
|
exit |
91 |
|
fi |
92 |
|
|
93 |
|
indir=( `cat .darwinview/netcdf | head -1` ) |
94 |
|
outdir=( `cat .darwinview/netcdf | head -2 | tail -1` ) |
95 |
|
fn=( `cat .darwinview/netcdf | head -3 | tail -1` ) |
96 |
|
vn=( `cat $fn` ) |
97 |
|
fn=( `cat .darwinview/netcdf | head -4 | tail -1` ) |
98 |
|
tlist=( `cat $fn` ) |
99 |
|
fn=( `cat .darwinview/netcdf | tail -1` ) |
100 |
|
itlist=( `cat $fn` ) |
101 |
|
|
102 |
|
initdir=`pwd` |
103 |
|
gcc netcdf.c -I/usr/include/netcdf-3 -L/usr/lib/netcdf-3 -lnetcdf |
104 |
|
for tstep in ${itlist[@]}; do |
105 |
|
cd $initdir |
106 |
|
cd $outdir |
107 |
|
mkdir -p $tstep |
108 |
|
cd $tstep |
109 |
|
for name in ${vn[@]}; do |
110 |
|
for tile in ${tlist[@]}; do |
111 |
|
$initdir/a.out ~/${indir}/ptr_tave.${tstep}.${tile}.nc $name |
112 |
|
done |
113 |
|
done |
114 |
|
done |
115 |
|
|
116 |
|
cd $initdir |
117 |
|
|
118 |
|
for name in ${vn[@]}; do |
119 |
|
echo $name |
120 |
|
touch .darwinview/$name.datnc |
121 |
|
echo .darwinview/$name.datnc >> .darwinview/ncfilenames |
122 |
|
for i in `ls $outdir`; do |
123 |
|
echo $outdir/$i/`ls $outdir/$i | grep $name` >> .darwinview/$name.datnc |
124 |
done |
done |
|
fi |
|
125 |
done |
done |
126 |
|
|
127 |
|
else |
128 |
|
echo "Error: please enter 'binary' or 'netcdf.'" |
129 |
|
exit |
130 |
|
fi |
131 |
|
|
132 |
|
if [ ! `ls | grep jet.dat` ]; then |
133 |
|
echo "Error: jet.dat not found." |
134 |
|
exit |
135 |
fi |
fi |
136 |
|
|
137 |
make |
gcc darwin.c -lglut |
138 |
./a.out |
./a.out $nb |