Silverfrost Forums

Welcome to our forums

Compiler ignores syntax error with /opt

19 Jan 2021 11:41 #26931

The following test program contains a syntax error, as shown in the end-of-line comment. FTN95 8.70 compiles the program to an EXE when the /opt option is specified, with or without /64.

program tst
implicit none
integer, parameter :: N = 10
integer i
real,dimension(N) :: x
real :: x0 = 2.3
!
x = [(0.5*i+0.2, i=1,N)]
if(all(x(i) > x0+1e-3))then       ! syntax error, argument of ALL() must be array
   print *,' All elements of x exceed x0 by a sufficient margin'
else
   print *,' Some elements of x are too small'
endif
end program tst
19 Jan 2021 12:24 #26932

mecej4

Thank you for the feedback.

I will take a look at this to see if there is a simple fix.

In a similar situation that occurred recently, it proved to be extremely difficult to fix so the documentation has been revised to say that /opt should not be used during initial development.

19 Jan 2021 1:41 #26933

If it works, then surely it is an extension.

Eddie

19 Jan 2021 2:28 #26934

Eddie

No, it just won't work. Some syntax checking is currently skipped when using /opt and the outcome is unpredictable.

mecej4

This and the earlier issue have now been fixed. A different day and some evidence of lateral thinking.

19 Jan 2021 3:13 #26935

Paul, thanks for the rapid resolution of the issue.

Eddie, please note that the index variable i is not defined when the IF clause is evaluated; given that error, an extension does not make sense.

Perhaps an explanation of how this statement was born may be useful. In the old F77 code, the work of the ALL ... statement was performed in a DO loop, with a short exit from the loop if/when an element did not satisfy the condition. When such a short loop exit was taken, the index i would not only have been defined but would have had a value in the range 1:N.

When I replaced the loop by the IF..ALL() statement, I should have removed the index (i), but did not, which caused the bug.

19 Jan 2021 3:59 #26936

I really appreciate the explanations, but then I would always have used a DO loop.

Eddie

Please login to reply.