C            *****************************************************
C            *                                                   *
C            *     TEST WHETSTONE mesuarements                   *
C            *                                                   *
C            *****************************************************
C
C   COMPUTER       COMPILER         N     MILLION      TIME     SPEED
C                                         WHETSTONE    (SEC)   MIL/S, TH/S
C
C* Silicon Graphics (R4400/R4010)
C*              (fl -O3)       5000       500.           5.3    94.3     M/S
C* DECstation 5000-33 (fl -O4)      5000       500.          17.7    28.2     M/S
C* DECstation 5000/200             500      50.        2.25   22.2     M/S
C  IBM 3090-400                    500      50.        2.55   19.6     M/S
C* Silicon Graphics (R3000 20 MHz)
C                    (f77 /O4)       500      50.        2.66   18.8     M/S
C* VAXstation 4000-60              500      50.        4.15   12.0     M/S
C* VAXstation 3100/76              500      50.        7.94    7.95    M/S
C  VAX 8880                        500      50.       10.04    5.      M/S
C* MICROVAX 3500                   500      50.       16.9     2.96    M/S
C  MICROVAX II                     500      50.       60.      0.830   M/S
C* CM-1700 (VAX-11/730)            500      50.      169.      0.296   M/S
C  NORD 570/CX                     500      50.       15.8     3.2     M/S
C
C  IBM PC clone:
C    compiler:  FL - MS-FORTRAN v5.1,  FL /Ox/G2 
C           NDP- NDP486, MF486 -n2 -n3 -on 
C           F32- MS-FORTRAN-32, -Ox
C
C* Pentium-166MMX, (430HX, 512 kb)
C            F32       5000     500.       5.16    96.9     M/S
C* Pentium-100, (Zappa, 0 kb) NDP 5000     500.       8.51    58.8     M/S
C* Pentium-100, (Zappa, 0 kb) FL  5000     500.      22.6     22,1     M/S
C* Pentium-66,(Batman, 256 kb)NDP 1000     100.       2.75    36.4     M/S
C* Pentium-66,(Batman, 256 kb) FL  500      50.       3.63    13.78    M/S
C* AMD486DX2-80,(256 kb), NDP     5000     500.      24.9     20.1     M/S
C* AMD486DX2-80,(256 kb), FL      5000     500.      50.9      9.8     M/S
C* i486DX2-66, (0 kb), NDP        5000     500.      30.2     16.6     M/S
C* i486DX2-66, (0 kb), FL         5000     500.      65.3      7.66    M/S
C* i486DX2-66, (256 kb), FL        500      50.       6.59     7.58    M/S
C* i486DX2-66, (128 kb), FL        500      50.       6.59     7.58    M/S
C* Cx486DX-40, (256 kb), NDP      1000     100.       9.17    10.9     M/S
C* Cx486DX-40, (256 kb), FL       1000     100.       18.8     5.32    M/S
C* Cx486DX-33, (256 kb), NDP      1000     100.       11.0     9.06    M/S
C* Cx486DX-33, (256 kb), FL       1000     100.       22.6     4.42    M/S
C* i486DX-33, (0 kb), NDP         1000     100.       15.1     6.62    M/S
C* i486DX-33, (0 kb), FL          1000     100.       26.3     3.80    M/S
C* AMD386DX-40,(128 kb,IIT 4C387),
C             NDP486   1000     100.       25.4     3.93    M/S
C* AMD386DX-40,(128 kb,IIT 4C387),
C                        FL       1000     100.       45.1     2.21    M/S
C* 386SX-33 (IIT387sx-33), NDP    1000     100.       34.9     2.87    M/S
C* 386SX-33 (IIT387sx-33), FL     1000     100.       69.3     1.44    M/S
C* 386SX-33 (emulator Q387_33),FL  500      50.      360.       139    T/S
C* i286/287-12, FL 5.0 
C    --/--           FL /FPI87/G2  500      50.      245.        205   T/S
C
C* electronika-79    F77/NOTR      500      50.       77.7       640   T/S
C* MC-1212 M8        F77/NOTR      500      50.      300.        167   T/S
C* sm-4              FOR/NOSN      500      50.      763.         66   T/S
C* MC-1212 M6        F77/NOTR      500      50.      946.         53   T/S
C* electronika-100/25
C   ozu-256K         FOR/NOSN      500      50.     1060.         47   T/S
C* electronika-60 M2 FOR/NOSN      500      50.     1730.         29   T/S
C
C
C* EC-1061           FOR4          500      50.       53.0     0.940   M/S
C* EC-1061           FOR77 O1      500      50.       41.0     1.200   M/S
C* EC-1061           FOR77 O2      500      50.       35.0     1.400   M/S
C* EC-1061           FOR77 O3      500      50.       33.0     1.500   M/S
C* EC-1061           FOR77 O4      500      50.       33.0     1.500   M/S
C
C
C  BESM-6       fortran-gdr        500      50.       159.3    0.314   M/S
C  BESM-6       fortran-dubna      500      50.       149.1    0.335   M/S
C  BESM-6       fortran-foreks     500      50.       109.8    0.459   M/S
C  ELBRUS                                   50.       118.0    0.423   M/S
C
      PROGRAM BENCH
      COMMON T,T1,T2,E1(4),J,K,L
      DIMENSION TIME(9)
      DATA LUNOUT/6/

      WRITE(LUNOUT,300)
