Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29586 ディスカッション

Using abstract procedure interfaces

zp3
ビギナー
2,062件の閲覧回数

Hi,

I'd like to ask if there are any possibilities for pointing to an abstract procedure interface from a concrete implementation to avoid redundancy. For example, I've imagined myself something like this:

module foo_mod

    abstract interface
        elemental function foo_op(a,b) result(c)
            real, intent(in) :: a,b
            real :: c
        end function foo_op
    end interface

  contains

    procedure(foo_op) foo1 !syntax is just fictional
            c=2.0*a+sqrt(b)
    end procedure foo1

    procedure(foo_op) foo2 !syntax is just fictional
            c=a/b**2
    end procedure foo2

end module foo_mod

Thanks for help!

0 件の賞賛
2 返答(返信)
Steven_L_Intel1
従業員
2,062件の閲覧回数

Nothing like that exists in Fortran today. Perhaps the closest is module procedures in submodules, but the interface has to be non-abstract.

zp3
ビギナー
2,062件の閲覧回数

Ok, thanks!

I just thought such a feature might be helpful, because I have now a few more complex abstract interfaces and for each a couple of implementations. Because I am still in a very creative stage of programming, changing the interface(s) leads to a major modification in each implementation and is likely to produce inconsistencies....

返信