      SUBROUTINE EXKOR(X,A,B,N,FM,IPAR,PAR,IPA,IPAA)
C
C     COORDINATE OPTIMIZATION OF FUNCTION FI(X,N)
C
C     INPUT :X,A,B,N,IPAR,PAR,IPA,IPAA
C     OUTPUT:X,FM
C     X 	     INPUT-INITIAL POINT,OUTPUT-OPTIMUM POINT
C     A 	     BEGINNING OF INTERVALS OF OPTIMIZATION
C     B 	     END OF INTERVALS OF OPTIMIZATION
C     N 	     DIMENSIONALITY OF X
C     FM	     OPTIMUM
C     IPAR(IPA+5)    NUMBER OF COORDINATE WHICH BEGINS OPTIMIZATION
C		     IN FIRST CYCLE
C     IPAR(IPA+4)    NUMBER OF CYCLES
C     IPAR(IPA+2)    MAXIMAL ALLOWABLE NUMBER OF EVALUATIONS OF FI
C     IPAR(IPA+3)    IT IS USED IN EXTR AS IPAR(IPA+3) AND RECOMMENDED=6
C     IPAR(IPA+1)    INDICATOR OF PRINTING
C		     <0 NO PRINTING
C		     =0 PRINTING OF INITIAL POINT AND RESULTS OF OPTIMIZ
C		     =IP PRINTING OF OPTIMIZATION RESULTS IN IP ITERAT
C     PAR(IPAA+1)    ACCURACY OF FM
C     PAR(IPAA+2)-PAR(IPAA+N+1) ACCURACY OF OPTIMUM POINT
      COMMON /STATIS/IFAIL,J4,ITM,NF/INW/IN/SP13/K1,K2
      COMMON /IEXTR/ IFAULT
      COMMON /EXTR3/NS/EXTR9/N1
      COMMON /EXTR4/XPA(20),YPA
      COMMON /EXK1/ J2,NEX/EXT10/XE,YE
      DIMENSION X(N),PA(2),IP(3),PAR(30),IPAR(30),A(N),B(N)
      IFAIL=0
      IN=4
      CALL INWR13(X,A,B,N,FM,IPAR,PAR,IPA,IPAA)
      IF (IFAIL.EQ.10) RETURN
      NEX=N
      YPA=FM
      DO 10 I=1,N
   10 XPA(I)=X(I)
      NF=1
      PA(1)=PAR(IPAA+1)
      IP(1)=IPAR(IPA+2)
      IP(2)=IPAR(IPA+3)
      KC=IPAR(IPA+4)
      IPR=IPAR(IPA+1)
      J4=0
      DO 100 J1=1,KC
      I4=IPAR(IPA+5)
      IF (J1.GT.1) I4=1
      K1=J1
      DO  90 J2=I4,N
      K2=J2
      IP(3)=J2
      IN=4
      I=IPAA+J2+1
      PA(2)=PAR(I)
      CALL EXTRKO(XM,A(J2),B(J2),YM,IP,PA)
      J4=J4+1
      GO TO (20,20,30,40),IN
   20 IF (J4.LE.N) CALL INWR13(X,A,B,N,FM,IPAR,PAR,IPA,IPAA)
      GO TO 90
   30 X(J2)=XE
      CALL INWR13(X,A,B,N,YE,IPAR,PAR,IPA,IPAA)
      IFAIL=10
   40 CONTINUE
      IF (YM.LT.FM) ITM=J4
      YPA=YM
      FM =YM
      XPA(J2)=XM
      NF=NF+N1
      X(J2)=XM
      IF (IFAIL.EQ.10) RETURN
      IF (IPR.LE.0) GO TO 90
      IF (MOD(J4,IPR).EQ.0) CALL SPAU13(X,N,FM,IPR)
   90 CONTINUE
  100 CONTINUE
      IN=IN+100
      IF(IPR.GE.0) CALL SPAU13(X,N,FM,IPR)
      RETURN
      END
      SUBROUTINE EXTRKO(XM,BP,EP,YM,IPAR,PAR)
