                                     170
C BEGINNING OF MODULE 7, TRIG. FUNCTIONS                                     171
C                                                                            172
        X = 0.5                                                              173
        Y = 0.5                                                              174
        IF(N7)79,79,71                                                       175
71      DO 78 I = 1,N7,1                                                     176
           X = T*ATAN(T2*SIN(X)*COS(X)/(COS(X+Y)+COS(X-Y)-1.0))              177
           Y = T*ATAN(T2*SIN(Y)*COS(Y)/(COS(X+Y)+COS(X-Y)-1.0))              178
78      CONTINUE                                                             179
C                                                                            180
79      CONTINUE                                                             181
        IF(JJ.EQ.LOOP) CALL POUT (N7,J,K,X,X,Y,Y)                            182
C                                                                            183
C BEGINNING OF MODULE 8, PROCEDURE CALLS                                     184
C                                                                            185
        X = 1.0                                                              186
        Y = 1.0                                                              187
        Z = 1.0                                                              188
        IF(N8)89,89,81                                                       189
81      DO 88 I = 1,N8,1                                                     190
88      CALL P3 (X,Y,Z)                                                      191
C                                                                            192
89      CONTINUE                                                             193
        IF(JJ.EQ.LOOP) CALL POUT (N8,J,K,X,Y,Z,Z)                            194
C                                                                            195
C BEGINNING OF MODULE 9, ARRAY REFERENCES                                    196
C                                                                            197
        J = 1                                                                198
        K = 2                                                                199
        L = 3                                                                200
        E1(1) = 1.0                                                          201
        E1(2) = 2.0                                                          202
        E1(3) = 3.0                                                          203
        IF(N9)99,99,91                                                       204
91      DO 98 I = 1,N9,1                                                     205
98      CALL P0                                                              206
C                                                                            207
99      CONTINUE                                                             208
        IF(JJ.EQ.LOOP) CALL POUT (N9,J,K,E1(1),E1(2),E1(3),E1(4))            209
C                                                                            210
C BEGINNING OF MODULE 10, INTEGER ARITHMETIC                                 211
C                                                                            212
        J = 2                                                                213
        K = 3                                                                214
        IF(N10)109,109,101                                                   215
101     DO 108 I = 1,N10,1                                                   216
           J = J+K                                                           217
           K = J+K                                                           218
           J = K-J                                                           219
           K = K-J-J                                                         220
108     CONTINUE                                                             221
C                                                                            222
109     CONTINUE                                                             223
        IF(JJ.EQ.LOOP) CALL POUT (N10,J,K,X1,X2,X3,X4)                       224
C                                                                            225
C BEGINNING OF MODULE 11, STANDARD FUNCTIONS                                 226
C                                                                            227
        X = 0.75                                                             228
        IF(N11)119,119,111                                                   229
111     DO 118 I = 1,N11,1                                                   230
118     X = SQRT(EXP(ALOG(X)/T1))                                            231
C                                                                            232
119     CONTINUE                                                             233
        IF(JJ.EQ.LOOP) CALL POUT (N11,J,K,X,X,X,X)                           234
C                                                                            235
C THERE IS NO MODULE 12                                                      236
C                                                                            237
C THIS IS THE END OF THE MAJOR LOOP                                          238
 500  CONTINUE                                                               239
C------------------------------------------------------------                240
C  USER  SHALL MODIFY THIS TO SET "TTIME" TO TOTAL AMOUNT OF                 241
C ELAPSED TIME SINCE "STIME" IN SECONDS.                                     242
C-------------------------------------------------------------               248
	TTIME=SECNDS(STIME)
C LLL MODIFICATION TO PRINT TOTAL ELAPSED TIME OF BENCHMARK                  249
      ETIME = TTIME/60.0                                                     250
      WRITE(NTTY,1000)ETIME                                                  251
1000  FORMAT(' BENCHMARK 1 EXECUTION TIME IS ',F8.4,' MINUTES')              252
C--------------------------------------------------------------              253
C COMPUTE WHETSTONE IPS RATE
C                                                                            255
	WHETS = (1/TTIME)*LOOP*1000
	WRITE(NTTY,999) WHETS
