On Thu, 2010-08-05 at 15:51 -0700, Tobias Brandt wrote:
> Thank you very much for your quick answer. At least now I know I don't
> have to search for a Fortran 90 solution any longer. :-)
According to the table in ACM Fortran Forum, several Fortran compilers,
that is, the most widely used ones (Cray, g95, gfortran, IBM, Intel,
NAG) have implemented abstract interfaces and procedure pointers. Sun
apparently has not. Many of those have made significant progress toward
complete compliance with the 2003 standard, and have even implemented a
few features of the 2008 standard.
You would have to contact PGI, Pathscale, Silverfrost, Fujitsu...
directly to ask them how much of Fortran 2003 or 2008 they support.
> On 6 August 2010 00:40, Van Snyder <[log in to unmask]> wrote:
> Tobias:
>
> It's not possible in Fortran 90 or Fortran 95, but in Fortran
> 2003 or
> Fortran 2008 you can define an abstract interface thus:
>
> abstract interface
> subroutine F ( Arg )
> real :: Arg
> end subroutine F
> end interface
>
> You can then access that interface either within the same
> scope as its
> definition, or by use or host association, and declare a
> procedure
> pointer, procedure dummy argument, or type-bound procedure by
> reference
> to it:
>
> subroutine Some_Sub ( A, My_F )
> real :: A
> procedure(F) :: My_F
> ....
> end subroutine Some_Sub
>
> See subclauses 4.5.3, 4.5.4, 12.3.2.1 and 12.3.2.3 of
> http://j3-fortran.org/doc/year/04/04-007.pdf.
>
>
>
> On Thu, 2010-08-05 at 15:09 -0700, Tobias Brandt wrote:
> > Hi all,
> > I'm just starting out with Fortran 90 coming from C++ and
> need some
> > help. In C++ you can define a function pointer type like so:
> >
> >
> > typedef void (*mytype) (float);
> >
> >
> > and then use it as a type for function parameters:
> >
> >
> > void some_function (float a, mytype f)
> > {
> > f(a);
> > }
> >
> >
> > void some_other_function (float a, mytype f)
> > {
> > f(2*a);
> > }
> >
> >
> >
> >
> > Now, if I want to do the same in Fortran 90, I have to
> define the same
> > inteface twice:
> >
> >
> > subroutine some_sub (a, f)
> > real :: a
> > interface
> > subroutine f (arg)
> > real :: arg
> > end subroutine
> > end interface
> > call f(a)
> > end subroutine
> >
> >
> > subroutine some_sub (a, f)
> > real :: a
> > interface
> > subroutine f (arg)
> > real :: arg
> > end subroutine
> > end interface
> > call f(2*a)
> > end subroutine
> >
> >
> >
> >
> > Is it possible to somehow "reuse" the interface definition
> by
> > declaring it outside the subroutines or in a different
> module?
> >
> >
> > Regards,
> > Tobias
>
>
>
|