       SUBROUTINE UGFFREAD
C
       IMPLICIT NONE
C
C
       include 'mcflags.inc'
       include 'vols.inc'
       include 'part.inc'
C
      LOGICAL IOK,ex
      INTEGER I, IARGC, nArgs
      CHARACTER*132 fileName
C
C Define user FFREAD data cards (format free input)
C
      call ffinit(1000)
      call ffset('SIZE', 8)
      call ffset('LINP',4)

C Define the run number

      CALL FFKEY('RAND',IRURNDM,2,'INTE')

C Initialise random number sequence

      CALL FFKEY('RSEQ',IRSEQ,1,'INTE')

C Set scale magnification for drawing package

      CALL FFKEY('MAGNIFY',MAGNIFY,1,'REAL')

C Define the hadronic interaction package (probably not needed)

      CALL FFKEY('HPMOD',hpmod,1,'INTE')

C Define the mother volume

      CALL FFKEY('MVOL', MOTHER_VOL, 3, 'REAL')

C Define the scintillator bar

      CALL FFKEY('SVOL', SCINTPAR, 3, 'REAL')
      CALL FFKEY('SPOS', SCINTPOS, 3, 'REAL')

C Define the lead tube

      CALL FFKEY('LIDH', LIDHEIGHT, 1, 'REAL')
      CALL FFKEY('LEADTHCK', LEADTHICKNESS, 1, 'REAL')

C Define the collimator

      CALL FFKEY('THETA', THETA, 1, 'REAL')

C Define the body

      CALL FFKEY('BODYVOL', SKINPAR, 3, 'REAL')
      CALL FFKEY('BODYPOS', BODYPOS, 3, 'REAL')  

C Read in particle types, momentum switch and momemtum from data card

      CALL FFKEY ('PTYPE', PTYPE,5, 'INTE')

      CALL FFKEY ('PX', PX, 5, 'REAL')
      CALL FFKEY ('PY', PY, 5, 'REAL')
      CALL FFKEY ('PZ', PZ, 5, 'REAL')

      CALL FFKEY ('PSWITCH',PSWITCH,1,'INTE')


      CALL GLUNDI
C
C
C Read the data cards
C
      nArgs = IARGC()
      DO I = 1, nArgs
              CALL GETARG(I,fileName)
              inquire(file=fileName,exist=ex)
              if (.not.ex) then
               PRINT *,'----------------------------------'
               PRINT *,'File : ',fileName,' does not exist'
               PRINT *,'----------------------------------'
               STOP
              endif
              OPEN(UNIT=4,STATUS='OLD',FORM='FORMATTED',file=fileName)
              CALL GFFGO
              CLOSE(4)
      ENDDO
C
      PRINT *,'MOTHER_VOl : ',MOTHER_VOL
C
      END

