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

Generic Statement

marat_a
Beginner
1,912 Views
I'm trying to use features of fortran 2003.
Problem is procedure bound to type.
I'm want my method "init" have couple of implementions
So I've tried to use "GENERIC" statement.


file_handler_module.f90(24): error #5082: Syntax error, found '::' when expecting one of: ( % : . = =>
generic :: init=> init_d,init_e
------------------------^
file_handler_module.f90(24): error #6592: This symbol must be a defined parameter, an enumerator, or an argument of an inquiry function that evaluates to a compile-time constant. [INIT_D]
generic :: init=> init_d,init_e
----------------------------------^
file_handler_module.f90(24): error #6973: This is not a valid initialization expression. [INIT_D]
generic :: init=> init_d,init_e
----------------------------------^
file_handler_module.f90(50): error #6645: The name of the module procedure conflicts with a name in the encompassing scoping unit. [INIT_D]
subroutine init_d(f,name_prefix)
-------------------^
file_handler_module.f90(24): error #6404: This name does not have a type, and must have an explicit type. [INIT_D]
generic :: init=> init_d,init_e
----------------------------------^
compilation aborted for file_handler_module.f90 (code 1)


code
[bash]module file_handler_module
IMPLICIT NONE


    type cfile_handler
         private

        character*55 ::file_name
        integer::file_handle
    contains
!         procedure :: init
        procedure :: handle
        procedure :: name
        generic :: init=> init_d,init_e


    end type cfile_handler

    private current_handle

    integer::current_handle=1000!

    contains
    subroutine init_d(f,name_prefix)
        class (cfile_handler)::f
        character*25 ,intent(in) ::name_prefix
    end subroutine init_d  

    subroutine init_e(f,name_prefix,name_ext)
        class (cfile_handler)::f
        character*25 ,intent(in) ::name_prefix
        character*25 ,intent(in) ::name_ext
    end subroutine init_e  

    integer function handle(f)
        class (cfile_handler)::f
        handle=f%file_handle
    end function handle

    character*55 function name(f)
        class (cfile_handler)::f
        name=f%file_name
    end function name

end module file_handler_module
[/bash]
Question: what's wrong?
is generic statement is supported?
Is there some other wayto do it?
0 Kudos
1 Solution
John4
Valued Contributor I
1,912 Views

In the latest Release Notes there's a note for it:

Note: GENERIC attribute, FINAL procedures and type-bound operators are not supported in this release

mecej4 is right about the required specific binding. gfortran (v4.5) complains about it:

Error: Undefined specific binding 'init_e' as target of GENERIC 'init' at (1)

View solution in original post

0 Kudos
5 Replies
mecej4
Honored Contributor III
1,912 Views
I believe that you need to declare init_d and init_e as type-bound procedures before defining the generic name init on line-14.

Be that as it may, I don't think that the Intel Fortran compiler supports generic type-bound procedures yet (this statement is a candidate for correction if the Intel people comment on it).
0 Kudos
John4
Valued Contributor I
1,913 Views

In the latest Release Notes there's a note for it:

Note: GENERIC attribute, FINAL procedures and type-bound operators are not supported in this release

mecej4 is right about the required specific binding. gfortran (v4.5) complains about it:

Error: Undefined specific binding 'init_e' as target of GENERIC 'init' at (1)

0 Kudos
marat_a
Beginner
1,912 Views
Thanks You Guys!
Now it's all clear. I hope generic statement will be included soon.
0 Kudos
Steven_L_Intel1
Employee
1,912 Views
Yes, it will be in a release later this year.
0 Kudos
marat_a
Beginner
1,912 Views
Great news! I'm loooking forward to it.
0 Kudos
Reply