999	FORMAT(' RATE IS ',F8.0,' THOUSAND ',
	2 'SINGLE PRECISION WHETSTONE INSTRUCTIONS PER SECOND')
        STOP                                                                 258
        END                                                                  259
C===========================================================                 260
        SUBROUTINE P0                                                        261
        COMMON T,T1,T2,E1(4),J,K,L                                           262
        E1(J) = E1(K)                                                        263
        E1(K) = E1(L)                                                        264
        E1(L) = E1(J)                                                        265
        RETURN                                                               266
        END                                                                  267
C===========================================================                 268
        SUBROUTINE P3 (X,Y,Z)                                                269
        COMMON T,T1,T2                                                       270
        X1 = X                                                               271
        Y1 = Y                                                               272
        X1 = T*(X1+Y1)                                                       273
        Y1 = T*(X1+Y1)                                                       274
        Z = (X1+Y1)/T2                                                       275
        RETURN                                                               276
        END                                                                  277
C===========================================================                 278
        SUBROUTINE POUT (N,J,K,X1,X2,X3,X4)                                  279
        WRITE(6,1) N,J,K,X1,X2,X3,X4                                         280
1       FORMAT(1H ,3I7,4E12.4)                                               281
        RETURN                                                               282
        END                                                                  283
C===========================================================                 284
        SUBROUTINE PA (E)                                                    285
        COMMON T,T1,T2                                                       286
        DIMENSION E(4)                                                       287
        J = 0                                                                288
1       E(1) = (E(1)+E(2)+E(3)-E(4))*T                                       289
        E(2) = (E(1)+E(2)-E(3)+E(4))*T                                       290
        E(3) = (E(1)-E(2)+E(3)+E(4))*T                                       291
        E(4) = (-E(1)+E(2)+E(3)+E(4))/T2                                     292
        J = J+1                                                              293
        IF(J-6)1,2,2                                                         294
2       CONTINUE                                                             295
        RETURN                                                               296
        END                                                                  297

C BENCHMARK CCA1, WHETSTONE
C   BENCHMARK  = SYNTH FORS IN NPL REPORT NAC 62
C--------------------------------------------------------
C LAWRENCE LIVERMORE LAB. MODIFICATION OF WHETSTONE BENCHMARK
C MODIFIED FOR AUTOMATIC TIMING OF BENCHMARK
C  USER  SHALL MODIFY THIS PROGRAM IN THE AREAS INDICATED
C TO PROVIDE AUTOMATIC TIMING. (SEE BELOW)
C  USER  SHALL RUN THIS BENCHMARK TWICE,
C ONCE WITH LOGICAL UNIT 6 SET TO A NULL DEVICE
C AND ONCE WITH LOGICAL UNIT 6 SET TO A PRINTING DEVICE.
C LOGICAL UNIT 7 SHALL ALWAYS BE SET TO A PRINTING DEVICE.
C--------------------------------------------------------
C WHETSTONE BENCHMARK TEST 1
C
C VERSION 3  OCT. 17, 1977
C
C REFERENCE:
C   THE DESIGN OF SYNTHETIC PROGRAMS I, BRIAN A. WICHMANN
C   BENCHMARKING; COMPUTER EVALUATION AND MEASUREMENT,
C   JOHN WILEY & SON, NEW YORK 1975, PP 89-98
C
C   THE DESIGN OF SYNTHETIC, PROGRAMS II, HARRY J. CURNOW
C   BENCHMARKING; COMPUTER EVALUATION AND MEASUREMENT,
C   JOHN WILEY & SON, NEW YORK 1975, PP 99-114
C
C   A SYNTHETIC BENCHMARK, H. J. CURNOW AND B. A. WICHMANN,
C   A COMPUTER JOURNAL, VOL. 19, NUMBER 1.
C
C------------------------------------------------------------
C THIS PROGRAM HAS A SINGLE PARAMETER LOOP
C SET LOOP=1 FOR 1,000,000 WHETSTONE INSTRUCTIONS
C SET LOOP=10 FOR 10,000,000 WHETSTONE INSTRUCTIONS
C SET LOOP=26 FOR ONE MINUTE ON MACHINE OF POWER OF 360/65
C SET LOOP=3 FOR MACHINE 1/10 POWER OF 360/65
C SET LOOP=257 FOR MACHINE TEN TIMES POWER OF 360/65
C
C MAIN PROGRAM
      COMMON T,T1,T2,E1(4),J,K,L
