      SUBROUTINE SEARCH
      IMPLICIT NONE
      INTEGER I,J
      DOUBLE PRECISION U,V
c      INCLUDE 'setcon.txt'
c      INCLUDE 'veccom.txt'
c      INCLUDE 'redcom.txt'
c      INCLUDE 'seacom.txt'
C*****setcon.txt
      LOGICAL CONV,FAIL
      INTEGER NP,ITCT,PPIND
      DOUBLE PRECISION CSO,CSZ,LAM,SSOLD,GMOLD,GMNEW,SIGSQ,OLDB(22)
c      COMMON/SETCON/CONV,FAIL,NP,ITCT,PPIND,CSO,CSZ,LAM,SSOLD,
c     *GMOLD,GMNEW,SIGSQ,OLDB
      COMMON/SETCON/CSO,CSZ,LAM,SSOLD,
     *GMOLD,GMNEW,SIGSQ,OLDB,CONV,FAIL,NP,ITCT,PPIND
C*****veccom.txt
      DOUBLE PRECISION B(22),NEWB(22),PERB(22),DELB(22),
     * ERR(5000),RES(5000),PRES(22,5000),sres(5000)
      COMMON/VECCOM/B,NEWB,PERB,DELB,ERR,RES,PRES,sres
C*****redcom.txt
      DOUBLE PRECISION GRAD(22),SSP(22,22)
      COMMON/REDCOM/GRAD,SSP
C*****seacom.txt
      LOGICAL SOLV
      DOUBLE PRECISION ESSP(22,22),ECOV(22,22)
c      COMMON/SEACOM/SOLV,ESSP,ECOV
      COMMON/SEACOM/ESSP,ECOV,SOLV

      V=CSO+LAM
      DO I=1,NP
      DELB(I)=GRAD(I)
      DO J=1,NP
      U=SSP(I,J)
      IF(I.EQ.J)U=U*V
      ESSP(I,J)=U
      END DO
      END DO
      CALL SIMI
      IF(SOLV)THEN
        DO 101 I=1,NP
        NEWB(I)=OLDB(I)-DELB(I)
  101   CONTINUE
      END IF
      RETURN
      END
