- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
please, answer me...
may I use (how?) var, that holds any proc address?
smth like this:
WHAT_IS_THIS_TYPE PointerToSub
external someProc
PointerToSub = someProc
...
call PointerToSub(...)
thanks in advance...
may I use (how?) var, that holds any proc address?
smth like this:
WHAT_IS_THIS_TYPE PointerToSub
external someProc
PointerToSub = someProc
...
call PointerToSub(...)
thanks in advance...
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have to use "Cray (Integer) pointers". To reference a procedure, use LOC(). To dereference it, use a cray pointer. In the meantime, you can use an integer to store it (or, better, integer(INT_PTR_KIND)):
Jugoslav
!Referencing external someProc integer(int_ptr_kind()):: PointerToSub PointerToSub = loc(someProc) ... !Dereferencing external aProc; pointer(paProc, aProc) paProc = PointerToSub call aProc(...) !actually calls someProc
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thank You for answering...
but excuse my misunderstanding...
may You be more specific?
the task is:
- there is the global var pToSub (in some module for example)
- I "call" this pointer inside some sub Sub1
- and I want to change this pToSub in the different sub,
_outside_ Sub1 (Sub2 for ex.)
moreover, this var (and it's call) is resides in fortran DLL, but changing and the sub itseft are in the stand-alone independence (non-fortran) module...
may You write some code fragment?
thanks once more...
but excuse my misunderstanding...
may You be more specific?
the task is:
- there is the global var pToSub (in some module for example)
- I "call" this pointer inside some sub Sub1
- and I want to change this pToSub in the different sub,
_outside_ Sub1 (Sub2 for ex.)
moreover, this var (and it's call) is resides in fortran DLL, but changing and the sub itseft are in the stand-alone independence (non-fortran) module...
may You write some code fragment?
thanks once more...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Assuming you know how C pointers to subs work, the slight difference from Fortran Cray pointers are that the latter are dual (thus slightly less comprehensive). In the example above, paSub is, basically, of type INTEGER and can be used in integer operations. aSub is a procedure whose starting address is always equal to contents of paSub (i.e. = *paSub).
You can put the pointer-pair declaration as above in a module. Changing the contents of paSub causes the aSub to change address:
Jugoslav
You can put the pointer-pair declaration as above in a module. Changing the contents of paSub causes the aSub to change address:
MODULE m INTERFACE SUBROUTINE aSub() END SUBROUTINE END INTERFACE POINTER (paSub, aSub) END MODULE m !======= PROGRAM Proggie USE m EXTERNAL foo, bar paSub = LOC(foo) CALL aSub() paSub = LOC(bar) CALL aSub() END PROGRAM Proggie !======= SUBROUTINE foo() WRITE(*,*) "Foo" END SUBROUTINE foo !======= SUBROUTINE bar() WRITE(*,*) "Bar" END SUBROUTINE barGives the output:
Foo BarOf course, you can change value of paSub wherever you like.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it's now clear for me...
thanks!
thanks!

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page