- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello;
I tried to generate error messages when there is an incompatible use of argument types across subroutine calls. My understanding was that I could set compiler options toGENERATE interface blocks and WARN when those occur.
I could not however, force any error messages to appeareven when deliberately trying to cause them.
First of all, where do IFORCE the compiler to generate them? The compile options don't include that. I had to stick it on as an added option during the compile phase.
Secondly, do the error messages appear at LINK time? If so, are they put somewhere in a special log file? How do I find them? They don't come up during the link part of the build.
It seems like WARN:interface should be in the linker, not in the compiler. At compile time, the compiler has no way to know how a subroutine is being called, i.e. with missing or mistyped arguments, etc.
I could not find the article you wrote about this topic, except where it was described as a new feature.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are using version 10.1, it is an option under Diagnostics in Visual Studio. Actually, it's two options, one for generate and one for "check interfaces". In version 9.1, I think, it was split onto two property pages, external routines and diagnostics.
This is a compile-time check and requires that the routine being called having been previously compiled. The compiler does know because it generates an interface module as it compiles routines and then looks for these generated modules when you call a routine without an explicit interface.
Which compiler version are you using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm still using 9.1.
But I'm still puzzled - in the test cases I ran, the called routine and the calling routine are in the same block of code, so they get compiled together.
Still does not generate any warnings...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, here's one I was playing with. I wonder if the interface can distinguish between different types of integers. But you'll notice I stuck in a floating point, and that didn't generate any warnings either.
Also of interest: When I put in a nonsense value for "WARN" it doesn't flag that either. There isn't a way to set GEN unless I add it as an extra line. Not under compiler options, anyway.
Is it ignoring what I put there?
---------------------------------------------------------------
program
test_integercall sub1(12_8,12_4,12_2,12_1)
call sub1(324, 324.D0, 324,324)
call sub1(34567,34567,34567,34567)
call sub1(134567278,134567278,134567278,134567278)
call sub1(135656367775757,135656367775757,135656367775757,135656367775757_8)
WRITE(*,*)"EXITING - - "
READ *,IEXIT
end
subroutine sub1(i1,i2,i4,i8) integer(1) i1 integer(2) i2 integer(4) i4 integer(8) i8 print *,"i1=",i1," i2=",i2," i4=",i4," i8=",i8 end! compile options in project test_integer properties
/nologo /Zi /Od /debug-parameters:all /warn:declarations /warn:unused
/warn:interfaces /
module:"$(INTDIR)/" /object:"$(INTDIR)/"/asmattr:source /asmfile:"$(INTDIR)/" /traceback /check:bounds
/libs:
static /threads /dbglibs /c /gen:interfaces- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
integer.f90(5) : Warning: The BYTE / LOGICAL(KIND=1) / INTEGER(KIND=1) value is out-of-range. [324]
call sub1(324, 324.D0, 324,324)
----------^
integer.f90(5) : Error: The type of the actual argument differs from the type of the dummy argument. [324.D0]
call sub1(324, 324.D0, 324,324)
---------------^
integer.f90(7) : Warning: The BYTE / LOGICAL(KIND=1) / INTEGER(KIND=1) value is out-of-range. [34567]
call sub1(34567,34567,34567,34567)
----------^
integer.f90(9) : Warning: The BYTE / LOGICAL(KIND=1) / INTEGER(KIND=1) value is out-of-range. [134567278]
call sub1(134567278,134567278,134567278,134567278)
----------^
integer.f90(9) : Warning: The INTEGER(KIND=2) value is out-of-range. [13456727
8]
call sub1(134567278,134567278,134567278,134567278)
--------------------^
integer.f90(11) : Warning: The BYTE / LOGICAL(KIND=1) / INTEGER(KIND=1) value is out-of-range. [135656367775757]
call sub1(135656367775757,135656367775757,135656367775757,135656367775757_8)
----------^
integer.f90(11) : Warning: The INTEGER(KIND=2) value is out-of-range. [1356563
67775757]
call sub1(135656367775757,135656367775757,135656367775757,135656367775757_8)
--------------------------^
integer.f90(11) : Warning: The INTEGER(KIND=4) value is out-of-range. [1356563
67775757]
call sub1(135656367775757,135656367775757,135656367775757,135656367775757_8)
------------------------------------------^
compilation aborted for integer.f90 (code 1)
I'll comment that the compiler has an extension where it will try to convert larger integer kinds to a smaller argument kind if it sees an explicit interface.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Compiling with IVF 9.1.028 and /warn:interfaces and /gen-interfacesI get the same warnings andthe error.
Les
hdr.f90(15) : Warning: This name has not been given an explicit type. [IEXIT]
hdr.f90(3) : Warning: The data type of the actual argument does not match the definition. [12]
hdr.f90(3) : Warning: The data type of the actual argument does not match the definition. [12]
hdr.f90(3) : Warning: The data type of the actual argument does not match the definition. [12]
hdr.f90(3) : Warning: The data type of the actual argument does not match the definition. [12]
hdr.f90(5) : Warning: The data type of the actual argument does not match the definition. [324]
hdr.f90(5) : Warning: The BYTE / LOGICAL(KIND=1) / INTEGER(KIND=1) value is out-of-range. [324]
hdr.f90(5) : Error: The type of the actual argument differs from the type of the dummy argument. [324.D0]
hdr.f90(5) : Warning: The data type of the actual argument does not match the definition. [324]
hdr.f90(7) : Warning: The data type of the actual argument does not match the definition. [34567]
hdr.f90(7) : Warning: The BYTE / LOGICAL(KIND=1) / INTEGER(KIND=1) value is out-of-range. [34567]
hdr.f90(7) : Warning: The data type of the actual argument does not match the definition. [34567]
hdr.f90(7) : Warning: The data type of the actual argument does not match the definition. [34567]
hdr.f90(9) : Warning: The data type of the actual argument does not match the definition. [134567278]
hdr.f90(9) : Warning: The BYTE / LOGICAL(KIND=1) / INTEGER(KIND=1) value is out-of-range. [134567278]
hdr.f90(9) : Warning: The data type of the actual argument does not match the definition. [134567278]
hdr.f90(9) : Warning: The INTEGER(KIND=2) value is out-of-range. [134567278]
hdr.f90(9) : Warning: The data type of the actual argument does not match the definition. [134567278]
hdr.f90(11) : Warning: The data type of the actual argument does not match the definition. [135656367775757]
hdr.f90(11) : Warning: The BYTE / LOGICAL(KIND=1) / INTEGER(KIND=1) value is out-of-range. [135656367775757]
hdr.f90(11) : Warning: The data type of the actual argument does not match the definition. [135656367775757]
hdr.f90(11) : Warning: The INTEGER(KIND=2) value is out-of-range. [135656367775757]
hdr.f90(11) : Warning: The data type of the actual argument does not match the definition. [135656367775757]
hdr.f90(11) : Warning: The INTEGER(KIND=4) value is out-of-range. [135656367775757]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see that I misspelled it - but why doesn't it FLAG that as an error?
Do I have to add that as a separate line in the compiler options?
I don't see it in the check boxes, at least with 9.1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Brad;
I was finally able to find it - it's under "external procedures" Not clear to me why they put it there.
Anyway, you can go there to turn the gen-interfaces option on. I was able to get the same results as the others.
I agree with you, they should flag misspelled options, sous poor users aren't left to wonder what's going on when things don't turn out likewe expect...
Yours; Tammy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Usually the compiler driver does warn of unrecognized options and in this case I see:
ifort: command line error: option '/gen:interface' is ambiguous
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry Dr. Fortran, but I just could not find it - -
I looked in the area where all the other Fortran compile warning and error messages are located (Ctl-W, Ctl-E). If that message is present, it must be elsewhere, but an exhaustive search could not find it. I even tried to input a nonsensical option like /quack-quack, no response generated from that either. I noticed you mentioned "IFORT" Were you using a batch build? Maybe that's why our results differ.
Is it in a LOG file somewhere?
Apparently it doesn't abort the compile or the build, otherwise it would be easy to spot. Wouldn't it make more sense to flag it appropriately if results are being produced unlike what the user expects?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
C:MyProjects>ifort /quack-quack t.f90
Intel Fortran Compiler for 32-bit applications, Version 9.1 Build 20071017Z
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.
ifort: Command line warning: ignoring option '/q'; no argument required
C:MyProjects>ifort /gen:interface t.f90
Intel Fortran Compiler for 32-bit applications, Version 9.1 Build 20071017Z
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.
ifort: Command line warning: ignoring option '/gen_interfaces'; no argument required
If you are using Visual Studio. the message will appear in the build output pane as well as in buildlog.htm.
It is a warning, not an error, so it does not abort the build.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page