C------------------------------------------------------------
C  USER  SHALL MODIFY THIS TO SET "STIME" TO A REFERENCE TIME
C IN SECONDS (ACCURATE TO AT LEAST ONE SECOND).
C-------------------------------------------------------------
	STIME=SECNDS(0.0)
1     T = 0.499975
      T1 = 0.50025
      T2 = 2.0
C
C     SET NTTY FOR TERMINAL OUTPUT DEVICE NUMBER
      NTTY = 7
C
C IF LOOP = 10 THEN THIS COORESPONDS TO THE EXECUTION OF
C 10 TIMES  1,000,000 WHETSTONE INSTRUCTIONS.
C
      LOOP = 100
C
C I=10 COORESPONDS TO 1,000,000 WHETSTONE INSTRUCTIONS PER MAJOR LOOP
      I = 10
C
C ESTABLISH MODULE EXECUTION TIME PARAMETERS
      N1 = 0
      N2 = 12*I
      N3 = 14*I
      N4 = 345*I
      N5 = 0
      N6 = 210*I
      N7 = 32*I
      N8 = 899*I
      N9 = 616*I
      N10 = 0
      N11 = 93*I
      N12 = 0
C
C BEGINNING OF MAJOR LOOP
C WE HAVE THIS MAJOR LOOP RATHER THAN USING A BIGGER I BECAUSE
C A LARGE I (GREATER THAN 36) WILL OVERFLOW ON A 16 BIT MACHINE.
C
      DO 500  JJ = 1,LOOP
C
C BEGINNING OF MODULE 1, SIMPLE IDENTIFIERS
C
        X1 = 1.0
        X2 = -1.0
        X3 = -1.0
        X4 = -1.0
        IF(N1)19,19,11
11      DO 18 I = 1,N1,1
           X1 = (X1+X2+X3-X4)*T
           X2 = (X1+X2-X3+X4)*T
           X3 = (X1-X2+X3+X4)*T
           X4 = (-X1+X2+X3+X4)*T
18      CONTINUE
C
19      CONTINUE
        IF(JJ.EQ.LOOP) CALL POUT (N1,N1,N1,X1,X2,X3,X4)
C
C BEGINNING OF MODULE 2, ARRAY ELEMENTS
C
        E1(1) = 1.0
        E1(2) = -1.0
        E1(3) = -1.0
        E1(4) = -1.0
        IF(N2)29,29,21
21      DO 28 I = 1,N2,1
           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
28      CONTINUE
C
29      CONTINUE
        IF(JJ.EQ.LOOP) CALL POUT (N2,N3,N2,E1(1),E1(2),E1(3),E1(4))
C
C BEGINNING OF MODULE 3, ARRAY AS A PARAMETER
C
        IF(N3)39,39,31
31      DO 38 I = 1,N3,1
38      CALL PA (E1)
C
39      CONTINUE
        IF(JJ.EQ.LOOP) CALL POUT (N3,N2,N2,E1(1),E1(2),E1(3),E1(4))
C
C BEGINNING OF MODULE 4, CONDITIONAL JUMPS
C
        J = 1
        IF(N4)49,49,41
41      DO 48 I = 1,N4,1
           IF(J-1)43,42,43
42         J = 2
           GO TO 44
43         J = 3
44         IF(J-2)46,46,45
45         J = 0
           GO TO 47
46         J = 1
47         IF(J-1)411,412,412
411        J = 1
           GO TO 48
412        J = 0
48      CONTINUE
C
49      CONTINUE
        IF(JJ.EQ.LOOP) CALL POUT (N4,J,J,X1,X2,X3,X4)
C
C THERE IS NO MODULE 5
C
C BEGINNING OF MODULE 6, INTEGER ARITHMETIC
C
        J = 1
        K = 2
        L = 3
        IF(N6)69,69,61
61      DO 68 I = 1,N6,1
           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
