      PROGRAM DVEC2ASCI
C
C  ADAPTED FROM
C  PROGRAM OF KTT FOR READING DIPOLE MATRIX ELEMENT DATA
C
      IMPLICIT REAL*8 (A-H,O-Z)
C
      PARAMETER (MZCHF=   160)    !CHANNELS
      PARAMETER (MZMNP=  8000)    !R-MATRIX EIGENVALUES
      PARAMETER (MZEST=   050)    !ALL BOUND STATE ENERGIES PER SYMMETRY
C
      PARAMETER (MNPEXT=MZMNP+MZCHF)
C
      DIMENSION AMAT(MZCHF,MZCHF),BMATL(MZCHF,MZCHF)
     X,BMATV(MZCHF,MZCHF)
      DIMENSION DVECT(MNPEXT,MZEST)
C
C
      ITAPE7=7
      ITAPE8=8
C
      OPEN(ITAPE7,FILE='DVEC',STATUS='OLD',FORM='UNFORMATTED')
      OPEN(ITAPE8,FILE='DVEC.ASCI',STATUS='UNKNOWN',FORM='FORMATTED')
C
 100  READ(ITAPE7,END=200) MNP2D2,NCHND2,LRGLD2,NPTYD2,NSPND,
     1             MNP2D1,NCHND1,LRGLD1,NPTYD1,K20,K10,M11,MLAST
      WRITE(ITAPE8,*) MNP2D2,NCHND2,LRGLD2,NPTYD2,NSPND,
     1             MNP2D1,NCHND1,LRGLD1,NPTYD1,K20,K10,M11,MLAST
C
C  CHECK DIMENSIONS FOR MNP2,MZCHF
C
      N=MAX(NCHND1,NCHND2)
      M=MAX(MNP2D1,MNP2D2)
      IF(M.GT.MZMNP.OR.N.GT.MZCHF) THEN
        WRITE(*,600)MNP2D1,NCHND1,MNP2D2,NCHND2
        STOP
      ENDIF
C
C  READ DIPOLE MATRIX
C
      MINP=MLAST-M11+1
      IF(MINP.GT.MZEST)THEN
        WRITE(*,601)MINP
        STOP
      ENDIF
C
      READ(ITAPE7)((DVECT(K2,M1),K2=1,K20),M1=1,MINP)
      WRITE(ITAPE8,*)((DVECT(K2,M1),K2=1,K20),M1=1,MINP)
      READ(ITAPE7)((DVECT(K2,M1),K2=1,K20),M1=1,MINP)
      WRITE(ITAPE8,*)((DVECT(K2,M1),K2=1,K20),M1=1,MINP)
C
C  READ ANGULAR COEFFICIENTS
C
      READ(ITAPE7) ((AMAT(J,I),J=1,NCHND1),I=1,NCHND2),
     1             ((BMATL(J,I),J=1,NCHND1),I=1,NCHND2),
     2             ((BMATV(J,I),J=1,NCHND1),I=1,NCHND2)
      WRITE(ITAPE8,*) ((AMAT(J,I),J=1,NCHND1),I=1,NCHND2),
     1             ((BMATL(J,I),J=1,NCHND1),I=1,NCHND2),
     2             ((BMATV(J,I),J=1,NCHND1),I=1,NCHND2)
      GO TO 100
C
  200 WRITE(*,*)'DVEC.ASCI WRITTEN'
C
  600 FORMAT(//1X,30(1H*)//' DIMENSION FOR MNP2 OR NCHF TOO'
     &,' SMALL'//  ' MNP2D1, NCHND1 = ',I5,', ',I5/
     &  ' MNP2D2, NCHND2 = ',I5,', ',I5//1X,30(1H*)//)
  601 FORMAT(//' INCREASE MZEST TO AT LEAST: ',I4)
      END
