Erratum for an August 2007 Fortran Forum article
The article "A Fortran binding for the GNU scientific library" in the August 2007 issue of SIGPLAN Fortran Forum contains an error in the section "Non-interoperable function arguments and Fortran polymorphism". Under the heading "Usage: contrasting Fortran and C", a function my_fun is described (in the second table of the subsection). This function must be amended to read
function my_fun(x,params) real(fgsl_double) :: my_fun real(fgsl_double), intent(in) :: x class(fgsl_void) :: params select type (params) class is (my_void) my_fun = params%d(1) + & x*(params%d(2) + ...)))) class default stop 'incorrect extension of fgsl_void' end select end function my fun
The reason for this lies in the fact that the library internally uses a polymorphic pointer of base class to the function parameters. According to section 220.127.116.11 of the Fortran 2003 standard, the actual argument used internally must be of the same type as the dummy argument, or one of its extensions.
As a consequence, the dummy argument used in the user-provided function must also be of base class. Making use of select type is then unavoidable. This particular example is not a case of run time type identification (RTTI), but of run time class identification (perhaps to be abbreviated as RTCI).