-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMAKE-MPI-CHAPTER
executable file
·140 lines (121 loc) · 3.42 KB
/
MAKE-MPI-CHAPTER
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/csh
#MAKE-MPI-CHAPTER
unalias rm
# adopted from HPF script -- thanks to David Loveman
#Version of July 29, 1993 - Steve Otto, Oregon Graduate Institute
# MAKE-MPI-CHAPTER - a script similar to MAKE-MPI-REPORT. It takes
# one argument, the filename of the chapter to be produced. It
# uses the file chapter-head.tex and a set of
# temporary files named temp.*
#set TEXroot=/usr/local/bin
#alias latex $TEXroot/latex
#alias dvips $TEXroot/dvips
#alias xdvi $TEXroot/xdvi
set thedate = `date`
echo " "
echo BEGIN JOB ON: $thedate
echo "this script assumes that latex, dvips, and xdvi"
echo "are on your search path"
if $#argv != 1 then
echo -n "type the chapter's filename:"
set f = "$<"
else
set f = $1
endif
if ( ! (-e $f) ) then
echo "file $f does not exist"
exit 1
else if ( ! (-r $f) ) then
echo "file $f is not readable"
exit 1
else
echo "file $f exists and is readable"
endif
rm -f temp.tex >& /dev/null
cat chapter-head.tex $f > temp.tex
cp temp.tex temp1.tex # we will cp temp1 to temp if there are no \cite's
echo "\bibliographystyle{plain}" >> temp.tex
echo "\bibliography{refs}" >> temp.tex
echo "\end{document}" >> temp.tex
echo "\end{document}" >> temp1.tex
echo " "
which latex
grep '\cite' temp.tex >& /dev/null
if ($status == 1) then
cp temp1.tex temp.tex
endif
##################################################
# Run LATEX the first time
##################################################
echo " "
echo "latex $f the first time"
latex temp #< /dev/null
if($status != 0) then
echo "first LATEX run fails, quit"
exit(1)
endif
##################################################
# Run BIBTEX
##################################################
echo " "
echo "bibtex $f"
bibtex temp < /dev/null
if($status != 0) then
echo "BibTeX run fails, quit"
exit(1)
endif
grep "\item" temp.bbl # check to see if any items have appeared in bbl file
if($status == 1) then # if not, overwrite temp with temp1
rm -f temp.tex >& /dev/null
mv temp1.tex temp.tex
endif
##################################################
# Run LATEX the second time
##################################################
echo " "
echo "latex $f the second time"
latex temp < /dev/null
if($status != 0) then
echo "second LATEX run fails, quit"
exit(1)
endif
##################################################
# Run LATEX the third time
##################################################
echo " "
echo "latex $f the third time"
latex temp < /dev/null
if($status != 0) then
echo "third LATEX run fails, quit"
exit(1)
endif
##################################################
# Run dvips to produce a ps file
##################################################
echo " "
echo "dvips -o temp.ps $f"
dvips -o temp.ps temp
if($status != 0) then
echo "DVIPS fails, quit"
exit(1)
endif
set fbase = `basename $f '.tex'`
rm -f $fbase.ps $fbase.dvi >& /dev/null
mv temp.ps $fbase.ps
mv temp.dvi $fbase.dvi
echo " "
echo "files $fbase.ps and $fbase.dvi have been created"
##################################################
# Run xdvi to view the .dvi file
##################################################
#echo " "
#echo "xdvi $fbase"
#xdvi $fbase &
##################################################
# Print the ps file
##################################################
echo " "
echo "now print the postscript file (this script doesn't)"
rm -f temp.* >& /dev/null
echo "done"
echo " "