300     FORMAT(' **** TEST WHETSTONE ****')
C       -------
      TIME(1)=CPU()
      T=0.499975
      T1=0.50025
      T2=2.0
C       -----
      N=5000   !500 mln. WHETSTONE
C       -----
      N1=0
      N2=12
      N3=14
      N4=345
      N5=0
      N6=210
      N7=32
      N8=899
      N9=616
      N10=0
      N11=93
C
C       1-SIMPLE IDENTIFIERS
C       X1=1.0
C       X2=-1.0
C       X3=-1.0
C       X4=-1.0
C
C       DO 1 I=1,N1
C       DO 1 M=1,N
C
C       X1=(X1+X2+X3-X4)*T
C       X2=(X1+X2-X3+X4)*T
C       X3=(X1-X2+X3+X4)*T
C       X4=(-X1+X2+X3+X4)*T
C1       CONTINUE
C       TIME(1)=CPU()
C
C       2-ARRAY ELEMENTS (12)
C
      E1(1)=1.0
      E1(2)=-1.0
      E1(3)=-1.0
      E1(4)=-1.0
      DO 2 I=1,N2
      DO 2 M=1,N
      E1(1)=(E1(1)+E1(2)+E1(3)-E1(4))*T
      E1(2)=(E1(1)+E1(2)-E1(3)+E1(4))*T
      E1(3)=(E1(1)-E1(2)+E1(3)+E1(4))*T
      E1(4)=(-E1(1)+E1(2)+E1(3)+E1(4))*T
2       CONTINUE
      TIME(2)=CPU()
C
C       3-ARRAY AS PARAMETER (14)
C
      DO 3 I=1,N3
      DO 3 M=1,N
      CALL PA(E1)
3       CONTINUE
      TIME(3)=CPU()
C
C       4-CONDITIONAL JUMPS (345)
C
      J=1
      DO 4 I=1,N4
      DO 4 M=1,N
      IF (J-1) 42,41,42
41      J=2
      GOTO 43
42      J=3
43      IF (J-2) 45,45,44
44      J=0
      GOTO 46
45      J=1
46      IF (J-1) 47,48,48
47      J=1
      GOTO 4
48      J=0
4       CONTINUE

C       IF(J.EQ.1) THEN
C         J=2
C       ELSE
C         J=3
C       ENDIF
C       IF(J.GT.2) THEN
C         J=0
C       ELSE
C         J=1
C       ENDIF
C       IF(J.LT.1) THEN
C         J=1
C       ELSE
C         J=0
C       ENDIF

      TIME(4)=CPU()
C
C       6-INTEGER ARITHMETIC (210)
C
      J=1
      K=2
      L=3
      DO 6 I=1,N6
      DO 6 M=1,N
      J=J*(K-J)*(L-K)
      K=L*K-(L-J)*K
      L=(L-K)*(K+J)
      E1(L-1)=J+K+L
      E1(K-1)=J*K*L
6       CONTINUE
      TIME(5)=CPU()
