forked from OSSOS/SurveySimulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateDistrib.sh
executable file
·92 lines (79 loc) · 2.35 KB
/
CreateDistrib.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
#! /bin/bash
# Determine directory name
ID=`date +"%Y%m%d"`
d="../SurveySim${ID}"
da=`date +"%F"`
dt=`LC_ALL=us date +"%d %b %Y"`
df=`LC_ALL=us date +"%b %d/%Y"`
v="2.0"
intended_audience="OSSOS team"
#intended_audience="General Public"
# Create a clean distribution directory
if [ -d $d ]; then
\rm -rf $d
fi
mkdir $d
if [ -e ../CurrentDistrib ]; then
\rm ../CurrentDistrib
fi
if [ -h ../CurrentDistrib ]; then
\rm ../CurrentDistrib
fi
ln -s ${d/./} ../CurrentDistrib
curdir=$(pwd)
# Copy fix files
cat > $d/README.version <<EOF
## Survey Simulator for OSSOSv12
## Survey simulator as of $dt
EOF
head -2 README.md > $d/README.md
cat >> $d/README.md <<EOF
$df release to $intended_audience
EOF
tail --line=+3 README.md >> $d/README.md
cp -a eupl* Simulator Models $d/
for s in CFEPS OSSOS All_r_Surveys All_Surveys; do
mkdir -p $d/Surveys/$s
cp Surveys/$s/* $d/Surveys/$s/
done
for s in CFEPS OSSOS All_r_Surveys; do
\rm -f $d/Surveys/$s/README.formats
ln -s ../All_Surveys/README.formats $d/Surveys/$s/README.formats
done
\rm -f $d/Simulator/F77/fortran/Test*f
\rm -f $d/Simulator/F95/fortran/test*f95
# Initialize SurveySubs.f
cd $d/Simulator/F77/fortran
cp SurveySubs.f zzzz0
n=`grep -i include zzzz0 | grep -i -v "[a-z].*include" | grep -i -v "include 'param.inc'" | wc -l`
# Now loop on including "include" files, except "include 'param.inc'"
while [ $n -gt 0 ]; do
cp zzzz0 zzzz1
grep -i include zzzz0 | grep -i -v "[a-z].*include" | grep -i -v "include 'param.inc'" | (
while read inc file rest; do
grep -v "include.*$file" zzzz1 | grep -v "INCLUDE.*$file" > zzzz2
cat `echo $file | sed "s/'//g"` >> zzzz2
\mv zzzz2 zzzz1
done
)
\mv zzzz1 zzzz0
n=`grep -i include zzzz0 | grep -i -v "[a-z].*include" | grep -i -v "include 'param.inc'" | wc -l`
done
# Now inline the "include 'param.inc'" statements.
cp zzzz0 zzzz1
${curdir}/InlineIncludeParam.py
\rm -f zzzz1
# Move the result in the distribution directory
cat > SurveySubs.f <<EOF
c-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
c
c File generated on $da
c
c-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
EOF
cat zzzz0 >> SurveySubs.f
\rm GetSurvey.f EffUtils.f PosVelUtils.f Polygon-lib.f ElemPosUtils.f Rotation.f zzzz0
cd ${curdir}
# Create the tarball
tar czf ../SurveySimulator-${ID}.tgz $d
exit