      SUBROUTINE SEARCH(JREG,RKM,H1,H2,M,ZZ,EGVL,FNORM,EGVR,NATEN,NDPTH,
     1                   IEIG,IPRT,MX,EGV)
C
C     THIS SUBROUTINE ORGANIZES THE LOGIC FOR FINDING THE EIGEN VALUES
C
C     IEIG=1 - USE THE EIGEN VALUES IN THE PREVIOUS REGION TO START.
C               IEIG IS IGNORED I ON THE FIRST PASS AND NATEN IS USED.
C               IN SUBSEQUENT REGIONS IEIG TAKES PRIORITY AND NATEN IS
C               IGNORED.
C
C     IEIG=0 - ALWAYS START WITH EIGEN VALUES OF REAL PROBLEM AND USE
C              NATEN.
C
C
C     NATEN .GT. 1 - INTRODUCE THE ATENUATION A LITTLE (DATEN=
C                    ATEN/NATEN) AT A TIME STARTING FROM THE REAL PROB.
C
C     NATEN=0 OR 1 - OMIT INCREMENTAL APPROACH BUT START FROM REAL PROB.
C
C
C     NDPTH .GT. 1 - IF MULTIPLE EIGEN VALUES ARE
C                    INCOUNTERED WITH IEIG=1 START SEARCH AGAIN AND
C                    INTRODUCE THE DEPTH STEP H2-H1 A LITTLE ( (H2-H1)/
C                    NDPTH ) AT A TIME STARTING WITH THE EIGEN VALUES
C                    OF THE PREVIOUS REGION.
C
C     NDPTH=1      - OMIT INCREMENTAL APPROACH WITH DEPTH BUT USE THE
C                    EIGEN VALUES OF THE PREVIOUS REGION TO START.
C
C
      IMPLICIT REAL*8 (A-H,O-Z)
      REAL*8 ZZ(MX),ERMAX
      COMPLEX*16 EGVL(MX),FNORM(MX),EGVR(MX)
      COMPLEX*16 GAMA,EGV(MX),CDSRT,ONE
      COMPLEX*16 CKH,CSH
C
      COMMON /BLKEVN/ HB,CW,CB,FKW,FKB,ROHW,ROHB,ATEN
C
      ONE=DCMPLX(1.0D0,0.0D0)
C
      IF(IPRT .GE. 1) WRITE(9,40) JREG,RKM
   40 FORMAT(1H0,41HSEARCH FOR COMPLEX EIGEN VALUES IN REGION,I5,
     1           10H ENDING AT,F10.3,11H KM ENTERED)
C
      IF((JREG .GT. 1) .AND. (IEIG .EQ. 1)) GO TO 400
C
   50 CONTINUE
C
      IF(NATEN .LE.1) GO TO 100
C
      DATEN=ATEN/NATEN
      ATEN=DATEN
C
  100 CONTINUE
C
C
      CALL EGNVAL(H2,M,ZZ,MX)
      CALL PTURB(H2,M,ZZ,EGVR,MX)
      CALL CEGV(H2,M,EGVR,MX,ERMAX)
C
C
      IF(NATEN .LE. 1) GO TO 300
C
      NATM1=NATEN-1
      DO 200 JA=1,NATM1
C
C
      CALL CPTURB(H2,M,EGVR,DATEN,MX)
      CALL CEGV(H2,M,EGVR,MX,ERMAX)
C
C
  200 CONTINUE
C
  300 CONTINUE
C
C
      CALL CHECK(M,EGVR,IABRT,MX)
C
C
      IF(IABRT .GT.0) GO TO 320
C
      GO TO 900
C
  320 CONTINUE
C
      WRITE(9,350) IABRT,JREG,RKM
  350 FORMAT(1X,I5,39H REDUNDANT EIGEN VALUES FOUND IN REGION,I5,
     1       16H ENDING AT RANGE,F10.3,3H KM)
C
      IFLAG=1
      CALL ABORTC(IFLAG)
C
C
  400 CONTINUE
C
C
      CALL CPTBH(M,H1,H2,EGVL,FNORM,EGVR,MX)
      CALL CEGV(H2,M,EGVR,MX,ERMAX)
C
C
      CALL CHECK(M,EGVR,IABRT,MX)
C
C
      IF(IABRT .EQ. 0) GO TO 900
C
      IF((IABRT .GT. 0) .AND. (NDPTH .LE.1)) GO TO 320
C
      DO 500 I=1,M
      EGV(I)=EGVL(I)
  500 CONTINUE
C
      DDEP=(H2-H1)/NDPTH
C
      DO 700 JD=1,NDPTH
C
      HL=H1+(JD-1)*DDEP
      HR=H1+JD*DDEP
C
C
      CALL CPTBH(M,HL,HR,EGV,FNORM,EGVR,MX)
      CALL CEGV(HR,M,EGVR,MX,ERMAX)
C
C
      IF(JD .EQ. NDPTH) GO TO 700
      DO 600 I=1,M
      EGV(I)=EGVR(I)
      FNORM(I)=GAMA(HL,EGV(I))
  600 CONTINUE
C
  700 CONTINUE
C
C
      CALL CHECK(M,EGVR,IABRT,MX)
C
C
C     AS A LAST RESORT TRY STARTING FROM THE REAL PROBLEM
C     AND USE NATEN
C
      IF(IABRT .GT. 0) GO TO 50
C
  900 CONTINUE
C
      IF(IPRT .GE. 1) WRITE(9,950) ERMAX
  950 FORMAT(1X, 70HSEARCH FOR COMPLEX EIGEN VALUES COMPLETED WITH MAXIM
     1UM RELATIVE ERROR=,E12.4/)
C
C     WRITE(9,*) ' '
C
      DO 1000 I=1,M
      FNORM(I)=GAMA(H2,EGVR(I))
C
C      CKH=FKB*CDSRT(ONE-EGVR(I))
C      WRITE(9,990) I,CKH
C  990 FORMAT(1X,I5,2G23.14)
C
 1000 CONTINUE
C
C      WRITE(9,*) ' '
C
C      OMEGA=CB*FKB
C      DO 1100 I=1,M
C      CKH=FKB*CDSRT(ONE-EGVR(I))
C      CSH=1000.0D0*CKH/OMEGA
C      WRITE(9,990) I,CSH
C 1100 CONTINUE
C
      RETURN
      END
