Fortran 2003



Hi,

I'm trying to use the procedure pointer to create a method for a
derived type. The code is as follows:


module mymod

type :: mytype
integer :: i
procedure(seti_interface), pointer :: seti
end type

interface
subroutine seti_interface(this,i)
import
type(mytype), intent(out) :: this
integer, intent(in) :: i
end subroutine seti_interface
end interface

contains

subroutine seti_interface(this,i)
type(mytype), intent(out) :: this
integer, intent(in) :: i
this%i=i
end subroutine seti_interface

end module mymod

program Test_03
use mymod
implicit none

type(mytype) :: m

call m%seti(5)

end program Test_03


Unfortunately this doesn't compile (complaining about a name conflict
for seti_interface). I'm using Intel Visual Fortran v11.

Any ideas about where I'm going wrong?

Thanks in advance,

Cliff
.



Relevant Pages

  • Re: The importance of not being explicit
    ... subroutine mysub ... end interface ... end module mymod ... This was in a minimisation routine and the only symptom was that the ...
    (comp.lang.fortran)
  • Re: The importance of not being explicit
    ... subroutine mysub ... end interface ... end module mymod ... This was in a minimisation routine and the only symptom was that the ...
    (comp.lang.fortran)
  • The importance of not being explicit
    ... subroutine mysub ... end subroutine subr ... end interface ... end module mymod ...
    (comp.lang.fortran)
  • Re: Fortran 2003 questions
    ... Does this mean that all routines in a interface ... subroutine foo ... No, because, as you say, x needs an explicit interface. ... whether a procedure pointer counts as a procedure. ...
    (comp.lang.fortran)
  • Re: passing a pointer to a function using iso_c_binding
    ... Your C++ function expects a pointer to a function by value. ... however) or change your Fortran interface ... and then pass the procedure pointer. ... the interface block to specify a subroutine by reference rather ...
    (comp.lang.fortran)