*
*     ------------------------------------------------------------------
*	C F G O 1
*     ------------------------------------------------------------------
*
*	Read configurations for one state, assuming orthogonality of
*       the orbitals
*
      SUBROUTINE CFGO1(NCFG,MAXORB,IAJCMP,LJCOMP,NJCOMP,NOCCSH,
     :                  NELCSH,NOCORB,J1QNRD,NCD,INPUT)
      IMPLICIT DOUBLE PRECISION(A-H,O-Z)
      PARAMETER (NWD=30)
*
      CHARACTER BUFFER(NWD)*3, HEADER*72, INPUT*24
      CHARACTER*1 JAJCLD(NWD,3),JAJCMP(NWD,3),JCQN(9)
      COMMON/INFORM/IREAD,IWRITE,IOUT,ISC0,ISC1,ISC2,ISC3,JSC0,JSC(3)
      COMMON /CLOSED/B1ELC(4),NCLOSD,IAJCLD(NWD),LJCLSD(NWD),IBK
*
      DIMENSION IAJCMP(NWD),LJCOMP(NWD),NJCOMP(NWD),NOCCSH(NCD),
     :          NELCSH(5,NCD),NOCORB(5,NCD),J1QNRD(9,NCD),
     :          J3QN(9),J2QN(9),J1QN(9)
*
    3 FORMAT(18(1X,A3))
    4 FORMAT(3A1)
    5 FORMAT(9(1X,A3,1H(,I2,1H)))
    6 FORMAT(9(1X,4X,I1,A1,I1))
    7 FORMAT(A72)
    8 FORMAT(A3)
   22 FORMAT(// 7H STATE ,' (WITH',I3,' CONFIGURATIONS):'/1H ,31(1H-)/)
   23 FORMAT(/10H THERE ARE,I3,21H ORBITALS AS FOLLOWS://
     : 5X,21(1X,A3):/5X,21(1X,A3))
   25 FORMAT(/14H CONFIGURATION,I3,' ( OCCUPIED ORBITALS=',I2,' ):'
     : ,5(1X,A3,1H(,I2,1H)))
   26 FORMAT(26X,17H COUPLING SCHEME:,5(1X,4X,I1,A1,I1))
   27 FORMAT(54X,4(1X,4X,I1,A1,I1))
   28 FORMAT(/10H THERE ARE ,I3,31H CLOSED SUBSHELLS COMMON TO ALL ,
     :  27H CONFIGURATIONS AS FOLLOWS: //
     :  5X, 21(1X,A3))
*
* --- ANALYZE INPUT DATA
*
      OPEN(UNIT=4,FILE=INPUT,STATUS='OLD')
      CALL ANALY1(IREAD,IWRITE,NCLOSD,MAXORB,0,NCFG,NOCCSH,BUFFER,NCD)
      REWIND(UNIT=IREAD)
*
* ---  Process the configuration data
*
      READ(BUFFER,8) (IAJCMP(I),I=1,MAXORB)
      WRITE(IWRITE,22) NCFG
      WRITE(IWRITE,23) MAXORB,(IAJCMP(I),I=1,MAXORB)
      READ(BUFFER,4)((JAJCMP(I,J),J=1,3),I=1,MAXORB)
      DO 60 I=1,MAXORB
      IF (JAJCMP(I,1) .EQ. ' ') THEN
         JAJCMP(I,1) = JAJCMP(I,2)
         JAJCMP(I,2) = JAJCMP(I,3)
         JAJCMP(I,3) = ' '
      ENDIF
      LJCOMP(I) = LVAL(JAJCMP(I,2))
      NJCOMP(I) = ICHAR(JAJCMP(I,1)) - ICHAR('1') + 1
   60 CONTINUE
*
* --- READ HEADER CARD FOR THE CASE
*
      READ(IREAD,7) HEADER
      WRITE(IOUT,7) HEADER
*
* --- READ IN THE COMMON SET OF CLOSED SUBSHELLS
*
      READ(IREAD,3) (BUFFER(I),I=1,NCLOSD)
      IF (NCLOSD .EQ. 0) GO TO 70
      READ(BUFFER,8) (IAJCLD(I),I=1,NCLOSD)
      WRITE(IWRITE,28) NCLOSD,(IAJCLD(I),I=1,NCLOSD)
      READ(BUFFER,4) ((JAJCLD(I,J),J=1,3),I=1,NCLOSD)
      DO 71 I=1,NCLOSD
      J = 3
      IF (JAJCLD(I,1) .NE. ' ') J = 2
      LJCLSD(I) = LVAL(JAJCLD(I,J))
71    CONTINUE
 70   CONTINUE
*
* --- READ IN (AND PRINT OUT) CONFIGURATIONS ETC. FOR THE STATE UNDER
* --- CONSIDERATION
*
      DO 63 I=1,NCFG
      N=NOCCSH(I)
      READ(IREAD,5)        (NOCORB(J,I),NELCSH(J,I),J=1,N)
      WRITE(IWRITE,25) I,N,(NOCORB(J,I),NELCSH(J,I),J=1,N)
      DO 61 J=1,N
      DO 61 JJ=1,MAXORB
   61 IF(NOCORB(J,I).EQ.IAJCMP(JJ)) NOCORB(J,I)=JJ
      M=2*N-1
      N1=N+1
      READ(IREAD,6)    (J3QN(J),JCQN(J),J1QN(J),J=1,M) 
      WRITE(IWRITE,26) (J3QN(J),JCQN(J),J1QN(J),J=1,N) 
      IF(N.GT.1) WRITE(IWRITE,27) (J3QN(J),JCQN(J),J1QN(J),J=N1,M)
      DO 62 J=1,M
      J2QN(J) = 2*LVAL(JCQN(J)) + 1
      J1QNRD(J,I) = (J3QN(J)*64 + J2QN(J))*64 + J1QN(J)
   62 CONTINUE
   63 CONTINUE
      CALL CFGTST(NCFG,LJCOMP,NOCCSH,NELCSH,NOCORB,J1QNRD,NCD)
      RETURN
      END
