c$debug
c***********************************************************************
      PROGRAM CHUCK3
c
c     Main program, calls ACHCK3 and BCHCK3
c     
c***********************************************************************
c
C     KMAX  = Number of integration points
C     NCHAN = Number of sub channels in INTEG2
c     ispc  = Labeled common sizes
c     nlev  = number of levels
c
      parameter (kmax = 300, nchan = 64, ispc0 = 16384, ispc1 = 3*16384
     1, ispc4 = 12900, nlkmax = ispc1/2/kmax, nlev = 12)
c
	character*32  datfile,lisfile
      COMMON ALPHA(15),HBARC,AMU,CHGSQ,DRT,RMAX
     1,ICON(20),LMAX,KT,MAXD,IOUT,JOUT,NLTR,IDAT(6)
     2,KLAM(nlev),LTRT(nlev),JTRT(nlev),NADD(nlev)
      COMMON EN(nlev),FM(nlev),Z(nlev),FMA(nlev),ZA(nlev),RY(nlev)
     1,FS(nlev),ECM(nlev),FMU(nlev),RC(nlev),FK2(nlev),FK(nlev)
     2,ETA(nlev),AFACT(nlev),PFACT(nlev),DRF(nlev),FN(nlev)
     3,PNLOC(nlev),DUM(nlev),TSIG(nlev)
     4,IS(nlev),NS(nlev),NLI(nlev),IN(nlev),INN(nlev,nlev)
     5,LAM(nlkmax),ISP(nlkmax),JSP(nlkmax),ILK(nlkmax)
     6,LKTAB(2*nlkmax),ICUP(2*nlkmax),JCUP(2*nlkmax)
c
      COMMON/label0/ Space0(ispc0)
      COMMON/label1/ Space1(ispc1)
      COMMON/label4/ Space4(ispc4)
	common/ch3files/input, ioutp, datfile, lisfile
C
C     MAXD  = Number of scattering amplitude storage in COMMON/label0/
C
      MAXD  = ispc0/4
      HBARC = 197.327
      AMU   = 931.495
      fscon = 137.036
      CHGSQ = hbarc/fscon
      ifirst=0
 5001 CONTINUE
      CALL CH3_PC (IDAT,IFIRST)
C     CALL CH3UNIX(IDAT,IFIRST)
C     CALL CH3VAX (IDAT,IFIRST)
C     CALL CH3IBM (IDAT,IFIRST)
      call second(time)
      JOUT=0
C
c     Unit 2 stores scattering  amplitudes in SOLVE
c     Unit 3 stores integration end points in INTEG2
c
      REWIND 2
      REWIND 3
C
C     READ IN CARD SET 1
C
      icon(1) = 9
      READ (input,9000,END=5005)ICON,ALPHA
 5005 continue
c   
      if(icon(19).eq.0) then
        write(ioutp,9999)ifirst
	write(*    ,9900)time
	write(ioutp,9900)time
        write(ioutp,9005)
        write(ioutp,9019)idat
        write(ioutp,9003)icon,alpha
      endif
      ifirst=1
      if(icon(1).ne.9) then
        if(icon(19).eq.0) then
          write(*    ,'('' '',15a4)')alpha
        endif
C
C     PROGRAM MAY BE DIVIDED INTO 2 MAIN OVERLAYS
C
C     1- ACHCK3
C     2- BCHCK3
C
      if(icon(19).eq.0) then
	write(*,'(a)') ' Achck3 entered'
      endif
        CALL ACHCK3
      IF(JOUT.EQ.0) THEN
        if(icon(19).eq.0) then
	  write(*,'(a)') ' Bchck3 entered'
        endif
        CALL BCHCK3
      ENDIF

c
      else
        close (2)
        close (3)
        close (input)
        close (ioutp)  
        stop 'End of CHUCK3'
      endif
      GO TO 5001
c
 9000 FORMAT(20Z1,15A4)
 9003 FORMAT(' ',20(1x,Z1),4X,15A4)
 9005 FORMAT('0CONTROL INTEGERS  ')
 9019 FORMAT('  1 2 3 4 5 6 7 8 9 A B C D E F G H I J K'
     1,'    RUN IDENTIFICATION  ',40X,I4,2(1H/,I2.2),I4,2(1H.,I2.2))
 9900	format(' Elapsed time in seconds =',f8.2)
 9998 FORMAT('0ELAPSED TIME =', F9.2)
 9999 FORMAT(I1,'COUPLED CHANNELS CODE--CHUCK3-VAX/PC-VERSION  '
     1,' 12/Jan /1995 ')
      END


	block data ch3file
c
	character*32  datfile,lisfile
	common/ch3files/input, ioutp, datfile, lisfile
c
	data input, ioutp, datfile, lisfile
     1	/15,16, ' ', ' '/
	end


