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

-gen-interfaces drops Allocatable and Optional (for Types)

Cross__Mat
Beginner
757 Views

Hi. I'm using

> ifort --version
ifort (IFORT) 13.0.0 20120731

on

> uname -a
Linux whakarewarewa.nag.co.uk 3.5.3-1.fc17.x86_64 #1 SMP Wed Aug 29 18:46:34 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

The fixes to -gen-interfaces at Version 13 are really appreciated, but there are still some problems.

> cat interface.f90

    Subroutine s(a, b, c, d)
      Implicit None
      Integer, Parameter :: n = 3, k = 8
      Integer, Allocatable :: a
      Type t
      End Type t
      Type (t), Optional :: b
      Integer :: c(n)
      Integer (k) :: d
    End Subroutine s

> ifort -gen-interfaces -c interface.f90 ; cat s__genmod.f90
        !COMPILER-GENERATED INTERFACE MODULE: Thu Sep 13 11:47:10 2012
        MODULE S__genmod
          INTERFACE
            SUBROUTINE S(A,B,C,D)
              TYPE T
              END TYPE T
              INTEGER(KIND=4) :: A
              TYPE (T) :: B
              INTEGER(KIND=4) :: C(3)
              INTEGER(KIND=8) :: D
            END SUBROUTINE S
          END INTERFACE
        END MODULE S__genmod

Note that in the output a is missing Allocatable and b is missing Optional.

As further suggestions, would you consider preserving Parameters in Interfaces instead of semantically replacing them? E.g., preserve c(n) and Integer (Kind=k) :: d in the output?

0 Kudos
5 Replies
Cross__Mat
Beginner
757 Views
Are there any thoughts here?
0 Kudos
TimP
Honored Contributor III
757 Views
You can't use optional without supplying an explicit interface. Allocatable shouldn't need to be in the interface.
0 Kudos
Steven_L_Intel1
Employee
757 Views
An ALLOCATABLE dummy argument also requires an interface - there is a use for this (when you'll be doing allocation or deallocation in the subroutine) - but most of the time, as Tim suggests, it isn't needed. The .f90 form of the generated interface is just for a human reference - it isn't really intended as a way of creating usable interfaces, though many do. By the time the compiler is generating the interface, all the PARAMETER constant expressions have been resolved. I note that even though the generated interface ,f90 doesn't include OPTIONAL or ALLOCATABLE, the compiler seems to notice it anyway and does the right checking. I will ask that these attributes be included in the .f90 to help users who look at them.
0 Kudos
Cross__Mat
Beginner
757 Views
Tim: "You can't use optional without supplying an explicit interface. Allocatable shouldn't need to be in the interface." I have explicit interfaces. My toolchain is using ifort to make sure these are always current. The standard says that Allocatable is a dummy's characteristic, so it must be in the Interface if it's in the procedure itself. I'm aware of how to use Allocatable for dummies. Steve: "I will ask that these attributes be included in the .f90 to help users who look at them." Thanks. That will be helpful.
0 Kudos
Steven_L_Intel1
Employee
757 Views
This problem has been fixed for a future major version of the compiler.
0 Kudos
Reply