xref: /original-bsd/usr.bin/f77/tests/tests/fm012.f (revision 72b8f354)
1c
2c     comment section.
3c
4c     fm012
5c
6c             this routine tests the fortran do - statement from its
7c     simplist format to the more abbreviated forms.  various increments
8c     are used and branching by various methods is tested for passing
9c     control out of the do range and returning (extended range).
10c     nested do statements using various terminating statements are also
11c     tested by this routine.
12c
13c      references
14c        american national standard programming language fortran,
15c              x3.9-1978
16c
17c        section 11.10, do statement
18c        section 11.10.3, executes a do loop
19c        section 11.11, continue statement
20c
21c
22c      **********************************************************
23c
24c         a compiler validation system for the fortran language
25c     based on specifications as defined in american national standard
26c     programming language fortran x3.9-1978, has been developed by the
27c     federal cobol compiler testing service.  the fortran compiler
28c     validation system (fcvs) consists of audit routines, their related
29c     data, and an executive system.  each audit routine is a fortran
30c     program, subprogram or function which includes tests of specific
31c     language elements and supporting procedures indicating the result
32c     of executing these tests.
33c
34c         this particular program/subprogram/function contains features
35c     found only in the subset as defined in x3.9-1978.
36c
37c         suggestions and comments should be forwarded to -
38c
39c                  department of the navy
40c                  federal cobol compiler testing service
41c                  washington, d.c.  20376
42c
43c      **********************************************************
44c
45c
46c
47c     initialization section
48c
49c     initialize constants
50c      **************
51c     i01 contains the logical unit number for the card reader.
52      i01 = 5
53c     i02 contains the logical unit number for the printer.
54      i02 = 6
55c     system environment section
56c
57cx010    this card is replaced by contents of fexec x-010 control card.
58c     the cx010 card is for overriding the program default i01 = 5
59c     (unit number for card reader).
60cx011    this card is replaced by contents of fexec x-011 control card.
61c     the cx011 card is for systems which require additional
62c     fortran statements for files associated with cx010 above.
63c
64cx020    this card is replaced by contents of fexec x-020 control card.
65c     the cx020 card is for overriding the program default i02 = 6
66c     (unit number for printer).
67cx021    this card is replaced by contents of fexec x-021 control card.
68c     the cx021 card is for systems which require additional
69c     fortran statements for files associated with cx020 above.
70c
71      ivpass=0
72      ivfail=0
73      ivdele=0
74      iczero=0
75c
76c     write page headers
77      write (i02,90000)
78      write (i02,90001)
79      write (i02,90002)
80      write (i02, 90002)
81      write (i02,90003)
82      write (i02,90002)
83      write (i02,90004)
84      write (i02,90002)
85      write (i02,90011)
86      write (i02,90002)
87      write (i02,90002)
88      write (i02,90005)
89      write (i02,90006)
90      write (i02,90002)
91      ivtnum = 110
92c
93c     test 110  -  do statement with the complete format, increment of 1
94c           the loop should be executed ten (10) times thus the loop
95c           counter should have a value of ten at the completion of the
96c           do-loop.
97c
98c
99      if (iczero) 31100, 1100, 31100
100 1100 continue
101      ivon01=0
102      do 1102 i=1,10,1
103      ivon01=ivon01+1
104 1102 continue
105      go to 41100
10631100 ivdele = ivdele + 1
107      write (i02,80003) ivtnum
108      if (iczero) 41100, 1111, 41100
10941100 if(ivon01-10) 21100,11100,21100
11011100 ivpass = ivpass + 1
111      write (i02,80001) ivtnum
112      go to 1111
11321100 ivfail = ivfail + 1
114      ivcomp=ivon01
115      ivcorr=10
116      write (i02,80004) ivtnum, ivcomp ,ivcorr
117 1111 continue
118      ivtnum = 111
119c
120c     test 111  -  same do test as in test 110 except that no increment
121c           is given.  the increment should be 1 and the loop performed
122c           ten (10) times as before.
123c
124c
125      if (iczero) 31110, 1110, 31110
126 1110 continue
127      ivon01=0
128      do 1112 j=1,10
129      ivon01=ivon01+1
130 1112 continue
131      go to 41110
13231110 ivdele = ivdele + 1
133      write (i02,80003) ivtnum
134      if (iczero) 41110, 1121, 41110
13541110 if(ivon01-10)  21110, 11110, 21110
13611110 ivpass = ivpass + 1
137      write (i02,80001) ivtnum
138      go to 1121
13921110 ivfail = ivfail + 1
140      ivcomp=ivon01
141      ivcorr=10
142      write (i02,80004) ivtnum, ivcomp ,ivcorr
143 1121 continue
144      ivtnum = 112
145c
146c     test 112  -  do statement with an increment other than one (1).
147c           the do - loop should be executed five (5) times thus
148c           the value of the loop counter should be five (5) at the
149c           end of the do - loop.
150c
151c
152      if (iczero) 31120, 1120, 31120
153 1120 continue
154      ivon01=0
155      do 1122 k = 1, 10, 2
156      ivon01=ivon01+1
157 1122 continue
158      go to 41120
15931120 ivdele = ivdele + 1
160      write (i02,80003) ivtnum
161      if (iczero) 41120, 1131, 41120
16241120 if (ivon01 - 5 )  21120, 11120, 21120
16311120 ivpass = ivpass + 1
164      write (i02,80001) ivtnum
165      go to 1131
16621120 ivfail = ivfail + 1
167      ivcomp=ivon01
168      ivcorr=5
169      write (i02,80004) ivtnum, ivcomp ,ivcorr
170 1131 continue
171      ivtnum = 113
172c
173c     test 113  -  do statement with the initial value equal to the
174c           terminal value.  the do - loop should be executed one (1)
175c           time thus the value of the loop counter should be one (1).
176c
177c
178      if (iczero) 31130, 1130, 31130
179 1130 continue
180      ivon01=0
181      do 1132 l = 2, 2
182      ivon01=ivon01+1
183 1132 continue
184      go to 41130
18531130 ivdele = ivdele + 1
186      write (i02,80003) ivtnum
187      if (iczero) 41130, 1141, 41130
18841130 if ( ivon01 - 1 )  21130, 11130, 21130
18911130 ivpass = ivpass + 1
190      write (i02,80001) ivtnum
191      go to 1141
19221130 ivfail = ivfail + 1
193      ivcomp=ivon01
194      ivcorr=1
195      write (i02,80004) ivtnum, ivcomp ,ivcorr
196 1141 continue
197      ivtnum = 114
198c
199c     test 114  -  this tests the unconditional branch out of the
200c           range of the do using the go to statement.  the do index
201c           should retain the value it had when the unconditional branch
202c           was made.  since the do loop only contains an unconditional
203c           branch, the value of the do index should be its initial
204c           value.  in this case the value should be one (1).
205c           see section 11.10.
206c
207c
208      if (iczero) 31140, 1140, 31140
209 1140 continue
210      do 1142 m=1,10
211      go to 1143
212 1142 continue
213 1143 continue
214      go to 41140
21531140 ivdele = ivdele + 1
216      write (i02,80003) ivtnum
217      if (iczero) 41140, 1151, 41140
21841140 if ( m - 1 )  21140, 11140, 21140
21911140 ivpass = ivpass + 1
220      write (i02,80001) ivtnum
221      go to 1151
22221140 ivfail = ivfail + 1
223      ivcomp=m
224      ivcorr=1
225      write (i02,80004) ivtnum, ivcomp ,ivcorr
226 1151 continue
227      ivtnum = 115
228c
229c     test 115  -  this test is similar to test 114 in that the do
230c           range has only an unconditional branch outside of the range.
231c           the do index should again retain its value, in this case
232c           its initial value of one (1).
233c           see section 11.10.
234c
235c
236      if (iczero) 31150, 1150, 31150
237 1150 continue
238      do 1152 n = 1, 10
239      if ( n - 1 )  1152, 1153, 1152
240 1152 continue
241 1153 continue
242      go to 41150
24331150 ivdele = ivdele + 1
244      write (i02,80003) ivtnum
245      if (iczero) 41150, 1161, 41150
24641150 if (n - 1 )  21150, 11150, 21150
24711150 ivpass = ivpass + 1
248      write (i02,80001) ivtnum
249      go to 1161
25021150 ivfail = ivfail + 1
251      ivcomp=n
252      ivcorr=1
253      write (i02,80004) ivtnum, ivcomp ,ivcorr
254 1161 continue
255      ivtnum = 116
256c
257c     test 116  -  this is a test of a nest of two do ranges.  two
258c           separate continue statements are used as terminal statements
259c           for the two respective do ranges.  the outer loop should be
260c           performed ten (10) times and the inner loop should be
261c           performed twice for each execution of the outer loop.  the
262c           loop counter should have a value of twenty (20) since it
263c           is incremented in the inner do - loop.
264c           see section 11.10.3.
265c
266c
267      if (iczero) 31160, 1160, 31160
268 1160 continue
269      ivon01=0
270      do 1163 i=1,10,1
271      do 1162 j=1,2,1
272      ivon01=ivon01+1
273 1162 continue
274 1163 continue
275      go to 41160
27631160 ivdele = ivdele + 1
277      write (i02,80003) ivtnum
278      if (iczero) 41160, 1171, 41160
27941160 if ( ivon01 - 20 )  21160, 11160, 21160
28011160 ivpass = ivpass + 1
281      write (i02,80001) ivtnum
282      go to 1171
28321160 ivfail = ivfail + 1
284      ivcomp=ivon01
285      ivcorr=20
286      write (i02,80004) ivtnum, ivcomp ,ivcorr
287 1171 continue
288      ivtnum = 117
289c
290c     test 117  -  this is basically the same as test 116 except that
291c           only one continue statement is used as the terminating
292c           statement for both of the do ranges.  the value of the
293c           loop counter should again be twenty (20).
294c
295c
296      if (iczero) 31170, 1170, 31170
297 1170 continue
298      ivon01=0
299      do 1172 k=1,10,1
300      do 1172 l=1,2,1
301      ivon01=ivon01+1
302 1172 continue
303      go to 41170
30431170 ivdele = ivdele + 1
305      write (i02,80003) ivtnum
306      if (iczero) 41170, 1181, 41170
30741170 if (ivon01 - 20 )  21170, 11170, 21170
30811170 ivpass = ivpass + 1
309      write (i02,80001) ivtnum
310      go to 1181
31121170 ivfail = ivfail + 1
312      ivcomp=ivon01
313      ivcorr=20
314      write (i02,80004) ivtnum, ivcomp ,ivcorr
315 1181 continue
316      ivtnum = 118
317c
318c     test 118  -  this is basically the same test as 116 except
319c           that the loop counter increment is the terminating statement
320c           of both of the do ranges.  the value of the loop counter
321c           should be twenty (20), but the number of executions of
322c           the outer loop is now two (2) and the inner loop executes
323c           ten (10) times for every execution of the outer loop.
324c
325c
326      if (iczero) 31180, 1180, 31180
327 1180 continue
328      ivon01=0
329      do 1182 m=1,2,1
330      do 1182 n=1,10,1
331 1182 ivon01 = ivon01 + 1
332      go to 41180
33331180 ivdele = ivdele + 1
334      write (i02,80003) ivtnum
335      if (iczero) 41180, 1191, 41180
33641180 if (ivon01 - 20 )  21180, 11180, 21180
33711180 ivpass = ivpass + 1
338      write (i02,80001) ivtnum
339      go to 1191
34021180 ivfail = ivfail + 1
341      ivcomp=ivon01
342      ivcorr=20
343      write (i02,80004) ivtnum, ivcomp ,ivcorr
344 1191 continue
345      ivtnum = 119
346c
347c     test 119  -  this is a test of an unconditional branch out of a
348c           nested do range quite like test 114.  the loop counter
349c           should only be incremented on the outer loop range so
350c            the final value of the loop counter should be ten (10).
351c
352c
353      if (iczero) 31190, 1190, 31190
354 1190 continue
355      ivon01=0
356      do 1194 i=1,10,1
357      do 1193 j=1,2,1
358c
359c     the following statement is to eliminate the dead code produced
360c         by the statement   go to 1194.
361c
362      if ( iczero )  1193, 1192, 1193
363c
364 1192  go to 1194
365 1193 ivon01 = ivon01 + 1
366 1194 ivon01 = ivon01 + 1
367      go to 41190
36831190 ivdele = ivdele + 1
369      write (i02,80003) ivtnum
370      if (iczero) 41190, 1201, 41190
37141190 if ( ivon01 - 10 )  21190, 11190, 21190
37211190 ivpass = ivpass + 1
373      write (i02,80001) ivtnum
374      go to 1201
37521190 ivfail = ivfail + 1
376      ivcomp=ivon01
377      ivcorr=10
378      write (i02,80004) ivtnum, ivcomp ,ivcorr
379 1201 continue
380      ivtnum = 120
381c
382c     test 120  -  this is basically the same test as test 119 except
383c           that an if statement is used to branch out of the inner loop
384c           without incrementing the loop counter.  the value of the
385c           loop counter should again be ten (10).
386c
387c
388      if (iczero) 31200, 1200, 31200
389 1200 continue
390      ivon01=0
391      do 1203 i=1,10,1
392      do 1202 j=1,2,1
393      if ( j - 1 )  1203, 1203, 1202
394 1202 ivon01 = ivon01 + 1
395 1203 ivon01 = ivon01 + 1
396      go to 41200
39731200 ivdele = ivdele + 1
398      write (i02,80003) ivtnum
399      if (iczero) 41200, 1211, 41200
40041200 if ( ivon01 - 10 )  21200, 11200, 21200
40111200 ivpass = ivpass + 1
402      write (i02,80001) ivtnum
403      go to 1211
40421200 ivfail = ivfail + 1
405      ivcomp=ivon01
406      ivcorr=10
407      write (i02,80004) ivtnum, ivcomp ,ivcorr
408 1211 continue
409      ivtnum = 121
410c
411c     test 121  -  this is a test of do nests within do nests.  the
412c           loop counter should have a final value of eighty-four (84).
413c
414c
415      if (iczero) 31210, 1210, 31210
416 1210 continue
417      ivon01=0
418      do 1216 i1=1,2,1
419      do 1213 i2=1,3,1
420      do 1212 i3=1,4,1
421      ivon01=ivon01+1
422 1212  continue
423 1213  continue
424      do 1215 i4=1,5,1
425      do 1214 i5=1,6,1
426      ivon01=ivon01+1
427 1214 continue
428 1215 continue
429 1216 continue
430      go to 41210
43131210 ivdele = ivdele + 1
432      write (i02,80003) ivtnum
433      if (iczero) 41210, 1221, 41210
43441210 if ( ivon01 - 84 )  21210, 11210, 21210
43511210 ivpass = ivpass + 1
436      write (i02,80001) ivtnum
437      go to 1221
43821210 ivfail = ivfail + 1
439      ivcomp=ivon01
440      ivcorr=84
441      write (i02,80004) ivtnum, ivcomp ,ivcorr
442 1221 continue
443      ivtnum = 122
444c
445c     test 122  -  this is again a test of do nests but combined with
446c           arithmetic if statement branches within the do range.  the
447c           final loop counter value should be eighteen (18).
448c
449c
450      if (iczero) 31220, 1220, 31220
451 1220 continue
452      ivon01=0
453      do 1228 i1=1,3,1
454      do 1223 i2=1,4,1
455      if ( i2 - 3 )  1222, 1224, 1224
456 1222 ivon01 = ivon01 + 1
457 1223 continue
458 1224 do 1226 i3=1,5,1
459      if ( i3 - 3 )  1225, 1225, 1227
460 1225 ivon01 = ivon01 + 1
461 1226 continue
462 1227 continue
463 1228 continue
464      go to 41220
46531220 ivdele = ivdele + 1
466      write (i02,80003) ivtnum
467      if (iczero) 41220, 1231, 41220
46841220 if ( ivon01 - 15 )  21220, 11220, 21220
46911220 ivpass = ivpass + 1
470      write (i02,80001) ivtnum
471      go to 1231
47221220 ivfail = ivfail + 1
473      ivcomp=ivon01
474      ivcorr=15
475      write (i02,80004) ivtnum, ivcomp ,ivcorr
476 1231 continue
477      ivtnum = 123
478c
479c     note ****  test 123 was deleted by fccts.
480c
481      if (iczero) 31230, 1230, 31230
482 1230 continue
48331230 ivdele = ivdele + 1
484      write (i02,80003) ivtnum
485      if (iczero) 41230, 1241, 41230
48641230 if ( ivon01 - 20 )  21230, 11230, 21230
48711230 ivpass = ivpass + 1
488      write (i02,80001) ivtnum
489      go to 1241
49021230 ivfail = ivfail + 1
491      ivcomp=ivon01
492      ivcorr=20
493      write (i02,80004) ivtnum, ivcomp ,ivcorr
494 1241 continue
495      ivtnum = 124
496c
497c     test 124  -  this is a test of a triple nested do range with
498c           an unconditional go to statement branch in the innermost
499c           nested do to the common terminal statement.  the final
500c           loop counter value should be one hundred and forty-two (142)
501c           the initial value of the innermost do range is two (2).
502c
503c
504      if (iczero) 31240, 1240, 31240
505 1240 continue
506      ivon01=0
507      do 1242 i2=1,5,1
508      do 1242 i3=2,8,1
509      do 1242 i1=1,4,1
510      ivon01=ivon01+1
511      go to 1242
512 1242 continue
513      go to 41240
51431240 ivdele = ivdele + 1
515      write (i02,80003) ivtnum
516      if (iczero) 41240, 1251, 41240
51741240 if ( ivon01 - 140 )  21240, 11240, 21240
51811240 ivpass = ivpass + 1
519      write (i02,80001) ivtnum
520      go to 1251
52121240 ivfail = ivfail + 1
522      ivcomp=ivon01
523      ivcorr=140
524      write (i02,80004) ivtnum, ivcomp ,ivcorr
525 1251 continue
526      ivtnum = 125
527c
528c     test 125  -  this is basically the same as test 124 except that
529c           an arithmetic if branch is used instead of the go to
530c           statement for the branch to the terminal statement common
531c           to all three of the do ranges.
532c           the final value of the loop counter should be one
533c           hundred and forty (140).
534c
535c
536      if (iczero) 31250, 1250, 31250
537 1250 continue
538      ivon01=0
539      do 1252 i1=1,4,1
540      do 1252 i2=1,5,1
541      do 1252 i3=2,8,1
542      ivon01=ivon01+1
543      if ( i3 - 9 ) 1252, 1252, 1253
544 1252 continue
545 1253 continue
546      go to 41250
54731250 ivdele = ivdele + 1
548      write (i02,80003) ivtnum
549      if (iczero) 41250, 1261, 41250
55041250 if ( ivon01 - 140 )  21250, 11250, 21250
55111250 ivpass = ivpass + 1
552      write (i02,80001) ivtnum
553      go to 1261
55421250 ivfail = ivfail + 1
555      ivcomp=ivon01
556      ivcorr=140
557      write (i02,80004) ivtnum, ivcomp ,ivcorr
558 1261 continue
559c
560c     write page footings and run summaries
56199999 continue
562      write (i02,90002)
563      write (i02,90006)
564      write (i02,90002)
565      write (i02,90002)
566      write (i02,90007)
567      write (i02,90002)
568      write (i02,90008)  ivfail
569      write (i02,90009) ivpass
570      write (i02,90010) ivdele
571c
572c
573c     terminate routine execution
574      stop
575c
576c     format statements for page headers
57790000 format (1h1)
57890002 format (1h )
57990001 format (1h ,10x,34hfortran compiler validation system)
58090003 format (1h ,21x,11hversion 1.0)
58190004 format (1h ,10x,38hfor official use only - copyright 1978)
58290005 format (1h ,5x,4htest,5x,9hpass/fail, 5x,8hcomputed,8x,7hcorrect)
58390006 format (1h ,5x,46h----------------------------------------------)
58490011 format (1h ,18x,17hsubset level test)
585c
586c     format statements for run summaries
58790008 format (1h ,15x,i5,19h errors encountered)
58890009 format (1h ,15x,i5,13h tests passed)
58990010 format (1h ,15x,i5,14h tests deleted)
590c
591c     format statements for test results
59280001 format (1h ,4x,i5,7x,4hpass)
59380002 format (1h ,4x,i5,7x,4hfail)
59480003 format (1h ,4x,i5,7x,7hdeleted)
59580004 format (1h ,4x,i5,7x,4hfail,10x,i6,9x,i6)
59680005 format (1h ,4x,i5,7x,4hfail,4x,e12.5,3x,e12.5)
597c
59890007 format (1h ,20x,20hend of program fm012)
599      end
600