C====THE CORRECTION TO THE ENERGY ================
C==== OF A DISCRETE EXCITED STATE =================
      SUBROUTINE DISNN(OM,OM1,A,SA,JJ,NC,NC0,N1,M,M1,
     *        IMIN,LAML,LAMM,XM0,DELXM,XMAXM,L,R,S,MA,
     *        C,Q,D1,D2,B,B1,B2)

      INTEGER M(*),M1(*),IMIN(*)
      REAL*8 OM,OM1,SA,A,XM0(*),DELXM(*),XMAXM(*),
     *       LAML(*),LAMM(NC,*),R(N1,*),S(N1,*),
     *       MA(N1,*),SB,SB2,Y1,DOM,DOM1,SA1(3),
     *       C(*),Q(*),D1(*),D2(*),B(N1,*),
     *       B1(N1,*),B2(*)
      SB2=0.0D 00
      DOM=1.D-05
      IMIN1=IMIN(NC0)
C      WRITE(6,1000) IMIN1,NC0,JJ,IC1
C1000  FORMAT('input disnn imin1 nco jj ic1'/4I4)
      DO 1 J=1,3
         SA=0.0D 00
         DOM1=DOM*DFLOAT(J-2)
C        WRITE(*,*) J
         CALL CQDN(OM+DOM1,0.D 00,NC,NC0,M,M1,XM0,DELXM,
     *             XMAXM,LAML,LAMM,JJ,C,Q,D1,D2)
C        WRITE(*,'between cqdn invman')
         CALL INVMAN(M,M1,XM0,DELXM,XMAXM,LAML,
     *              IMIN,OM,L,JJ,NC,NC0,N1,C,Q,D1,D2,MA,
     *              Y1,R,S,B,B1,B2)
C         WRITE(*,*) DOM1
         IMIN1=IMIN(NC0)
       WRITE(*,1001) IMIN1,NC0,JJ
 1001  FORMAT(' in disnn after invman imin1 CHAN  jj '/22X,3I5)
         IF(IMIN1.NE.0) THEN
         DO 2 I=1,N1
    2       SA=SA+R(IMIN1,I)*MA(I,IMIN1)
         END IF
         SA1(J)=SA
    1    CONTINUE
      DO 3 I=1,3
    3    SA1(I)=SA1(I)/DFLOAT(2*L+1)
      SA=SA1(2)
      SB=(SA1(3)-SA1(1))/2.D 00/DOM
      A=1.D 00-SB
      OM=OM+(OM1-OM+SA)/A
C     WRITE(6,100) OM,SA,SB
C 100 FORMAT(5X,'OM=',D15.6,' AB=',2D20.6)
      RETURN
      END
