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

compiler-generated interfaces question

twlaub
Beginner
385 Views

We have built all our own interface for all of our routines and would like ifort to check them for us. That is, tell us if there is a missing or incorrect interface. However, the only info/behavior I can find is to let the compiler generate interfaces or not. When we let it we get genmod interfaces for all routines whether we have one or not. Our interface mod file is built and used but I want the compiler to only generate an interface when ours in incorrect or missing. Is there a combination of compiler options that will get us that behavior?

A related question is whether we should be creating our own interfaces or not. Is it better to let the compiler generate them? If we let the compiler generate interfaces will we be warned if the same routine name is used with different argument lists or will the compiler somehow happily create two interfaces and leave us in the dark?

 

0 Kudos
1 Reply
Steven_L_Intel1
Employee
385 Views

Ideally, you would almost never write an interface for a Fortran routine. Instead, you'd put the routines in modules and USE the modules. The generated interface feature is for when you have external procedures (not in a module or CONTAINed) - it generates modules for those and will then check the generated interface when you call a routine without an explicit interface. I can't think of a way for you to "supply your own" generated interfaces in a way that's usable by the compiler automatically.

What you really want is a feature proposed for Fortran 2015, IMPLICIT NONE (EXTERNAL), which will require an explicit interface for all procedure references.

How are you using the interfaces you create? Unfortunately, the language doesn't allow you to USE a module that declares an interface to the procedure you're already in.

Note that the .f90 files created for generated interfaces don't necessarily represent all of the characteristics of the procedure - they are there for your reference but aren't used by the compiler.

Given the order dependence of the interface checking, you could do a build in two passes - one with -gen-interface only and then one with -warn interface. This would make sure that all of the generated interfaces exist before they are checked.

0 Kudos
Reply