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

generic interface procedure-stmt's must have optional MODULE keyword in current compiler

joseph_battelle
Beginner
580 Views
Reference F2003 syntax for generic interface members:
R1206 procedure-stmt is [ MODULE ] PROCEDURE procedure-name-list
The current compiler doesn't allow one to omit the MODULE keyword for module procedures. Example below.
[fortran]module M1

    type :: c_opt
        integer :: index = 0
    end type 
    
    type, extends(c_opt) :: long_opt
        integer :: val
    end type long_opt
    
    type, extends(c_opt) :: real_opt
        real :: val
    end type real_opt

    !uncomment only one procedure-stmt below at a time to see compiler behavior
    interface opt
        module procedure opt_long, opt_real ! ok
        !procedure opt_long, opt_real ! error #6643:This statement is incorrectly positioned.
                                      ! error #8168: Parentheses are required after the PROCEDURE keyword.      
    end interface opt

contains

    function opt_long (i, v)
        integer, intent(in) :: i
        integer, intent(in) :: v
        type(long_opt) :: opt_long
        opt_long = long_opt(i, v)
    end function
    
    function opt_real (i, v)
        integer, intent(in) :: i
        real, intent(in) :: v
        type(real_opt) :: opt_real
        opt_real = real_opt(i, v)
    end function    

    subroutine foo
        print *, [opt(1,100), opt(2,200)]        
        print *, [opt(1,1.0), opt(2,2.0)]
    end subroutine foo

end module M1

program C4
    use :: M1
    call foo
end program C4

[/fortran]
0 Kudos
1 Solution
Steven_L_Intel1
Employee
580 Views
Thanks - this one we know about. Fixed in a future release.

View solution in original post

0 Kudos
1 Reply
Steven_L_Intel1
Employee
581 Views
Thanks - this one we know about. Fixed in a future release.
0 Kudos
Reply