Skip to content

Commit

Permalink
Update of Survey Simulator in preparation for v9 release of OSSOS. 20…
Browse files Browse the repository at this point in the history
…17-03-08T07:44 UT
  • Loading branch information
jmpetit authored and jmpetit committed Mar 8, 2017
1 parent bbc9088 commit 42b1fbb
Show file tree
Hide file tree
Showing 23 changed files with 1,710 additions and 1,636 deletions.
23 changes: 14 additions & 9 deletions CreateDistrib.sh
Expand Up @@ -25,43 +25,48 @@ ln -s ${d/./} ../CurrentDistrib
# Copy fix files
cat > $d/README.version <<EOF
Survey Simulator for OSSOSv8
Survey Simulator for OSSOSv9-pre
Survey simulator as of $dt
EOF
head -2 README.first > $d/README.first
cat >> $d/README.first <<EOF
$df release
$df release to OSSOS team
EOF
tail --line=+3 README.first >> $d/README.first
cp -a README.contact lookup parametric Python $d/
for s in cfeps OSSOS OSSOS-cfeps All_Surveys; do
for s in cfeps OSSOS OSSOS-cfeps OSSOS-MA All_Surveys; do
mkdir $d/$s
cp ../$s/* $d/$s/
done
cp src/Driver.{f,py} src/README.* $d/src/
cp src/Driver.{f,py} src/README.* src/ModelUtils.f $d/src/
\rm -f $d/cfeps/*.py

# Initialize SurveySubs.f
cd src
grep -i -v "^c.*include" SurveySubs.f > zzzz0
n=`grep -i include zzzz0 | grep -i -v "[a-z].*include" | wc -l`
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
# 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 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" | wc -l`
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
../InlineIncludeParam.py
\rm -f zzzz1

# Move the result in the distribution directory
cp SurveySubsHistory ../$d/src/SurveySubs.f
cat >> ../$d/src/SurveySubs.f <<EOF
Expand Down
53 changes: 53 additions & 0 deletions InlineIncludeParam.py
@@ -0,0 +1,53 @@
#! /usr/bin/env python
"""
Inline the "include 'param.inc'" statements in SurveySubs.f.
"""

def read_file_raw(fichier):
"""
Reads in file 'fichier' and returns a list of lines.
No processing is done on any line.
"""
iter = 0
while True:
try:
f = file(fichier,'r')
except IOError:
try:
fg = gzip.open(fichier+'.gz','r')
except IOError:
print 'Cannot open', fichier, ' nor ', fichier+'.gz'
iter += 1
if iter > 5:
print 'Something is wrong, quitting!'
lines = None
break
fichier = raw_input('Please re-enter the file name: ')
else:
lines = fg.readlines()
fg.close()
break
else:
lines = f.readlines()
f.close()
break
return lines

if __name__ == "__main__":
fin = 'zzzz1'
fout = 'zzzz0'
lines = read_file_raw(fin)
pas = read_file_raw('param.inc')
if lines:
fo = open(fout, 'w')
for line in lines:
cp = True
ws = line.split()
if (len(ws) == 2):
if (((ws[0] == "include") or (ws[0] == "INCLUDE")) and (ws[1] == "'param.inc'")):
cp = False
for pa in pas:
fo.write(pa)
if cp:
fo.write(line)
fo.close()
2 changes: 1 addition & 1 deletion Python/Driver.in
@@ -1,6 +1,6 @@
123456789 ! Random number generator seed
100 ! Number of tracked detections
./cfeps
../cfeps
./Resonance_3_2-g.in
./SimulDetect.dat
./SimulTrack.dat
Expand Down
4 changes: 2 additions & 2 deletions Python/Makefile
Expand Up @@ -25,5 +25,5 @@ GiMeObj.so: Res32Model.f SurveySubs.so Makefile
clean:
\rm -f *.o core SurveySimulator

test: SurveySimulator
./example/test.sh
test: Modules
./test.sh

0 comments on commit 42b1fbb

Please sign in to comment.