Debian Codegraph @

docs/manual/make_plots

raw
1 #!/bin/ksh
2
3
4
5 clean="yes"
6 convert="yes"
7 runsuites="yes"
8 purpose="manual"
9
10 pages='01 02 03 04 05 06 07 08 09 10 11 12'
11
12
13 for arg;do
14 if [[ $arg = "-h" || $arg = "-help" || $arg = "--help" ]]
15 then
16 echo ""
17 echo "make_plots"
18 echo "Possible options:"
19 echo " -noclean : only run examples with updated source code"
20 echo " -noconvert : do not convert PS files to EPSI and PNG"
21 echo " -norun : do not run the example suites"
22 echo " -tutorial : run the examples for the tutorial"
23 echo " -v : verbose - prints every line"
24 echo ""
25 exit
26 fi
27
28 if [[ $arg = "-noclean" ]]
29 then
30 clean="no"
31 fi
32
33 if [[ $arg = "-noconvert" ]]
34 then
35 convert="no"
36 fi
37
38 if [[ $arg = "-norun" ]]
39 then
40 runsuites="no"
41 fi
42
43 if [[ $arg = "-tutorial" ]]
44 then
45 purpose="tutorial"
46 fi
47
48 if [[ $arg = "-v" ]]
49 then
50 set -x
51 fi
52
53 done
54
55
56
57 # create any directories that do not already exist
58
59 mkdir -p examples/$purpose/fortran/source
60 mkdir -p examples/$purpose/magml/source
61 mkdir -p examples/$purpose/c/source
62 mkdir -p examples/$purpose/python/source
63 mkdir -p examples/$purpose/fortran/ps
64 mkdir -p examples/$purpose/magml/ps
65 mkdir -p examples/$purpose/c/ps
66 mkdir -p examples/$purpose/python/ps
67 # mkdir -p examples/fortran/epsi
68 # mkdir -p examples/magml/epsi
69 mkdir -p examples/$purpose/fortran/png
70 mkdir -p examples/$purpose/magml/png
71 mkdir -p examples/$purpose/c/png
72 mkdir -p examples/$purpose/python/png
73
74
75 # make a note of the directory we started in
76
77 original_dir=$PWD
78
79 # -------------------------------------------------------------
80 # --------------------- FORTRAN Examples ----------------------
81 # -------------------------------------------------------------
82
83 # go to the directory from where we want to run the test suite
84
85 cd ../www/4_examples/progs
86
87
88 # set things up before we start
89
90 # use magics # not under ksh!!!
91 # use magicsX++
92 # use odb
93 ./setbin -$purpose
94
95
96 # clean first?
97
98 if [[ $clean = "yes" && $runsuites = "yes" ]]
99 then
100 ./clean
101 ./cleanps
102 fi
103
104
105
106 # compile the version of the test suite used for the manual plots
107
108 if [[ $runsuites = "yes" ]]
109 then
110 echo "RUNNING FORTRAN EXAMPLES"
111
112 ./compile_magplus -$purpose -quick -plain_names -noodb
113
114 if [[ $purpose = "tutorial" ]]
115 then
116 ./compile_mag69 compile_mag69 -$purpose -quick
117 fi
118 fi
119
120
121
122 # copy the source across
123
124 cp -f src/$purpose/*.f ../../../manual/examples/$purpose/fortran/source
125 # cp ps/*.ps ../../../manual/examples/ps
126
127
128
129 # split each PostScript file into individual pages and copy here
130
131 for ps_orig in ps/*.ps
132 do
133 bname=`basename $ps_orig .ps`
134
135 for page in $pages
136 do
137 new_ps=../../../manual/examples/$purpose/fortran/ps/${bname}_$page.ps
138 (psselect -p$page $ps_orig $new_ps) 2> pstemp.txt
139
140 no_pages=`grep "0 pages" pstemp.txt` # look for the string that tells us there is no page
141
142 if [[ $no_pages != "" ]] # ok, we've come to the end of this file
143 then
144 rm -f $new_ps
145 # echo "No ($page)"
146 break
147 fi
148 done
149 done
150
151 rm -f pstemp.txt
152
153
154
155
156
157 # -------------------------------------------------------
158 # --------------------- C Examples ----------------------
159 # -------------------------------------------------------
160
161 # go to the directory from where we want to run the test suite
162
163 # cd ../www/4_examples/progs
164
165
166 # set things up before we start
167
168 # use magics # not under ksh!!!
169 # use magicsX++
170 # use odb
171 ./setbin -$purpose -c
172
173
174 # clean first?
175
176 if [[ $clean = "yes" && $runsuites = "yes" ]]
177 then
178 ./clean
179 ./cleanps
180 fi
181
182
183 # compile the version of the test suite used for the manual plots
184
185 if [[ $runsuites = "yes" ]]
186 then
187 echo "RUNNING C EXAMPLES"
188
189 ./make_c_testsuite -$purpose -nogifs -plain_names
190 fi
191
192
193 # copy the source across
194
195 if [[ -a c/$purpose ]]
196 then
197 cp -f c/$purpose/*.c ../../../manual/examples/$purpose/c/source
198 fi
199
200
201 # split each PostScript file into individual pages and copy here
202
203 for ps_orig in ps/*.ps
204 do
205 bname=`basename $ps_orig .ps`
206
207 for page in $pages
208 do
209 new_ps=../../../manual/examples/$purpose/c/ps/${bname}_$page.ps
210 (psselect -p$page $ps_orig $new_ps) 2> pstemp.txt
211
212 no_pages=`grep "0 pages" pstemp.txt` # look for the string that tells us there is no page
213
214 if [[ $no_pages != "" ]] # ok, we've come to the end of this file
215 then
216 rm -f $new_ps
217 echo "No ($page)"
218 break
219 fi
220 done
221 done
222
223 rm -f pstemp.txt
224
225
226
227
228
229
230 # -------------------------------------------------------------
231 # --------------------- MagML Examples ------------------------
232 # -------------------------------------------------------------
233
234
235 # if [[ $runsuites = "yes" ]]
236 # then
237 # cd ../www/4_examples/progs
238 # fi
239
240
241 # clean first?
242
243 if [[ $clean = "yes" && $runsuites = "yes" ]]
244 then
245 ./cleanps -magml
246 fi
247
248
249 # run the version of the MagML test suite used for the manual plots
250
251 if [[ $runsuites = "yes" ]]
252 then
253 echo "RUNNING MAGML EXAMPLES"
254
255 ./make_magml_testsuite -$purpose
256
257 # cd 4_examples/progs
258 fi
259
260
261 # copy the source across
262
263 if [[ -a magml/$purpose ]]
264 then
265 cp -f magml/$purpose/*.magml ../../../manual/examples/$purpose/magml/source
266 fi
267
268
269 # copy the output PostScript files across
270 # pwd
271 # ls -l ../../html/test/magml/
272 cp -f ../../html/$purpose/magml/*.ps ../../../manual/examples/$purpose/magml/ps
273
274
275
276 # -------------------------------------------------------------
277 # --------------------- Python Examples -----------------------
278 # -------------------------------------------------------------
279
280
281 # clean first?
282
283 if [[ $clean = "yes" && $runsuites = "yes" ]]
284 then
285 ./cleanps -python
286 fi
287
288
289 # run the version of the Python test suite used for the manual plots
290
291 if [[ $runsuites = "yes" ]]
292 then
293 echo "RUNNING PYTHON EXAMPLES"
294
295 ./make_python_testsuite -$purpose
296 fi
297
298
299 # copy the source across
300
301 if [[ -a python/$purpose ]]
302 then
303 cp -f python/$purpose/*.py ../../../manual/examples/$purpose/python/source
304 fi
305
306
307
308
309 # split each PostScript file into individual pages and copy here
310
311 for ps_orig in ../../html/$purpose/python/*.ps
312 do
313 bname=`basename $ps_orig .ps`
314
315 for page in $pages
316 do
317 new_ps=../../../manual/examples/$purpose/python/ps/${bname}_$page.ps
318 (psselect -p$page $ps_orig $new_ps) 2> pstemp.txt
319
320 no_pages=`grep "0 pages" pstemp.txt` # look for the string that tells us there is no page
321
322 if [[ $no_pages != "" ]] # ok, we've come to the end of this file
323 then
324 rm -f $new_ps
325 # echo "No ($page)"
326 break
327 fi
328 done
329 done
330
331 rm -f pstemp.txt
332
333
334
335
336
337
338 # copy the output PostScript files across
339 # pwd
340 # ls -l ../../html/test/magml/
341 # cp -f ../../html/$purpose/python/*.ps ../../../manual/examples/$purpose/python/ps
342
343
344
345
346 # -------------------------------------------------------------
347 # --------------------- Metgram Examples ------------------------
348 # -------------------------------------------------------------
349
350 ## clean first?
351 #
352 #if [[ $clean = "yes" && $runsuites = "yes" ]]
353 #then
354 # ./cleanps -magml
355 #fi
356 #
357 #
358 ## run the version of the MagML test suite used for the manual plots
359 #
360 #if [[ $runsuites = "yes" ]]
361 #then
362 # echo "RUNNING MAGML EXAMPLES"
363 #
364 # ./make_magml_testsuite -$purpose
365 #
366 ## cd 4_examples/progs
367 #fi
368 #
369 #
370 ## copy the source across
371 #
372 #if [[ -a magml/$purpose ]]
373 #then
374 # cp -f magml/$purpose/*.magml ../../../manual/examples/$purpose/magml/source
375 #fi
376 #
377 #
378 ## copy the output PostScript files across
379 ## pwd
380 ## ls -l ../../html/test/magml/
381 #cp -f ../../html/test/magml/*.ps ../../../manual/examples/$purpose/magml/ps
382 #
383
384
385
386
387
388
389
390 # ----------------------------------------------------------
391 # --------------------- Conversions ------------------------
392 # ----------------------------------------------------------
393
394
395
396 # convert to EPSI and PNG?
397
398 if [[ $convert = "yes" ]]
399 then
400 echo "CONVERTING OUTPUTS TO PNG"
401
402 echo "[Converting outputs to EPSI and PNG...]"
403 cd $original_dir
404 tools/convert_example_outputs -$purpose -nogifs
405 fi
406
407
408 # move all diagrams over to the diagrams directory
409
410 mv examples/manual/fortran/png/diagram*.png diagrams
411
412
413 # format the listings for DocBook
414
415 cd $original_dir
416 tools/generate_example_listings
417 tools/format_listings -$purpose
418