C
C     INPUT: BP EP FI IPAR PAR IPA IPAA
C     OUTPUT:XM YM
C
C     XM	     POINT OF OPTIMUM
C     BP	     BEGINNING OF INTERVAL OF OPTIMIZATION
C     EP	     END OF INTERVAL OF OPTIMIZATION
C     YM	     OPTIMUM
C     IPAR(1)	     MAXIMAL ALLOWABLE NUMBER OF EVALUATIONS OF FI
C     IPAR(2)	     NUMBER OF EVALUATIONS OF FI FOR ESTIMATE OF MODEL'S
C		     PARAMETER
C     PAR(1)	    ACCURACY OF YM
C     PAR(2)	    ACCURACY OF XM
C
      COMMON/EXTR2/X2(506),Y2(506)
      COMMON /EXTR3/NS/EXTR9/N1
      COMMON /EXTR5/Y1(506)
      COMMON /EXTR6/X1(506)
      COMMON/IEXTR/IFAIL
      DOUBLE PRECISION EE1,EE2,EE3,DM17
      COMMON /EXTR1/A,YH,XJ1,XJ2,YJ1,YJ2
      DIMENSION IPAR(3),PAR(2)
      COMMON /EXTR4/XPA(20),YPA
      COMMON /INW/INW1/EXT10/P1,Y
C
      RMAX=R1MACH(2)
      RMAXS=SQRT(RMAX)
      RMAX=ALOG10(RMAX)
      K=IFIX(RMAX)+1
      E1=PAR(1)
      E2=PAR(2)
      N=IPAR(1)
      NE=IPAR(2)
      IPAR4=IPAR(3)
      NS=0
      N1=0
      K1=K/3
      CUND=-2.0*FLOAT(K)
      CP5=10.0**(K1-1)
      CP6=10.0*CP5
      CM6=1.0/CP6
      CM5=1.0/CP5
      DM17=10.0D0 **(-K+2)
      CM17=DM17
      IFAIL=0
      N2=NE+2
      A=AMIN1(BP,EP)
      EB=AMAX1(BP,EP)-A
      EB2=EB/25.0
      IF ((EB.GE.CM5).AND.(EB.LE.CP5)) GO TO 10
      IFAIL=10
      INW1=1
      RETURN
   10 DA=EB/FLOAT(NE-1)
      N6=NE+3
      DO 20 J=4,N6
      X1(J)=A
      NS=NS+1
      Y=G(A)
      N1=N1+1
      Y1(J)=Y
      IF (J.EQ.4) GO TO 16
      IF (YM.LE.Y) GO TO 17
   16 YM=Y
      XM=A
   17 CONTINUE
      IF (ABS(Y).GE.RMAXS) GO TO 262
   20 A=A+DA
      A=0.0
      YMAX=Y1(4)
C
C     A IS ESTIMATE OF PARAMETER OF WIENER PROCESS
C     (PARAMETER OF MODEL OF FUNCTION F)
C
      DO 30 J=5,N6
      Y=Y1(J)
      A=A+(Y-Y1(J-1))**2
      IF (YMAX.LT.Y) YMAX=Y
   30 CONTINUE
      YH=YM-(YMAX-YM)/2.
      A=SQRT(A/EB)*20.
      IF (A.GE.CM6.AND.A.LE.CP6) GO TO 40
      IFAIL=10
      INW1=2
      RETURN
C
C     A IS EVALUATED. N5 IS THE NUMBER OF LOCAL OPTIMA
C     COMPUTED WITH ACCURACY E1,E2
C
   40 N5=0
      E1=AMIN1(E1,A*SQRT(EB2)*0.1)
      P1=XPA(IPAR4  )
      P2=EB*0.001
      N3=N6
      DO 45 J=4,N3
      IF(P1.GT.X1(J+1)) GO TO 45
      IF(P1.LE.X1(J  )+P2 .OR. P1.GE.X1(J+1)-P2) GO TO 46
      DO 43 J1=J,N6
      J2=N6-J1+J+1
      X1(J2+1)=X1(J2)
      Y1(J2+1)=Y1(J2)
   43 CONTINUE
      NS=NS+1
      N2=N2+1
      N6=N6+1
      X1(J+1)=P1
      Y1(J+1)=YPA
      IF (YPA.GE.YM) GO TO 46
      YM=YPA
      XM=P1
      YH=YM-(YMAX-YM)/2.
      GO TO 46
   45 CONTINUE
   46 CONTINUE
      NP=N+6
      DO 50 J=1,NP
   50 Y2(J)=0.0
