Pointers to functions: Is this the right [f03] syntax?



I am testing the f03 pointer to procedure functionality on the g95
compiler. This feature works smooth for subroutine procedures, but the
compiler seems 'confused' when pointees are functions. It issues the
error "Unexpected array reference".

I posted a message at the g95 forum about this issue. It is not clear
whether the test code --see bellow-- is not f03 standard compliant, or
it is not yet a fully implemented feature in g95.

So, the question is, is this the right syntax for pointer to functions?


module myMod
CONTAINS
real function proc3( arg1 )
integer :: arg1
proc3 = arg1+7
end function proc3
subroutine proc4( arg1 )
real, external :: arg1
print*, 'the func: ', arg1(0)
end subroutine proc4
end module myMod

program myProg
use myMod
PROCEDURE (proc3), POINTER :: p => NULL()
p => proc3
call proc4( p )
print*, 'the func: ', p(0) ! "Unexpected array reference"
end program myProg

.



Relevant Pages

  • Re: Procedure Pointer (Components) with no explicit interface and with implicit typing
    ... in principle, I can assign to it either a function nor a subroutine, e.g. ... "7.4.2.2 Procedure pointer assignment" ... "If proc-pointer-object has an implicit interface and is explicitly ... external:: func, sub ...
    (comp.lang.fortran)
  • Re: Pointer-valued function to access inner components
    ... implicit none ... Return a F90 pointer which points to the diagonal of T. ... a copyin/copyout on array A during the procedure call. ... subroutine dirty_pointer_1d ...
    (comp.lang.fortran)
  • Re: Fortran based MEX w/ COMMON/SAVE
    ... I believe dat (pointer to the array) and the ... SAVE at the begining of each subroutine is a bit unusual to me. ... > to unload it if there isn't a Fortran END or STOP statement. ... interaction w/ Matlab). ...
    (comp.soft-sys.matlab)
  • background process to monitor cursor location
    ... Inside the Document_Opensubroutine, I am using the Timer and DoEvents ... text form fields used for data entry, then a pointer to that field is stored. ... My concern/question: ...
    (microsoft.public.word.vba.general)
  • Re: Copy-in/Copy-out
    ... -|declared as a target or pointer, it should be safe to assign a pointer ... -| Character, Intent:: str* ... -| End Interface ... -| Subroutine SubTarget! ...
    (comp.lang.fortran)