build_pythia6.sh
Go to the documentation of this file.
1 #!/usr/bin/env bash
2 #
3 # A script to download and build pythia6.
4 #
5 # Build both a static library for use with fortran and a shared object
6 # library for use with ROOT. Strips out the dummy routines that would
7 # hide the real ones found in pdflib. Currently does *not* extract include
8 # files from the downloaded source, but uses definitions embedded in this
9 # script. Should work on both Linux and Mac OS X.
10 #
11 # Usage: ./build_pythia6 [version] [--dummies=bestry|remove|keep] \
12 # [--refetch] [gfortran|g77|g95] [-m32]
13 #
14 # where [version] takes a form like "6.4.28", "6428" or "6_428" w/ or
15 # without an optional leading "v". It will created a subdirectory named
16 # "v6_428" so it is probably wise to run this in a directory named "pythia6"
17 # or some such. The --dummies=XYZZY controls whether the dummy PDFSET,
18 # STRUCTM and STRUCTP routines are removed. The -m32 forces a 32-bit
19 # build.
20 #
21 # Creates directory structure:
22 #
23 # pythia6/ - start in this directory
24 # v6_428/ - created subdirectory
25 # download/ - code downloaded from remote locations
26 # inc/ - include files for selected common blocks
27 # (hardcoded! not from downloaded source)
28 # lib/ - liblund.a pydata.o libPythia6.so
29 # src/ - fsplit source (and intermediate .o files)
30 # tpythia6_build/ - files for building ROOT interface
31 #
32 # Questions? Suggestions? Improvements? Offers of insane amounts of cash?
33 # Write me at: Robert Hatcher <rhatcher@fnal.gov>
34 #
35 # History:
36 # 2006-10-20: original version created by <rhatcher@fnal.gov>
37 # 2007-06-28: strict bash needs -gt to compare an int value, not ">"
38 # bail out if fetching source fails
39 # 2007-08-07: version 6.4.11 and beyond are at www.hepforge.org and use
40 # a different naming convention; support 6409 and earlier
41 # from old location (6.4.10 is in tar form... punt for now)
42 # more alternatives for version specification, this is
43 # needed for different file naming schemes old vs. new
44 # use wget if possible, curl if not, bail if neither avail
45 # 2007-10-16: add flags
46 # --keep-dummies : force the keeping of pdflib dummies
47 # --refetch : force refetch of source code
48 # look around for CERNLIB pdflib[804], mathlib, kernlib
49 # libraries with which to link against in order
50 # to satisfy removed dummies
51 # 2007-10-17: change to --dummmies=[besttry|remove|keep]
52 # besttry (default) means try to link to CERNLIB
53 # if any of the libraries can't be found then
54 # don't remove dummmies
55 # remove always removes dummy routine and tries to link
56 # to what ever libraries that it can find
57 # keep always keeps dummy routine
58 # 2008-01-05: fix "keep" option to actually keep dummy stubs.
59 # 2009-04-09: choose fortran compiler, if cmd line specified use that
60 # otherwise first of gfortran or g77 found
61 # 2010-12-29: addition of -m32 option; default v6_422
62 # 2011-01-13: default v6_424; clean up comments
63 # 2014-07-14: default v6_428; http->https for hepforge
64 # 2016-05-19: new location for root download
65 #
66 ############################################################################
67 #
68 version=6.4.28
69 doclean=0
70 dummyaction="besttry"
71 refetch=0
72 whichftn="unknown"
73 m32flag=""
74 while [ $# -gt 0 ] ; do
75  case $1 in
76  *clean*)
77  doclean=1 ;;
78  *dumm*)
79  case $1 in
80  *keep*)
81  dummyaction="keep" ;;
82  *remove*)
83  dummyaction="remove" ;;
84  *best*)
85  dummyaction="besttry" ;;
86  *)
87  echo "failed to parse $1" ;;
88  esac ;;
89  *refetch*)
90  refetch=1 ;;
91  *g77*)
92  whichftn="g77" ;;
93  *gfortran*)
94  whichftn="gfortran" ;;
95  *g95*)
96  whichftn="g95" ;;
97  *m32*)
98  m32flag="-m32" ;;
99  *)
100  version=$1 ;;
101  esac
102  shift
103 done
104 
105 ############################################################################
106  export ESCCHAR="\x1B" # or \033 # Mac OS X bash doesn't support \e as esc?
107  export OUTBLACK="${ESCCHAR}[0;30m"
108  export OUTBLUE="${ESCCHAR}[0;34m"
109  export OUTGREEN="${ESCCHAR}[0;32m"
110  export OUTCYAN="${ESCCHAR}[0;36m"
111  export OUTRED="${ESCCHAR}[0;31m"
112  export OUTPURPLE="${ESCCHAR}[0;35m"
113  export OUTORANGE="${ESCCHAR}[0;33m" # orange, more brownish?
114  export OUTLTGRAY="${ESCCHAR}[0;37m"
115  export OUTDKGRAY="${ESCCHAR}[1;30m"
116  # labelled "light but appear in some cases to show as "bold"
117  export OUTLTBLUE="${ESCCHAR}[1;34m"
118  export OUTLTGREEN="${ESCCHAR}[1;32m"
119  export OUTLTCYAN="${ESCCHAR}[1;36m"
120  export OUTLTRED="${ESCCHAR}[1;31m"
121  export OUTLTPURPLE="${ESCCHAR}[1;35m"
122  export OUTYELLOW="${ESCCHAR}[1;33m"
123  export OUTWHITE="${ESCCHAR}[1;37m"
124  export OUTNOCOL="${ESCCHAR}[0m" # No Color
125 # use as: echo -e "${OUTRED} this is red ${OUTNOCOL}"
126 ##############################################################################
127 
128 
129 ############################################################################
130 #
131 # decompose version string which could take any of the forms:
132 # [v]{Major}.{minor}.{tiny}, [v]{Major}_{minor}{tiny} or
133 # [v]{Major}{minor}{tiny}, with the assumption that {Major} is always "6"
134 # and {tiny} is two digits.
135 #
136 # remove any "v" in version number
137 version0=${version#v*}
138 
139 major=${version0%%.*}
140 if [ "${major}" = "6" ] ; then
141 # in M.m.tt format
142  foo=${version0#*.}
143  minor=${foo%%.*}
144  tiny=${foo##*.}
145 else
146  major=${version0%%_*}
147  if [ "${major}" = "6" ] ; then
148 # in M_mtt format, convert to Mmtt
149  version0=${version0/_/}
150  fi
151 # assume Mmtt format, could it also be Mmmtt? anticipate it could be.
152 # ${parmeter:offset:length} doesn't work for negative offsets as advertized
153  major=${version0:0:1}
154  foo=`echo $version0 | cut -c2-`
155  if [ ${foo} -lt 1000 ] ; then
156  minor=`echo $foo | cut -c1`
157  tiny=`echo $foo | cut -c2-3`
158  else
159  minor=`echo $foo | cut -c1-2`
160  tiny=`echo $foo | cut -c3-4`
161  fi
162 fi
163 
164 ############################################################################
165 #
166 # script only works for pythia6
167 #
168 if [ "${major}" != "6" ] ; then
169  echo -e "${OUTRED}sorry this script only works for pythia6, not ${major}${OUTNOCOL}"
170  exit
171 fi
172 
173 ############################################################################
174 #
175 # use the naming conventions v{Major}_{minos}{tiny} for the subdir
176 # to match that used by UPS at FNAL.
177 #
178 topdir=v${major}_${minor}${tiny}
179 toppath=`pwd`/${topdir}
180 
181 echo -e ${OUTCYAN}version $version major $major minor $minor tiny $tiny ${OUTNOCOL}
182 echo -e ${OUTGREEN}full path: $toppath ${OUTNOCOL}
183 
184 if [ ! -d ${topdir} ] ; then
185  mkdir $topdir
186 fi
187 cd $topdir
188 for subdir in inc lib download src tpythia6_build ; do
189  if [ ! -d ${subdir} ] ; then
190  mkdir ${subdir}
191  fi
192 done
193 
194 ############################################################################
195 #
196 # pick a fortran: g77 vs. gfortran vs. g95
197 #
198 if [ "$whichftn" == "unknown" ] ; then
199 # for now not g95 option ...
200 # whichg95=`which g95 | grep -v "no g95 in"`
201  if [ ! -z "${whichg95}" ] ; then
202  whichftn="g95"
203  else
204 # echo "no g95"
205  whichgfortran=`which gfortran | grep -v "no gfortran in"`
206  if [ ! -z "${whichgfortran}" ] ; then
207  whichftn="gfortran"
208  else
209 # echo "no gfortran"
210  whichg77=`which g77 | grep -v "no g77 in"`
211  if [ ! -z "${whichg77}" ] ; then
212  whichftn="g77"
213  else
214  echo "could not find a fortran compiler (g95, gfortran, g77)"
215  fi
216  fi
217  fi
218 fi
219 export FORT=$whichftn
220 echo -e "${OUTGREEN}using $FORT as fortran compiler${OUTNOCOL}"
221 
222 ############################################################################
223 #
224 # make "inc" symlink
225 # (various scripts disagree about where the include files should live)
226 #
227 cd src
228 if [ ! -f inc ] ; then
229  echo make symlink src/../inc src/inc
230  ln -sf ../inc ./inc
231 else
232  echo src/inc symlink exists
233 fi
234 cd ${toppath}
235 #
236 #
237 ############################################################################
238 #
239 add2link()
240 {
241  # routine for building up linkage "-Lpath -llibrary" in variable
242  # given by varname (arg 1) for library (arg 2) in potential locations
243  # (args 3+). Don't repeat location in string. Look for various extensions
244  #
245  varname=$1
246  shift
247  libname=$1
248  shift
249  export foundlib=0
250  while [ $# -gt 0 ] ; do
251  loc=$1
252  shift
253  for ext in .a .so .dylib ; do
254  fullname=${loc}/lib${libname}${ext}
255  #echo look for ${fullname}
256  if [ -f ${fullname} ] ; then
257  #echo hit it at -L${loc} -l${libname}
258  foundlib=1
259  echo ${!varname} | grep ${loc} 2>&1 > /dev/null
260  if [ $? -ne 0 ] ; then
261  export $varname="${!varname} -L${loc} -l${libname}"
262  else
263  export $varname="${!varname} -l${libname}"
264  fi
265  break;
266  fi
267  done
268  if [ ${foundlib} -ne 0 ] ; then break ; fi
269  done
270 }
271 #
272 ############################################################################
273 #
274 # look for the CERNLIB libraries: pdflib[804], mathlib, kernlib
275 # these are needed in order to satisfy the removed dummy routines
276 # if they can't be found then don't remove the dummies
277 #
278 CERNLINK="" # -L${CERNLIBS} -lpdflib804 -lmathlib -lkernlib"
279 if [ "$dummyaction" = "keep" ] ; then
280  echo requested to keep dummy PDFSET, STRUCTM and STRUCTP
281 else
282  missinglib=""
283  add2link CERNLINK pdflib $CERNLIB $CERNLIBS $CERN_DIR/lib $CERN_ROOT/lib
284  if [ ${foundlib} -eq 0 ] ; then
285  add2link CERNLINK pdflib804 $CERNLIB $CERNLIBS $CERN_DIR/lib $CERN_ROOT/lib
286  if [ ${foundlib} -eq 0 ] ; then
287  missinglib="$missinglib pdflib[804]"
288  fi
289  fi
290  add2link CERNLINK mathlib $CERNLIB $CERNLIBS $CERN_DIR/lib $CERN_ROOT/lib
291  if [ ${foundlib} -eq 0 ] ; then
292  missinglib="$missinglib mathlib"
293  fi
294  add2link CERNLINK kernlib $CERNLIB $CERNLIBS $CERN_DIR/lib $CERN_ROOT/lib
295  if [ ${foundlib} -eq 0 ] ; then
296  missinglib="$missinglib kernlib"
297  fi
298  # didn't find something?
299  if [ -n "$missinglib" ] ; then
300  echo "### unable to locate library: ${missinglib} "
301  if [ "$dummyaction" = "besttry" ] ; then
302  echo "### revert to keeping dummy PDFSET, STRUCTM and STRUCTP "
303  CERNLINK=""
304  dummyaction="keep"
305  fi
306  else
307  dummyaction="remove"
308  fi
309  if [ -n "$CERNLINK" ] ; then
310  echo will attempt to resolve removed dummies with CERNLINK =
311  echo " $CERNLINK"
312  fi
313 fi # user didn't initially request "keep"
314 
315 ############################################################################
316 #
317 if [ ${doclean} -ne 0 ] ; then
318  echo clean out old code
319 fi
320 
321 ############################################################################
322 #
323 # decide on how to fetch the source files
324 #
325 cd ${toppath}/download
326 #
327 # wget or curl for retreiving remote files?
328 # (OS X doesn't generally have wget on it, so fall back on curl in that case)
329 #
330 whichfetchit=`which wget | grep -v "no wget in"`
331 if [ ! -z "${whichfetchit}" ] ; then
332  echo use \"wget\" for fetching files
333  fetchit='wget --no-check-certificate '
334 else
335  whichfetchit=`which curl | grep -v "no curl in"`
336  if [ ! -z "${whichfetchit}" ] ; then
337  # -f = fail without creating dummy, -O output local named like remoteza
338  echo use \"curl -f -O\" for fetching files
339  fetchit='curl -f -O '
340  else
341  echo "Neither wget nor curl available -- can't download files"
342  exit 1
343  fi
344 fi
345 
346 ############################################################################
347 #
348 # retrieve the pythia6 fortran soruce file
349 # naming and location depends on version
350 #
351 mt=${minor}${tiny}
352 if [ $mt -lt 410 ] ; then
353 # old location, unzip .f file
354  basef=pythia${major}${minor}${tiny}.f
355  #location=http://www.thep.lu.se/~torbjorn/pythia
356  #location=http://home.thep.lu.se/~torbjorn/pythia
357  gzipped=""
358 elif [ $mt -eq 410 ] ; then
359 # not a case we can handle
360 # there is a .tar.gz file at the new location .. but that's too much work
361  echo "source files for minor version $minor can't be handled by this script"
362  exit
363 else
364 # new location, .f file is gzipped
365  basef=pythia${major}${minor}${tiny}.f
366  #location=hhttp://home.thep.lu.se/~torbjorn/pythia6
367  #location=http://home.thep.lu.se/~torbjorn/pythia6
368  location=https://pythia.org/download/pythia6
369  gzipped=""
370 fi
371 # if we don't already have it, fetch the .f file
372 if [ ! -f ${basef}_with_dummies -o ${refetch} -ne 0 ] ; then
373  echo -e "${OUTCYAN}${fetchit} ${location}/${basef}${gzipped} ${OUTNOCOL}"
374  $fetchit ${location}/${basef}${gzipped}
375  if [ ! ${basef}${gzipped} ] ; then
376  echo -e "${OUTRED}Sorry could not fetch ${basef}${gzipped} from ${location}${OUTNOCOL}"
377  exit 1
378  fi
379  if [ -n "${gzipped}" ] ; then
380  rm -f ${basef}
381  gzip -d ${basef}${gzipped}
382  fi
383  mv ${basef} ${basef}_with_dummies
384 fi
385 
386 ############################################################################
387 #
388 # fetch the ROOT interface code
389 #
390 if [ ! -f pythia6.tar.gz -o ${refetch} -ne 0 ] ; then
391  # rooti="ftp://root.cern.ch/root/pythia6.tar.gz"
392  rooti=https://root.cern.ch/download/pythia6.tar.gz
393  echo -e "${OUTCYAN}${fetchit} ${rooti}${OUTNOCOL}"
394  ${fetchit} ${rooti}
395 fi
396 
397 ############################################################################
398 #
399 # need to remove PDFSET/STRUCTM/STRUCTP routines from pythia6 code
400 # if we're using PDFLIB to supply the PDFSET, STRUCTM, STRUCTP routines
401 #
402 if [ "$dummyaction" = "keep" ] ; then
403  cp ${basef}_with_dummies ${basef}
404  echo not removing dummy routines
405 else
406  cat > rm_dummy.awk <<EOF
407 BEGIN { writeout=1; isend=0; }
408 /SUBROUTINE PDFSET/ { writeout=0; }
409 /SUBROUTINE STRUCTM/ { writeout=0; }
410 /SUBROUTINE STRUCTP/ { writeout=0; }
411 / END\$/ { if ( writeout == 1 ) print \$0; writeout=1; isend=1; }
412 // { if ( writeout == 1 && isend != 1 ) print \$0; isend=0; }
413 EOF
414  awk -f rm_dummy.awk ${basef}_with_dummies > ${basef}
415 fi
416 
417 # extract block data routine
418 #cat > extract_pydata.awk <<EOF
419 #BEGIN { writeout=0; }
420 #/C...PYDATA/ { writeout=1; }
421 #/ END\$/ { if ( writeout == 1 ) print \$0; writeout=0; }
422 #// { if ( writeout == 1 ) print \$0; }
423 #EOF
424 #awk -f extract_pydata.awk ${basef} > pydata.f
425 
426 ############################################################################
427 #
428 # create a Makefile for the pythia6 source code
429 #
430 cd ${toppath}/src
431 cat > Makefile <<EOF
432 #
433 # simple pythia6 makefile
434 #
435 UNAME = \$(shell uname)
436 ifeq "\$(UNAME)" "Linux"
437  AR=ar
438  F77=$FORT
439  FFLAG= -O -fno-second-underscore -fPIC $m32flag
440  CPP = gcc -E
441  CPPFLG= -C -P
442 endif
443 ifeq "\$(UNAME)" "Darwin"
444  AR=ar
445  F77=$FORT
446  FFLAG= -O -fno-second-underscore -fPIC $m32flag
447  CPP = cc -E
448  CPPFLG= -C -P
449 endif
450 LIB = ../lib
451 CPPFLGS = \$(CPPFLG) -D\$(UNAME)
452 
453 FOBJSALL = \$(patsubst %.f,%.o,\$(wildcard *.f)) \
454  \$(patsubst %.F,%.o,\$(wildcard *.F))
455 
456 # remove the "pdfdum.o" as we don't want that going into the .a library
457 FOBJS = \$(filter-out pdfdum.o,\$(FOBJSALL))
458 
459 #------------------------------------------
460 
461 all: \$(LIB)/liblund.a \$(LIB)/pydata.o
462 
463 \$(LIB)/liblund.a: \$(FOBJS)
464  \$(AR) -urs \$(LIB)/liblund.a \$(FOBJS)
465 
466 \$(LIB)/pydata.o: pydata.o
467  cp -p pydata.o \$(LIB)/pydata.o
468 
469 \$(LIB)/pdfdum.o: pdfdum.o
470  cp -p pdfdum.o \$(LIB)/pdfdum.o
471 
472 clean:
473  rm -f *.o
474 
475 veryclean:
476  rm -f \$(LIB)/liblund.a \$(LIB)/pydata.o \$(LIB)/pdfdum.o
477  rm -f *.o
478 
479 #------------------------------------------
480 
481 .SUFFIXES : .o .f .F
482 
483 .f.o:
484  \$(F77) \$(FFLAG) -c \$<
485 
486 .F.o:
487  \$(F77) \$(FFLAG) -c \$<
488 
489 EOF
490 
491 ############################################################################
492 #
493 # split the pythia6 source code, build the library
494 #
495 whichfsplit=`which fsplit | grep -v "no fsplit in"`
496 echo initial ${whichfsplit}
497 if [ -z "${whichfsplit}" ] ; then
498  echo "No 'fsplit' -- can't build library without it"
499  echo "try to build fsplit"
500 # echo -e "${OUTCYAN}$fetchit -O http://home.fnal.gov/~rhatcher/fsplit.c ${OUTNOCOL}"
501 # $fetchit http://home.fnal.gov/~rhatcher/fsplit.c
502  echo -e "${OUTCYAN}$fetchit https://scisoft.fnal.gov/scisoft/packages/fsplit/fsplit.c ${OUTNOCOL}"
503  $fetchit https://scisoft.fnal.gov/scisoft/packages/fsplit/fsplit.c
504 
505  gcc -o fsplit fsplit.c
506  PATH=.:${PATH}
507  whichfsplit=`which fsplit`
508  echo "built ${whichfsplit}"
509 
510 fi
511 if [ ! -z "${whichfsplit}" ] ; then
512  echo "build static lund library"
513  if [ ${doclean} -gt 0 ] ; then rm -f *.f ; fi
514  if [ ! -f pydata.f ] ; then
515  fsplit ${toppath}/download/${basef}
516 # hack for illegal computation in DATA statement in some versions
517 # apparently works for g77 but not gfortran
518  mv pyalps.f pyalps.f_original
519  sed -e 's+(2D0\*107D0/2025D0)+0.10567901234568D0+g' \
520  -e 's+(2D0\*963D0/14375D0)+0.13398260869565D0+g' \
521  -e 's+(2D0\*321D0/3703D0)+0.17337294085876D0+g' \
522  -e 's+(-2D0\*107D0/1875D0)+-0.11413333333333D0+g' \
523  -e 's+(-2D0\*963D0/13225D0)+-0.14563327032136D0+g' \
524  -e 's+(-2D0\*321D0/3381D0)+-0.18988464951198D0+g' \
525  pyalps.f_original > pyalps.f
526  fi
527  rm -f zzz*.f
528  if [ "$dummyaction" != "keep" ] ; then
529  for junk in pdfset.f structm.f structp.f ; do
530  if [ -f ${junk} ] ; then
531  echo "${junk} in split output, should have been removed"
532  rm -f ${junk}
533  fi
534  done
535  fi
536  make all
537 fi
538 
539 ############################################################################
540 #
541 # build the ROOT interface library libPythia6.so
542 #
543 echo "build ROOT accessable shared library"
544 cd ${toppath}/tpythia6_build
545 
546 tar xzvf ${toppath}/download/pythia6.tar.gz pythia6/tpythia6_called_from_cc.F
547 tar xzvf ${toppath}/download/pythia6.tar.gz pythia6/pythia6_common_address.c
548 mv pythia6/* .
549 rmdir pythia6
550 echo 'void MAIN__() {}' > main.c
551 gcc -c -fPIC -fcommon $m32flag main.c
552 gcc -c -fPIC -fcommon $m32flag pythia6_common_address.c
553 $FORT -c -fPIC -fno-second-underscore $m32flag tpythia6_called_from_cc.F
554 
555 cd ${toppath}/lib
556 
557 arch=`uname`
558 if [ ${arch} == "Linux" ] ; then
559  $FORT $m32flag -shared -Wl,-soname,libPythia6.so -o libPythia6.so \
560  ${toppath}/tpythia6_build/*.o ${toppath}/src/*.o ${CERNLINK}
561 fi
562 if [ ${arch} == "Darwin" ] ; then
563  macosx_minor=`sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2`
564  gcc $m32flag -dynamiclib -flat_namespace -single_module -undefined dynamic_lookup \
565  -install_name ${toppath}/lib/libPythia6.dylib -o libPythia6.dylib \
566  ${toppath}/tpythia6_build/*.o ${toppath}/src/*.o ${CERNLINK}
567  if [ $macosx_minor -ge 4 ]; then
568  ln -sf libPythia6.dylib libPythia6.so
569  else
570  gcc $m32flag -bundle -flat_namespace -undefined dynamic_lookup -o libPythia6.so \
571  ${toppath}/tpythia6_build/*.o ${toppath}/src/*.o ${CERNLINK}
572  fi
573 fi
574 
575 ############################################################################
576 #
577 # create pythia6 include files for common blocks
578 #
579 # here we'd like to automate the extraction of the common common blocks
580 # into include files but it's non-trivial
581 
582 echo "extract include files"
583 cd ${toppath}/inc
584 
585 # define a #include that declares the types of all the pythia functions
586 cat > pyfunc.inc <<EOF
587 C...standard pythia functions
588  double precision PYFCMP,PYPCMP
589  double precision PYCTEQ,PYGRVV,PYGRVW,PYGRVS,PYCT5L,PYCT5M,PYHFTH
590  double precision PYGAMM,PYSPEN,PYTBHS,PYRNMQ,PYRNM3,PYFINT,PYFISB
591  double precision PYXXZ6,PYXXGA,PYX2XG,PYX2XH,PYH2XX
592  double precision PYGAUS,PYGAU2,PYSIMP,PYLAMF,PYTHAG
593  double precision PYRVSB,PYRVI1,PYRVI2,PYRVI3,PYRVG1,PYRVG2,PYRVG3
594  double precision PYRVG4,PYRVR, PYRVS, PY4JTW,PYMAEL
595  double precision PYMASS,PYMRUN,PYALEM,PYALPS,PYANGL
596  double precision PYR, PYP
597  integer PYK,PYCHGE,PYCOMP
598  character*40 VISAJE
599 
600  external PYFCMP,PYPCMP
601  external PYCTEQ,PYGRVV,PYGRVW,PYGRVS,PYCT5L,PYCT5M,PYHFTH
602  external PYGAMM,PYSPEN,PYTBHS,PYRNMQ,PYRNM3,PYFINT,PYFISB
603  external PYXXZ6,PYXXGA,PYX2XG,PYX2XH,PYH2XX
604  external PYGAUS,PYGAU2,PYSIMP,PYLAMF,PYTHAG
605  external PYRVSB,PYRVI1,PYRVI2,PYRVI3,PYRVG1,PYRVG2,PYRVG3
606  external PYRVG4,PYRVR, PYRVS, PY4JTW,PYMAEL
607  external PYMASS,PYMRUN,PYALEM,PYALPS,PYANGL
608  external PYR, PYP
609  external PYK,PYCHGE,PYCOMP
610  external VISAJE
611 EOF
612 
613 # how to "automate" the others ... including declaring the types
614 # without using the IMPLICIT DOUBLE PRECISION etc.
615 # NEUGEN3 needs pydat1.inc pydat3.inc pyjets.inc at a minimum
616 # !!!! for now just hard-code them !!!
617 
618 cat > pydat1.inc <<EOF
619 C...Parameters.
620  integer MSTU, MSTJ
621  double precision PARU, PARJ
622  COMMON/PYDAT1/MSTU(200),PARU(200),MSTJ(200),PARJ(200)
623 EOF
624 
625 cat > pydat2.inc <<EOF
626 C...Particle properties + some flavour parameters.
627  integer KCHG
628  double precision PMAS, PARF, VCKM
629  COMMON/PYDAT2/KCHG(500,4),PMAS(500,4),PARF(2000),VCKM(4,4)
630 EOF
631 
632 cat > pydat3.inc <<EOF
633 C...Decay information
634  integer MDCY, MDME, KFDP
635  double precision BRAT
636  COMMON/PYDAT3/MDCY(500,3),MDME(8000,2),BRAT(8000),KFDP(8000,5)
637 EOF
638 
639 cat > pyjets.inc <<EOF
640 C...The event record.
641  integer N,NPAD,K
642  double precision P, V
643  COMMON/PYJETS/N,NPAD,K(4000,5),P(4000,5),V(4000,5)
644  SAVE /PYJETS/
645 EOF
646 
647 cat > pypars.inc <<EOF
648 C...Parameters.
649  integer MSTP, MSTI
650  double precision PARP, PARI
651  COMMON/PYPARS/MSTP(200),PARP(200),MSTI(200),PARI(200)
652 EOF
653 
654 cat > pysubs.inc <<EOF
655 C...Selection of hard scattering subprocesses
656  integer MSEL,MSELPD,MSUB, KFIN
657  double precision CKIN
658  COMMON/PYSUBS/MSEL,MSELPD,MSUB(500),KFIN(2,-40:40),CKIN(200)
659 EOF
660 
661 ############################################################################
662 #
663 # done
664 #
665 echo "end-of-script $0"
666 # End-of-Script