C
C     BAYESIAN STEP - FIND INTERVAL OF BIGGEST IMPROVEMENT (J)
C
   60 DO 70 J=4,N2
      IF(Y2(J).GT.0.0) GO TO 70
      XJ1=X1(J)
      XJ2=X1(J+1)
      YJ1=Y1(J)
      YJ2=Y1(J+1)
      Y2(J)=COR(X2(J))
   70 CONTINUE
   80 P1=Y2(4)
      J=4
      DO 90 N3=5,N2
      IF (Y2(N3).GE.P1) GO TO 90
      J=N3
      P1=Y2(N3)
   90 CONTINUE
      N4=NS-J+3
      DO 100 N3= 1,N4
      N7=NS+4-N3
      X1(N7+1)=X1(N7)
      Y1(N7+1)= Y1(N7)
      X2(N7)= X2(N7-1)
  100 Y2(N7)=Y2(N7-1)
      P1=X2(J)
       NS=NS+1
      Y=G(P1)
      IF(Y.GT.YMAX) YMAX=Y
      X1(J+1)=P1
      Y1(J+1)=Y
      N4=1
      IF (Y.GE.YM) GO TO 110
      YM=Y
      XM=P1
      N4= 2
  110 N1=N1+1
      IF (ABS(Y).GE.RMAXS) GO TO 262
      N2=NS+2
C
C     IF NUMBER OF EVALUATIONS OF F MORE THAN (N-1) GO TO END
C
      IF(N1.LT.N) GO TO 115
      IFAIL=1
      GO TO 360
C
C     P4 IS PROBABILITY OF EVALUATING
C     XM,YM WITH ACCURACY E1,E2
C
  115 P4=1
      DO 120 N3=4,N2
      IF (Y2(N3).GE.0.) GO TO 120
      P1=-800.*((Y1(N3)-YM+E1)/A)*((Y1(N3+1)-YM+E1)/A)/(X1(N3+1)-X1(N3))
      IF(P1.LE.CUND) GO TO 120
      P4=P4*(1.0-EXP(P1))
  120 CONTINUE
C
C     IF P4 MORE THAN 0.95, THEN
C     GO TO END OF EXTR
C
      YH=YM-(YMAX-YM)/2.
      IF (ABS(YM-Y).LT.R1MACH(1)*1.E+3) GO TO 130
      IF (P4.GE.0.95) GO TO 360
C
C     IF N5=0 A IS UPDATED IN EACH FIFTH STEP
C
      IF (MOD(NS,5).NE.0.OR.N5.GT.0) GO TO 160
  130 A=0.
      N4=2
      DO 150 N3=4,N2
  150 A=A+((Y1(N3+1)-Y1(N3))**2)/(X1(N3+1)-X1(N3))
      A=SQRT(A/FLOAT(NS-1))*20.
C
C     PREPARATION OF BOUNDS OF X1,Y1 FOR TESTING-
C     IS INTERVAL OF LOCAL OPTIMUM  FOUND
C
  160 X1(3)=(3.0*X1(4)-X1 (5))/2.0
      X1(1)=X1(3)
      X1(2)=X1(3)
      X1(NS+4)=(3.0*X1(NS+3)-X1(NS+2))/2.0
      X1(NS+5)=X1(NS+4)
      X1(NS+6)=X1(NS+4)
      NR=NS+3
      DO 170 N3=1,3
      Y1(N3)=Y1(5)
      NR3=NR+N3
  170 Y1(NR3)  =Y1(N2)
      N7=MAX0(1,J-5)
      N8=MIN0(NS,J+1)
C
C     TEST IF INTERVAL OF LOCAL OPTIMUM FOUND
C
      DO 180 N3=N7,N8
      IF ( Y1(N3).GE.Y1(N3+1).AND. Y1(N3+1).GE.Y1(N3+2)
     *.AND.Y1(N3+2).GT.Y1(N3+3).AND.Y1(N3+3).LT.Y1(N3+4)
     *.AND.Y1(N3+4).LE.Y1(N3+5).AND.Y1(N3+5).LE.Y1(N3+6)
     *.AND.(X1(N3+6)-X1(N3)).LE.(EB/5.0)) GO TO 200
  180 CONTINUE
      GO TO 310