68      CONTINUE
C
69      CONTINUE
        IF(JJ.EQ.LOOP) CALL POUT (N6,J,K,E1(1),E1(2),E1(3),E1(4))
C
C BEGINNING OF MODULE 7, TRIG. FUNCTIONS
C
        X = 0.5
        Y = 0.5
        IF(N7)79,79,71
71      DO 78 I = 1,N7,1
           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))
78      CONTINUE
C
79      CONTINUE
        IF(JJ.EQ.LOOP) CALL POUT (N7,J,K,X,X,Y,Y)
C
C BEGINNING OF MODULE 8, PROCEDURE CALLS
C
        X = 1.0
        Y = 1.0
        Z = 1.0
        IF(N8)89,89,81
81      DO 88 I = 1,N8,1
88      CALL P3 (X,Y,Z)
C
89      CONTINUE
        IF(JJ.EQ.LOOP) CALL POUT (N8,J,K,X,Y,Z,Z)
C
C BEGINNING OF MODULE 9, ARRAY REFERENCES
C
        J = 1
        K = 2
        L = 3
        E1(1) = 1.0
        E1(2) = 2.0
        E1(3) = 3.0
        IF(N9)99,99,91
91      DO 98 I = 1,N9,1
98      CALL P0
C
99      CONTINUE
        IF(JJ.EQ.LOOP) CALL POUT (N9,J,K,E1(1),E1(2),E1(3),E1(4))
C
C BEGINNING OF MODULE 10, INTEGER ARITHMETIC
C
        J = 2
        K = 3
        IF(N10)109,109,101
101     DO 108 I = 1,N10,1
           J = J+K
           K = J+K
           J = K-J
           K = K-J-J
108     CONTINUE
C
109     CONTINUE
        IF(JJ.EQ.LOOP) CALL POUT (N10,J,K,X1,X2,X3,X4)
C
C BEGINNING OF MODULE 11, STANDARD FUNCTIONS
C
        X = 0.75
        IF(N11)119,119,111
111     DO 118 I = 1,N11,1
118     X = SQRT(EXP(ALOG(X)/T1))
C
119     CONTINUE
        IF(JJ.EQ.LOOP) CALL POUT (N11,J,K,X,X,X,X)
C
C THERE IS NO MODULE 12
C
C THIS IS THE END OF THE MAJOR LOOP
 500  CONTINUE
C------------------------------------------------------------
C  USER  SHALL MODIFY THIS TO SET "TTIME" TO TOTAL AMOUNT OF
C ELAPSED TIME SINCE "STIME" IN SECONDS.
C-------------------------------------------------------------
	TTIME=SECNDS(STIME)
C LLL MODIFICATION TO PRINT TOTAL ELAPSED TIME OF BENCHMARK
      ETIME = TTIME/60.0
      WRITE(NTTY,1000)ETIME
1000  FORMAT(' BENCHMARK 1 EXECUTION TIME IS ',F8.4,' MINUTES')
C--------------------------------------------------------------
C COMPUTE WHETSTONE IPS RATE
C
	WHETS = (1/TTIME)*LOOP*1000
	WRITE(NTTY,999) WHETS
999	FORMAT(' RATE IS ',F8.0,' THOUSAND ',
	2 'SINGLE PRECISION WHETSTONE INSTRUCTIONS PER SECOND')
        STOP
        END
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===========================================================
        SUBROUTINE P3 (X,Y,Z)
        COMMON T,T1,T2
        X1 = X
        Y1 = Y
        X1 = T*(X1+Y1)
        Y1 = T*(X1+Y1)
        Z = (X1+Y1)/T2
        RETURN
        END
C===========================================================
        SUBROUTINE POUT (N,J,K,X1,X2,X3,X4)
        WRITE(6,1) N,J,K,X1,X2,X3,X4
1       FORMAT(1H ,3I7,4E12.4)
        RETURN
        END
C===========================================================
        SUBROUTINE PA (E)
        COMMON T,T1,T2
        DIMENSION E(4)
        J = 0
1       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(4) = (-E(1)+E(2)+E(3)+E(4))/T2
        J = J+1
        IF(J-6)1,2,2
2       CONTINUE
        RETURN
        END
