      SUBROUTINE MIG2(X,A,B,N,XN,NM,FM,IPAR,IPA)
C     THE PARAMETERS
C     IPAR(IPA+1) = IPR - PRINTING PARAMETER
C     IPAR(IPA+2) = M - THE TOTAL NUMBER OF FUNCTION EVALUATIONS
      DIMENSION IPAR(30),X(N),A(N),B(N),XN(NM)
       COMMON /BAYZ/Z(20)/BS1/Y(1000)/INW/IN/ATT/AT(15)
     C/STATIS/IFAIL,M,IM,L
      IFAIL=0
      IN=5
      CALL INWR15(A,B,N,NM,IPAR,IPA)
      IF (IFAIL.EQ.10) RETURN
      IPR=IPAR(IPA+1)
      M=IPAR(IPA+2)
      J=0
      DO 70 K=1,M
      DO 10 I=1,N
   10 Z(I)=ATS(1)*(B(I)-A(I))+A(I)
      FF=FI(Z,N)
      L=K
      Y(L)=FF
      DO 16 I=1,N
      J1=J+I
   16 XN(J1)=Z(I)
      J=J+N
      IF (K.EQ.1) GO TO 20
      IF (FM.LE.FF) GO TO 50
   20 FM=FF
      IM=K
      DO 30 I=1,N
   30 X(I)=Z(I)
   50 IF(IPR.LE.0) GO TO 70
      IF (MOD(K,IPR).EQ.0) CALL SPAU15(X,Z,N,FM,FF,IPR)
   70 CONTINUE
      IF (IPR.LT.0) RETURN
      IN=IN+100
      CALL SPAU15(X,Z,N,FM,FF,IPR)
      RETURN
      END
      SUBROUTINE INWR15(A,B,N,NM,IPAR,IPA)
      DIMENSION IPAR(30),A(N),B(N)
      COMMON /STATIS/IFAIL,IM,ITM,NF
      MN=20
      MM=1000
      MIP=30
      NOUT=I1MACH(2)
      K=2
      IF (IPA.GE.0.AND.IPA+K.LE.MIP) GO TO 10
      WRITE (NOUT,520) K,MIP
      WRITE (NOUT,510) IPA
    5 IFAIL=10
      RETURN
   10 CONTINUE
      IPRINT=IPAR(IPA+1)
      M=IPAR(IPA+2)
      IF (IPRINT.LT.0) GO TO 110
      WRITE (NOUT,680)
      WRITE (NOUT,620)
      WRITE (NOUT,630) N
  110 IF (N.GT.0.AND.N.LE.MN) GO TO 20
      WRITE (NOUT,500) MN
      IF (IPRINT.LT.0) WRITE (NOUT,630) N
      GO TO 5
   20 CONTINUE
      IF (IPRINT.LT.0) GO TO 40
      WRITE (NOUT,640) IPRINT
      WRITE (NOUT,650) M
   40 IF (M.GT.0.AND.M.LE.MM) GO TO 50
      WRITE (NOUT,530) MM
      IF (IPRINT.LT.0) WRITE (NOUT,650) M
      GO TO 5
   50 IF (NM.GE.N*M) GO TO 60
      WRITE (NOUT,540)
      IF (IPRINT.GE.0) GO TO 55
      WRITE (NOUT,630) N
      WRITE (NOUT,650) M
   55 WRITE (NOUT,635) NM
      GO TO 5
   60 CONTINUE
      IF (IPRINT.LT.0) GO TO 200
      WRITE (NOUT,570)
      WRITE (NOUT,580) (A(I),I=1,N)
      WRITE (NOUT,590)
      WRITE (NOUT,580) (B(I),I=1,N)
  200 NER=0
      DO 90 I=1,N
      IF (A(I).LE.B(I)) GO TO 90
      IF (NER.NE.0) GO TO 86
      WRITE (NOUT,600) I,I
      GO TO 87
   86 WRITE (NOUT,605) I,I
   87 CONTINUE
      NER=1
   90 CONTINUE
      IF (NER.NE.1) RETURN
      IF (IPRINT.GE.0) GO TO 5
      WRITE (NOUT,570)
      WRITE (NOUT,580) A
      WRITE (NOUT,590)
      WRITE (NOUT,580) B
      GO TO 5
  500 FORMAT (/2X,59H**E R R O R  I N  M I G 2** N LESS THAN 1 OR N GREA
     CTER THAN,I3)
  510 FORMAT (/2X,20HNUMBER OF PARAMETERS,11X,5HIPA =,I6)
  520 FORMAT (/2X,43H**E R R O R  I N  M I G 2** IPA LESS THAN 0/2X,
     C7HOR IPA+,I2,13H GREATER THAN,I3)
  530 FORMAT (/2X,59H**E R R O R  I N  M I G 2** M LESS THAN 1 OR M GREA
     CTER THAN,I6/)
  540 FORMAT (/2X,44H**E R R O R  I N  M I G 2** NM LESS THAN N*M)
  570 FORMAT ( /2X,32HVECTOR OF LOWER BOUNDS (A) FOR X)
  580 FORMAT (4(2X,E15.8))
  590 FORMAT (2X,32HVECTOR OF UPPER BOUNDS (B) FOR X)
  600 FORMAT (/2X,30H**E R R O R  I N  M I G 2** A(,I3,17H) GREATER THAN
     C B(,I3,1H))
  605 FORMAT (30X,2HA(,I3,17H) GREATER THAN B(,I3,1H))
  620 FORMAT (/2X,22HI N I T I A L  D A T A)
  630 FORMAT (/2X,19HNUMBER OF VARIABLES,14X,3HN =,I6)
  635 FORMAT (2X,26HDIMENSION OF WORKING ARRAY,6X,4HNM =,I6)
  640 FORMAT (/2X,18HPRINTING PARAMETER,13X,5HIPR =,I6)
  650 FORMAT (2X,30HNUMBER OF FUNCTION EVALUATIONS, 3X,3HM =,I6)
  680 FORMAT (////12X,7HM I G 2)
      END
      SUBROUTINE SPAU15(X,Z,N,YM,FF,IPR)
      DIMENSION X(N),Z(N)
      COMMON /INW/IN/STATIS/IFAIL,IT,IM,L
      NOUT=I1MACH(2)
      IF(IN.GT.100) GOTO 10
      WRITE(NOUT,100)
      IF (L.EQ.IPR) WRITE(NOUT,210)
      WRITE(NOUT,110) L
      WRITE(NOUT,120) FF
      WRITE(NOUT,140)
      WRITE(NOUT,130) (Z(I),I=1,N)
      IF (L.EQ.1) RETURN
      WRITE(NOUT,150) YM,IM
      WRITE(NOUT,160)
      WRITE(NOUT,130) (X(I),I=1,N)
      RETURN
   10 WRITE(NOUT,170)
      WRITE(NOUT,180)
      WRITE(NOUT,150) YM,IM
      WRITE(NOUT,160)
      WRITE(NOUT,130) (X(I),I=1,N)
      WRITE(NOUT,190) L
      WRITE (NOUT,230)
      WRITE(NOUT,170)
      RETURN
  100 FORMAT (/1X,34(2H -))
  110 FORMAT(2X,23HI T E R A T I O N  NR =,I6)
  120 FORMAT (/2X,19HFUNCTION VALUE F = ,E15.8)
  130 FORMAT(4(2X,E15.8))
  140 FORMAT (2X,13HCURRENT POINT)
  150 FORMAT (/2X,28HOPTIMAL FUNCTION VALUE FM = ,E15.8,17H OBTAINED IN
     CNR =,I6)
  160 FORMAT(2X,13HOPTIMAL POINT)
  170 FORMAT (/1X,34(2H *)/1X,34(2H *))
  180 FORMAT (/2X,13HR E S U L T S)
  190 FORMAT (/2X,34HNUMBER OF FUNCTION EVALUATIONS L =,I6)
  210 FORMAT (1X,34(2H -))
  230 FORMAT (/7X,15HMIG2 TERMINATED)
      END
