Examples of MAIN Program and User Initialisation

+-------------+                                               +----------##
| Geant 3.15  |               GEANT User's Guide              | BASE100  ##
+-------------+                                               +----------##
                                   

Author(s) : R.Brun Submitted: 01.10.84 Origin : GEANT2/3 Revised: 10.01.92

This section contains examples of a standard user program to use the GEANT system. The main program is intended for batch applications, while to run the simulation interactively, the interactive main program called GXINT should be linked in front of the user code.

      PROGRAM MAIN
*
      PARAMETER (NG=100000,NH=10000)
      COMMON/PAWC/H(NH)
      COMMON/GCBANK/Q(NG)
*
*         Allocate memory for ZEBRA and HBOOK
      CALL GZEBRA(NG)
      CALL HLIMIT(-NH)
*
*         Initialise the graphics system (optional)
      CALL HPLINT (0)
*
*         Open the output metafile
      OPEN(1,FILE='geant.metafile',FORM='FORMATTED')
      CALL HPLCAP (-1)
*
*         Initialisation phase
      CALL UGINIT
*
*         Processing phase
      CALL GRUN
*
*         Termination phase
      CALL UGLAST
*
      END

Note: The HLIMIT call has to be placed after the call to GZEBRA and the argument has to be the dimension of the /PAWC/ common block with a negative sign in front. This way ZEBRA is initialised only once.

      SUBROUTINE UGINIT
*
+SEQ,GCLIST,GCRZ
*
*         Initialize GEANT variables
      CALL GINIT
*
*         Read data cards
      CALL GFFGO
*
*         Initialize data structures
      CALL GZINIT
*
*         Initialize drawing package
      CALL GDINIT
*
*         Open I/O buffers
      IF(NRGET  .GT. 0) THEN
*
*         Fetch permanent data structures
         CALL GRFILE(1,'mygeom.dat',' ')
         CALL GRIN('INIT',0,' ')
         CALL GREND(1)
      ELSE
*
*         Define standard Particle and Material data
         CALL GPART
         CALL GMATE
*
*         Define the geometrical set-up
         CALL UGEOM
         CALL GGCLOS
      ENDIF
      IF(NRSAVE .GT. 0) THEN
*
*         Save permanent data structures
         CALL GRFILE(2,'mysave.dat','U')
         CALL GROUT('INIT',1,' ')
         CALL GREND(2)
      ENDIF
*
*         Compute cross-section and energy loss tables
      CALL GPHYSI
*
*         Initialize standard histograms
      IF(NHSTA.GT.0) CALL GBHSTA
*
      END