Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Warn vs Check as compiler flags

carlls
Beginner
1,385 Views
Trying to use compiler diagnostics whenever possible so really trying to to give the compiler options

warn:all
check:all

a work out. ir seems to me that

Warn: Is a warning issued at compile time, hence static analysis. program execution NOT required.... find your errors before you check the source in.

Check: Is a run time verifications, hence dynamic analysis.... catch you errors in the software check out stage


Using my sample code:
--------------------------------------------------------------------
SUBROUTINE BadSub()
IMPLICIT NONE


INTEGER (KIND=4) I,LoopSize
REAL (KIND=4) ANumber
REAL (KIND=4) YetAnotherNumber
REAL (KIND=4) UnusedNumber
REAL (KIND=4) AnArray(5)


! If ANumber is commented out below then ...
! YetAnotherNumber=ANumber gives a runtime error
ANumber=2.
YetAnotherNumber=ANumber


! If LoopSize is greater that 5 the runtime error is trapped ...
LoopSize=5
! LoopSize=15
DO I=1,LoopSize
AnArray(I)=I*3.14159
END DO


PRINT 15
15 FORMAT(/1X,' Hello World subroutine')
write (*,*) ANumber

RETURN

! Can't reach this code
YetAnotherNumber=5.0

RETURN
END

------------------------------------------------
I can correctly find most run time errors i.e.


  1. forrtl: severe (193): Run-Time Check Failure. The variable 'BADSUB$ANUMBER' is being used without being defined
  2. forrtl: severe (408): fort: (2): Subscript #1 of the array ANARRAY has value 6 which is greater than the upper bound of 5
But I only see one warning:
  1. hello_subroutine.f(8) : Info: This variable has not been used. [UNUSEDNUMBER] REAL (KIND=4) UnusedNumber

I had hope:
warn:uncalled Enables warnings when a statement function is never called.

would have found the issue with the statement after "Can't reach this code". If Uncalled can't find this just what is uncalled intended to do? I guess I was hoping for behavior similar to FORTRAN flint.

And frankly warning never caught the out of bounds or undefined issues, on the run time checking did.

Thoughts?

Regards
Carl
0 Kudos
1 Solution
Steven_L_Intel1
Employee
1,385 Views
warn:uncalled refers to statement functions. These are an ancient Fortran feature that is "deprecated" in the current Fortran standard. You are not using these in your code, so no warning. Here's an example:

[plain]triple(y) = 3.0*y
quadruple(y) = 4.0*y

print *, triple(72.)
end

uncalled.f90(2): remark #7713: This statement function has not been used. [QUADRUPLE]
quadruple(y) = 4.0*y
^[/plain]


Uninitialized variable checking is done at run-time only. Array bounds checking is MOSTLY done at run-time, but sometimes the compiler can see bounds errors with constant subscripts and will warn you at compile time.

I recommend that you also use /gen-interface which allows /warn:interface to work.

View solution in original post

0 Kudos
2 Replies
Steven_L_Intel1
Employee
1,386 Views
warn:uncalled refers to statement functions. These are an ancient Fortran feature that is "deprecated" in the current Fortran standard. You are not using these in your code, so no warning. Here's an example:

[plain]triple(y) = 3.0*y
quadruple(y) = 4.0*y

print *, triple(72.)
end

uncalled.f90(2): remark #7713: This statement function has not been used. [QUADRUPLE]
quadruple(y) = 4.0*y
^[/plain]


Uninitialized variable checking is done at run-time only. Array bounds checking is MOSTLY done at run-time, but sometimes the compiler can see bounds errors with constant subscripts and will warn you at compile time.

I recommend that you also use /gen-interface which allows /warn:interface to work.
0 Kudos
carlls
Beginner
1,385 Views
You nailed it Steve, I had to dust off the old FOTRAN IV book, but there it was "statement functions".

Not a warning I ever hope to see pop out of our code.

Thanks
Carl
0 Kudos
Reply