C
C       7-TRIG. FUNCTIONS (32)
C
      X=0.5
      Y=0.5
      DO 7 I=1,N7
      DO 7 M=1,N
      X=T*ATAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0))
      Y=T*ATAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0))
7       CONTINUE
      TIME(6)=CPU()
C
C       8-PROCEDURE CALLS (899)
C
      X=0.99995
      Y=1.00005
C       X=1.0   ???
C       Y=1.0   ???
      Z=1.0
      DO 8 I=1,N8
      DO 8 M=1,N
      CALL P3(X,Y,Z)
8       CONTINUE
      TIME(7)=CPU()
C
C       9-ARRAY REFERENCE (616)
C
      J=1
      K=2
      L=3
      E1(1)=1.0
      E1(2)=2.0
      E1(3)=3.0
      DO 9 I=1,N9
      DO 9 M=1,N
      CALL P0
9       CONTINUE
      TIME(8)=CPU()
C
C       10-INTEGER ARITHMETIC (0)
C

C
C       11-STANDART FUNCTIONS (93)
C
      X=0.75
      DO 11 I=1,N11
      DO 11 M=1,N
      X=SQRT(EXP(ALOG(X)/T1))
11      CONTINUE
      TIME(9)=CPU()
C       -----
      TIM=(TIME(9)-TIME(1))
      DO 100 I=1,8
100     TIME(I)=(TIME(I+1)-TIME(I))

C --- OUTPUT REZALT

      WRITE(LUNOUT,200) TIM ,INT(TIM/60.),AMOD(TIM,60.)
200     FORMAT(' TOTAL TIME - ',F8.3,' SEC.  (',I3,' MIN. ', 
     *         F4.1,' SEC.)')
      WH=0.1*N
      SPEED=WH/TIM
      IF(SPEED.GE.1.0) GOTO 110
      WRITE(LUNOUT,204) WH,SPEED*1000.
204      FORMAT(' ',F8.1,' MILLION WHETSTONE, ',F9.3,
     *         ' THOUSAND WHETSTONE/SEC')
      GOTO 120
110      WRITE(LUNOUT,205) WH,SPEED
205      FORMAT(' ',F8.1,' MILLION WHETSTONE, ',F9.3,
     *          ' MILLION WHETSTONE/SEC')
120     WRITE(LUNOUT,210) ( TIME(I),TIME(I)*100./TIM, I=1,8)
210     FORMAT(' ARRAY ELEMENTS..........',F8.2,4X,F5.1,'%',/
     *         ' ARRAY AS PARAMETER......',F8.2,4X,F5.1,'%',/
     *         ' CONDITIONAL JUMPS.......',F8.2,4X,F5.1,'%',/
     *         ' INTEGER ARITHMETIC......',F8.2,4X,F5.1,'%',/
     *         ' TRIG. FUNCTIONS.........',F8.2,4X,F5.1,'%',/
     *         ' PROCEDURE CALLS.........',F8.2,4X,F5.1,'%',/
     *         ' ARRAY REFERENCE.........',F8.2,4X,F5.1,'%',/
     *         ' STANDART FUNCTIONS......',F8.2,4X,F5.1,'%')    
      STOP
      END
C
C
      SUBROUTINE PA(E)
      COMMON T,T1,T2,E1(4),J,K,L
      DIMENSION E(4)
      J=0
100     E(1)=(E(1)+E(2)+E(3)-E(4))*T
      E(2)=(E(1)+E(2)-E(3)+E(4))*T
      E(3)=(E(1)-E(2)+E(3)+E(4))*T
      E(1)=(-E(1)+E(2)+E(3)+E(4))/T2
      J=J+1
      IF (J.LT.6) GOTO 100
      RETURN
      END
C
C
      SUBROUTINE P0
      COMMON T,T1,T2,E1(4),J,K,L
      E1(J)=E1(K)
      E1(K)=E1(L)     
      E1(L)=E1(J)     
      RETURN
      END
C
C
      SUBROUTINE P3(X,Y,Z)
      COMMON T,T1,T2,E1(4),J,K,L
      X=T*(X+Y)
      Y=T*(X+Y)+0.0001
      Z=(Y-X)/T2
      RETURN
      END
C
C
C
      FUNCTION CPU()
      CPU=SECNDS(0.)
      RETURN
      END