C
C     BEGINING OF LOCAL OPTIMIZATION
C
  200 N6=N3+5
      DO 210 N7=N3,N6
  210 Y2(N7)=1.
      N3=N3+3
      N5=N5+1
      P3=X1(1)
      XL1=X1(N3-1)
      XL2=X1(N3)
      XL3=X1(N3+1)
      YL1=Y1(N3-1)
      YL2=Y1(N3)
      YL3=Y1(N3+1)
      N8=0
  220 EE1=DBLE(YL1-YL2)
      EE2=DBLE(XL1-XL2)
      IF (DABS(EE1).LE.DM17.OR.DABS(EE2).LE.DM17) GO TO 300
      EE3=DBLE(2.*(YL1-YL3))/EE1-DBLE(2.*(XL1-XL3))/EE2
      IF (DABS(EE3).LE.DM17) GO TO 300
      XA=(DBLE(XL1+XL2)*DBLE(YL1-YL3)/EE1-DBLE(XL1-XL3)*DBLE(XL1+XL3)/
     *EE2)/EE3
      EE3=DBLE(XL2-XA)
      EE2=DBLE(XL1-XA)
      IF (DABS(EE2).GE.DM17) GO TO 230
      P1=YL1
      GO TO 250
  230 EE3=1.0D0-(EE3/EE2)**2
      IF (DABS(EE3).GE.DM17) GO TO 240
      IF (EE1.LE.DABS(EE3)*1.0D6) GO TO 240
      P1=YL1-1.0E5
      GO TO 250
  240 EE1=EE1/EE3
      P1=YL1-EE1
  250 YA=G(XA)
      P3=ABS(XA-P3)
      IF (YA.GE.YM) GO TO 260
      YM=YA
      XM=XA
      YH=YM-(YMAX-YM)/2.
  260 N7=1
      N1=N1+1
      IF (N1.LT.N) GO TO 261
      IFAIL=1
      GO TO 360
  261 CONTINUE
      IF (ABS(YA).LT.RMAXS) GO TO 251
      A=XA
      Y=YA
  262 INW1=3
      P1=A
      IFAIL=10
      RETURN
  251 CONTINUE
      IF (XA.GT.XL2) N7=2
      P2=ABS(P1-YA)
      IF((P2.LE.E1.AND.P3.LE.E2).OR.P2.LE.CM17.OR.P3.LE.CM17)GO TO 300
      IF (YA.GE.YL2) GO TO 280
      IF (N7.EQ.1) GO TO 270
      XL1=XL2
      YL1=YL2
      XL2=XA
      YL2=YA
  265 IF (N3.EQ.NS+3.AND.N8.EQ.0) GO TO 267
      N8=1
      GO TO 290
  267 XL3=(3.*XL2-XL1)/2.
      YL3=YL1
      GO TO 290
  270 XL3=XL2
      YL3=YL2
      XL2=XA
      YL2=YA
  275 IF (N3.EQ.4.AND.N8.EQ.0) GO TO 277
      N8=1
      GO TO 290
  277 XL1=(3.*XL2-XL3)/2.
      YL1=YL3
      GO TO 290
  280 IF (N7.EQ.1) GO TO 285
      XL3=XA
      YL3=YA
      GO TO 275
  285 XL1=XA
      YL1=YA
      GO TO 265
  290 P3=XA
      GO TO 220
  300 X1(N3)=XA
      Y1(N3)=YA
  305 N4=2
  310 CONTINUE
      IF(N4.EQ.2) GO TO 60
      N7=J+1
      DO 330 N3=J,N7
      XJ1=X1(N3)
      XJ2=X1(N3+1)
      YJ1=Y1(N3)
      YJ2=Y1(N3+1)
      IF((XJ2-XJ1).LT.EB2.AND.Y2(N3-1).GT.0.0.AND.
     *YJ1.LT.YJ2) GO TO 320
      Y2(N3)=COR(X2(N3))
      GO TO 330
  320 Y2(N3)=1.
  330 CONTINUE
      IF (Y2(N7+1).GT.0.0.AND.Y1(N7).GT.Y1(N7+1).AND.
     *(X1(N7+1)-X1(N7)).LT.EB2) Y2(N7)=1.0
      IF( Y2(N7).GT.0.0 .AND. Y1(N7-1).GT.Y1(N7).AND.
     *(X1(N7)-X1(N7-1)).LT.EB2) Y2(N7-1)=1.0
      GO TO 80
  360 CONTINUE
       RETURN
      END
      FUNCTION G(X)
      COMMON/EXK1/K,NEX
      COMMON /EXTR4/XPA(20),YPA
      DIMENSION XP (20)
      DO 1 J=1,NEX
    1 XP(J)=XPA(J)
      XP(K)=X
      G1=FI(XP,NEX)
      G=G1
      RETURN
      END
      SUBROUTINE SPAU13(X,N,FM,IPR)
      COMMON/INW/IN/STATIS/IFAULT,J4,ITM,NF/EXTR9/N1/SP13/K1,K2/IEXTR/
     CIFAIL
      DIMENSION X(N)
      NOUT=I1MACH(2)
      IF(IN.GT.100) GOTO 10
      WRITE(NOUT,100)
      IF(J4.EQ.IPR) WRITE(NOUT,210)
      WRITE(NOUT,280) K1,K2
      WRITE(NOUT,290) N1
      WRITE(NOUT,300) IFAIL
      WRITE(NOUT,150) FM
      WRITE(NOUT,160)
      WRITE(NOUT,130) (X(I),I=1,N)
      WRITE (NOUT,190) NF
      RETURN
  10  WRITE(NOUT,170)
      WRITE(NOUT,180)
      WRITE(NOUT,150) FM
      WRITE(NOUT,160)
      WRITE(NOUT,130) (X(I),I=1,N)
      WRITE(NOUT,190) NF
      WRITE(NOUT,310)
      WRITE(NOUT,170)
      RETURN
  100 FORMAT (/1X,34(2H -))
  130 FORMAT(4(2X,E15.8))
  150 FORMAT (/2X,28HOPTIMAL FUNCTION VALUE FM = ,E15.8)
  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 -))
  280 FORMAT(2X,20HNUMBER OF CYCLE K1 =,I3,3X,
     C23HNUMBER OF VARIABLE K2 =,I3)
  290 FORMAT (2X,60HNUMBER OF FUNCTION EVALUATIONS IN ONEDIMENSIONAL SEA
     CRCH N1 =,I6)
  300 FORMAT(2X,23HSUBROUTINE EXTR IFAIL =,I2)
  310 FORMAT(/7X,16HEXKOR TERMINATED)
      END
      SUBROUTINE INWR13(X,A,B,N,FM,IPAR,PAR,IPA,IPAA)
      DIMENSION X(N),A(N),B(N)
      DIMENSION IPAR(30),PAR(30)
      COMMON /INW/INW1/STATIS/IFAIL,IT,ITM,NFUN/EXK1/J2,NEX
      MN=20
      MIP=30
      MM=500
      MIM=6
      K=5
      K1=N+1
      NOUT=I1MACH(2)
      GO TO (1,2,7,3),INW1
    1 WRITE (NOUT,750) J2
      IF (IPAR(IPA+1).GE.0) RETURN
    6 WRITE (NOUT,570)
      WRITE (NOUT,580) A
      WRITE (NOUT,590)
      WRITE (NOUT,580) B
      RETURN
    2 WRITE (NOUT,760) J2
      IF (IPAR(IPA+1).GE.0) RETURN
      LT=IPAR(IPA+3)
      WRITE (NOUT,660) LT
      GO TO 6
    7 WRITE (NOUT,860) FM
      WRITE (NOUT,580) X
      RETURN
    3 CONTINUE
      IF (IPA.GE.0.AND.IPA+K.LE.MIP) GO TO 4
      WRITE (NOUT,520) K,MIP
      WRITE (NOUT,510) IPA
    5 IFAIL=10
      RETURN
    4 CONTINUE
      IPRINT=IPAR(IPA+1)
      IF (IPRINT.LT.0) GO TO 110
      WRITE (NOUT,770)
      WRITE (NOUT,620)
      WRITE (NOUT,630) N
  110 IF (N.GT.0.AND.N.LE.MN) GO TO 10
      WRITE (NOUT,500) MN
      IF (IPRINT.LT.0) WRITE (NOUT,630) N
      GO TO 5
   10 CONTINUE
      M=IPAR(IPA+2)
      LT=IPAR(IPA+3)
      KC=IPAR(IPA+4)
      NO=IPAR(IPA+5)
      IF (IPRINT.LT.0) GO TO 40
      WRITE (NOUT,640) IPRINT
      WRITE (NOUT,650) M
      WRITE (NOUT,660) LT
      WRITE (NOUT,780) KC
      WRITE (NOUT,790) NO
   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 CONTINUE
      IF (LT.GE.MIM.AND.LT.LE.M) GO TO 80
      WRITE (NOUT,550) MIM
      IF (IPRINT.GE.0) GO TO 5
      WRITE (NOUT,650) M
      WRITE (NOUT,660) LT
      GO TO 5
   80 CONTINUE
      IF (NO.GE.1.AND.NO.LE.N) GO TO 120
      WRITE (NOUT,800)
      IF (IPRINT.GE.0) GO TO 5
      WRITE (NOUT,630) N
      WRITE (NOUT,790) NO
      GO TO 5
  120 CONTINUE
      IF (IPAA.GE.0.AND.IPAA+K1.LE.MIP) GO TO 240
      WRITE (NOUT,710) K1,MIP
      WRITE (NOUT,700) IPAA
      GO TO 5
  240 E1=PAR(IPAA+1)
      IF (IPRINT.LT.0) GO TO 200
      WRITE (NOUT,720) E1
      J=IPAA+2
      J1=IPAA+N+1
      WRITE (NOUT,810)
      WRITE (NOUT,580) (PAR(I),I=J,J1)
      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
      NER1=0
      DO 90 I=1,N
      IF (A(I).LT.B(I)) GO TO 90
      IF (A(I).NE.B(I)) GO TO 81
      NER1=NER1+1
      GO TO 90
   81 CONTINUE
      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.EQ.0) GO TO 100
   97 IF (IPRINT.GE.0) GO TO 5
      WRITE (NOUT,570)
      WRITE (NOUT,580) (A(I),I=1,N)
      WRITE (NOUT,590)
      WRITE (NOUT,580) (B(I),I=1,N)
      GO TO 5
  100 CONTINUE
      IF (NER1.NE.N) GO TO 130
      WRITE (NOUT,607)
      GO TO 97
  130 CONTINUE
      IF (IPRINT.LT.0) GO TO 260
      WRITE (NOUT,820)
      WRITE (NOUT,580) (X(I),I=1,N)
  260 NER=0
      DO 270 I=1,N
      IF (X(I).LE.B(I).AND.X(I).GE.A(I)) GO TO 270
      WRITE (NOUT,830) I,I,I,I
      NER=1
  270 CONTINUE
      IF (NER.EQ.0) GO TO 300
      IF (IPRINT.GE.0) GO TO 5
      WRITE (NOUT,570)
      WRITE (NOUT,580) (A(I),I=1,N)
      WRITE (NOUT,590)
      WRITE (NOUT,580) (B(I),I=1,N)
      WRITE (NOUT,820)
      WRITE (NOUT,580) (X(I),I=1,N)
      GO TO 5
  300 CONTINUE
      FM=FI(X,N)
      IF (IPRINT.GE.0) WRITE (NOUT,850) FM
      RETURN
  500 FORMAT (/2X,61H**E R R O R  I N  E X K O R** N LESS THAN 1 OR N GR
     CEATER THAN,I3)
  510 FORMAT (/2X,26HNUMBER OF PARAMETERS IPA =,I6)
  520 FORMAT (/2X,45H**E R R O R  I N  E X K O R** IPA LESS THAN 0/2X,
     C7HOR IPA+,I2,13H GREATER THAN,I3)
  530 FORMAT (/2X,43H**E R R O R  I N  E X K O R** M LESS THAN 1/2X,
     C17HOR M GREATER THAN,I6/)
  550 FORMAT (/2X,42H**E R R O R  I N  E X K O R** LT LESS THAN,I3/2X,
     C20HOR LT GREATER THAN 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,32H**E R R O R  I N  E X K O R** A(,I2,17H) GREATER TH
     CAN B(,I2,1H))
  605 FORMAT (32X,2HA(,I2,17H) GREATER THAN B(,I2,1H))
  607 FORMAT (/2X,55H**E R R O R  I N  E X K O R** VECTORS A AND B ARE E
     CQUAL)
  620 FORMAT (/2X,22HI N I T I A L  D A T A)
  630 FORMAT (/2X,19HNUMBER OF VARIABLES,39X,3HN =,I6)
  640 FORMAT (/2X,18HPRINTING PARAMETER,38X,5HIPR =,I6)
  650 FORMAT (2X,54HMAXIMUM NUMBER OF FUNCTION EVALUATIONS IN ONEDIMENSI
     CO-/2X,10HNAL SEARCH,48X,3HM =,I6)
  660 FORMAT (2X,55HNUMBER OF FUNCTION EVALUATIONS FOR PARAMETER ESTIMAT
     CION/2X,24HIN ONEDIMENSIONAL SEARCH,33X,4HLT =,I6)
  700 FORMAT (/2X,27HNUMBER OF PARAMETERS IPAA =,I3)
  710 FORMAT (/2X,46H**E R R O R  I N  E X K O R** IPAA LESS THAN 0/2X,
     C8HOR IPAA+,I2,13H GREATER THAN,I3)
  720 FORMAT (/2X,41HACCURACY OF OPTIMAL FUNCTION VALUE EPS1 =,E15.8)
  750 FORMAT (/2X,43H**E R R O R  I N  E X K O R** BOUNDS FOR X(,I2,
     C5H) ARE/2X,22HTOO SMALL OR TOO LARGE)
  760 FORMAT (/2X,64H**E R R O R  I N  E X K O R** VARIATION OF FUNCTION
     C IS TOO SMALL/2X,57HOR TOO LARGE. TRY TO CHANGE LT TO LT*2+1 OR BO
     CUNDS FOR X(,I2,1H)/)
  770 FORMAT (////12X,9HE X K O R)
  780 FORMAT (2X,16HNUMBER OF CYCLES,41X,4HKC =,I6)
  790 FORMAT (2X,42HNUMBER OF FIRST COORDINATE TO BE OPTIMIZED,15X,
     C4HNO =,I6)
  800 FORMAT (/2X,65H**E R R O R  I N  E X K O R** NO LESS THAN 1 OR NO
     CGREATER THAN N)
  810 FORMAT (2X,25HACCURACY OF OPTIMAL POINT)
  820 FORMAT (/2X,14HSTARTING POINT)
  830 FORMAT (/2X,32H**E R R O R  I N  E X K O R** X(,I2,17H) GREATER TH
     CAN B(,I2,1H)/2X,5HOR X(,I2,14H) LESS THAN A(,I2,1H))
  850 FORMAT (2X,19HFUNCTION VALUE F = ,E15.8)
  860 FORMAT (/2X,54H**E R R O R  I N  E X K O R** TOO LARGE FUNCTION VA
     CLUE//2X,3HF =,E15.8,2X,3HX =)
      END
      FUNCTION COR(X)
      COMMON /EXTR1/C,YH,XJ1,XJ2,YJ1,YJ2
      X=(XJ1+XJ2)/2.+(XJ2-XJ1)*(YJ1-YJ2)*0.5 /(YJ1+YJ2-2.*YH)
      AM=((XJ2-X)*YJ1+(X-XJ1)*YJ2)/(XJ2-XJ1)
      D=SQRT((XJ2-X)*(X-XJ1)/(XJ2-XJ1))*C
      COR=-ALNORM((YH-AM)/D,.FALSE.)
      RETURN
      END
      FUNCTION ALNORM(X,UPPER)
      REAL LTONE,UTZERO,ZERO,HALF,ONE,CON,Z,Y,X
      LOGICAL UPPER,UP
      DATA  LTONE/7.0/, UTZERO/18.66/
      DATA  ZERO/0./, HALF/0.5/, ONE/1./, CON/1.28/
      UP=UPPER
      Z=X
      IF (Z.GE.ZERO) GO TO 10
      UP= .NOT.UP
      Z=-Z
   10 IF (Z.LE.LTONE.OR.UP.AND.Z.LE.UTZERO) GO TO 20
      ALNORM=ZERO
      GO TO 40
   20 Y=HALF*Z*Z
      IF (Z.GT.CON) GO TO 30
      ALNORM=HALF-Z*(0.398942280444-0.399903438504*Y/(Y+5.75885480458-
     129.8213557808/(Y+2.62433121679+48.6959930692/(Y+5.92885724438))))
      GO TO 40
   30 ALNORM=0.398942280385*EXP(-Y)/(Z-3.8052E-8+1.00000615302/(Z+
     13.98064794E-4+1.98615381364/(Z-0.151679116635+5.29330324926/
     2(Z+4.8385912808-15.1508972451/(Z+0.742380924027+30.789933034/
     3(Z+3.99019417011))))))
   40 IF (.NOT.UP) ALNORM=ONE-ALNORM
      RETURN
      END
