Anthony Stone wrote:
> Aleksandar, what are the advantages of your code over f90gl? Or is it
> simply intended as an example of the way to use the Fortran 2003
> features, rather than a replacement for f90gl?
BTW, I use f90gl, and have hacked its source to fit my needs and to bind
to freeglut/openglut instead of "classic" glut, so I am well aware of
its existence :-) The specific code I provided is just an example, it
was not a full interface to OpenGL and thus cannot replace f90gl. But
this is only because I have not had the time to do the job fully. That
said:
I personally very much hope that f90gl will eventually go out of use and
be replaced with a simple Fortran module that provides a binding for
OpenGL using the new C Interop features of Fortran 2003. The same goes
for the "Fortran" binding of MPI, and a whole lot of "bindings". This
binding would be as close to the C binding as possible, avoiding adding
any kind of "Fortran"-like features unless really necessary. For
example, the f90gl (which is well-designed, don't get me wrong),
introduces a new derived type GLU_QUADRIC (sadly J3 never added
typedef/typealiases to Fortran...). This is not so even in the C
binding, glu_quadric is an incomplete type and operated on only using
handles (pointers). It may be a struct but it is probably just a
typedef. It is best to declare quadric arguments as TYPE(C_PTR) in
Fortran rather than try to add type-checking and such by inventing new
types. Similarly, the basic Fortran binding to MPI should not use
assumed-shape arrays, generic interfaces, or other features. The very
bottom layer of the binding should aim at providing *direct* access to
the underlying facility. Additional abstractions and a more modern
interface can then be layered on top of that.
The reasoning is simple, though maybe not agreeable to all (I am always
willing to argue :-). The OpenGL or MPI forums designed a library meant
to be a "C" library, that is, the primary binding is a C binding. The
Fortran and C++ bindings are kind of hacked, and honestly, bad. They
are also unnecessary. C++ can call MPI through the C binding. Then some
group, not the MPI Forum, that knows C++, can design a standardized C++
binding to the C binding that the forum published. Similarly for
OpenGL---I or J3 or someone else that actually knows Fortran can design
a Fortran binding to the C binding. This is only possible now that we
actually standize C interop.
There are also pragmatic reasons. The Fortran bindings in f90gl or mpich
requre wrappers, nonstandard hacks, compiler-specific conditional
compilation. If you do not believe me just look at the (C) source of
f90gl. It is messy and nonportable and needs to be changed whenever a
new version of a compiler comes out (thus there is one version for
Intel version 6, one for 7...). I do not like it one bit.
Best,
Aleks
|