PROGRAM PARS
C
C     Program created from matthews_coef.f 
C     this is a template for the parser routines
C     
      IMPLICIT NONE
C     ..
C     .. Parameters ..
      INTEGER NPARM
      PARAMETER(NPARM=200)

C     .. Local Scalars ..
      INTEGER NMOL, NUMSGP, NSYM, NSYMP, HOWMANY, I
      REAL WEIGHT
      LOGICAL DEBUG, FLAG
      CHARACTER PGNAME*10, SPGNAM*10, LONGLINE*100, CWORK*4
C     ..
C     .. Local Arrays ..
      REAL CELL(6), RSYM(4,4,192)
      INTEGER ARRAYMISB(100)

C---- things for parser
C
      CHARACTER KEY*4,LINE*600,CVALUE(NPARM)*4
      REAL      FVALUE(NPARM)
      LOGICAL   LEND
      INTEGER   NTOK,IBEG(NPARM),IEND(NPARM),ITYPE(NPARM),
     +          IDEC(NPARM)
C     ..
C     .. External Routines ..
      EXTERNAL CCPERR, CCPFYP, CCPRCS, PARSER
C     .. 
C     .. Initialisations
      NMOL = 1
      NSYM = 0
      CELL(1) = 0.0
      CELL(2) = 0.0
      CELL(3) = 0.0
      CELL(4) = 90.0
      CELL(5) = 90.0
      CELL(6) = 90.0
      WEIGHT = 0.0
      DEBUG = .FALSE.
      HOWMANY = 0
      FLAG = .FALSE.
C
      CALL CCPFYP
      CALL CCPRCS(6,'PARS','$Date: 1996/10/09 10:47:26 $')

C     ...Read keyword input
 10   CONTINUE
      KEY  = ' '
      LINE = ' '
      NTOK = NPARM
C
C          **********************************************************
      CALL PARSER(KEY,LINE,IBEG,IEND,ITYPE,FVALUE,CVALUE,IDEC,NTOK,LEND,
     +     .TRUE.)
C          **********************************************************
C
      IF (LEND) GO TO 200

C  Check to see if END keyword is declared
      IF(KEY.EQ.'END') THEN
        GO TO 200

C  Check to see if a keyword is declared eg debug?
      ELSEIF(KEY.EQ.'DEBU') THEN
        DEBUG = .TRUE.

C  Parse a real e.g. Molecular weight
      ELSEIF(KEY.EQ.'MOLW') THEN
        IF (NTOK.GE.2) CALL GTPREA(2,WEIGHT,NTOK,ITYPE,FVALUE)

C  Parse an integer eg Number of Molecules per asymmetric unit
      ELSEIF(KEY.EQ.'NMOL') THEN
        IF (NTOK.GE.2) CALL GTPINT(2,NMOL,NTOK,ITYPE,FVALUE)
C
C  Parse a number n of integers eg batches to miss
      ELSEIF(KEY.EQ.'MISB') THEN
        DO I = 2,NTOK
          IF (ITYPE(I).NE.2) GOTO 10
          HOWMANY = HOWMANY + 1
          CALL GTPINT(I,ARRAYMISB(I),NTOK,ITYPE,FVALUE)
       ENDDO
C
C  Parse the cell 
      ELSEIF(KEY.EQ.'CELL') THEN
        CALL RDCELL(2,ITYPE,FVALUE,NTOK,CELL)
C
C  Parse the Symm
      ELSEIF(KEY.EQ.'SYMM') THEN
        CALL RDSYMM(2,LINE,IBEG,IEND,ITYPE,FVALUE,NTOK,
     +      SPGNAM, NUMSGP, PGNAME, NSYM, NSYMP, RSYM)

C  Get a complicated line to parse later if need
      ELSEIF(KEY.EQ.'BLUR') THEN
        LONGLINE = LINE(IBEG(2):IEND(NTOK))
C
C  Some more complex sitiuations:
C
C  Parse a SUBKEY - flag becomes true if subkey matched
C     DOIT = the key
C     FAST = subkey
      ELSEIF(KEY.EQ.'DOIT') THEN
        CWORK = LINE(IBEG(2):IBEG(2)+3)
        IF (CWORK.EQ.'FAST') THEN
          FLAG = .TRUE.
        ENDIF
  
      ELSE
        WRITE(6,'(/,A,A4)') ' Unrecognised keyword ',KEY

      ENDIF
      GOTO 10

 200  CONTINUE
C
C---- End of input keywords 
C     at this point you can check to see if all the required 
C     keywords have been called with correct values e.g.
C
      IF (CELL(1) .EQ. 0.0) 
     +  CALL CCPERR(1,' *** The CELL keyword has not been given ***')
      IF (NSYM .EQ. 0) 
     +  CALL CCPERR(1,' *** The SYMM keyword has not been given ***')
      IF (WEIGHT .EQ. 0.0) CALL CCPERR(1,
     +           ' *** The MOLWEIGHT keyword has not been given ***')
C
C---- If everything OK start to calculate!

C     the main body of your program would be here
 
C

      CALL CCPERR(0,'Normal Termination')
      END