CVF POINTER(pointer,pointee) command

CVF POINTER(pointer,pointee) command

CVF has this handy POINTER(pointer,pointee) command built into it. I am a little hesitant to use it because users of our program have various compilers and need to be able to recompile using whatever compiler they own. Is the code for this function available either as Fortran or as a callable library? Once pointers to subroutines are assigned, what are other methods for calling them?
As always, thanks in advance for any help.

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Indeed the POINTER statement is not portable, so if that is your goal then you shouldn't use it. See if you can accomplish what you need to do using Fortran 90 pointers. Note that the POINTER statement is not a function, rather it is syntax that the CVF compiler understands so that it can associate a pointer to a pointee, where the pointer is the address of a data structure as defined by the type of the pointee. Also the POINTER statement is used in the declaration portion of a program unit, not within the executable portion.


Thanks for the response James, that is what I suspected. I am pretty new at dealing with pointers. Is there any documentation or are there examples that could help me? I've gotten pointers to a number of subroutines (located in various external dlls) using LoadLibrary and GetProcAddress. Now I need to call them using standard Fortran 90 commands. All the documentation I can find talks about either pointers to data (not what I want) or the POINTER(pointer,pointee) statement which we've already discussed. Can you point me to any other resources?
Thanks in advance,

Standard Fortran doesn't provide an answer, at least not until the next standard is released. Unfortunately the only truly standard solution today is to call a C (or other language with standard pointer capabilities) to do the work for you. Fortran pointers don't map to addresses in the manner necessary for a working implementation. Next best thing is to do a survey of platforms/compilers and see if you can do some preprocessing (#ifdef sort of thing) to creating working code for the possible target platforms.


Below is a copy of my earlier reply in comp.lang.fortran.
James's comments on C are appropriate, but unfortunately there's no standard way to interface with C either :-(.
I believe %VAL is rather common extension though.

"Wolfgang Trautenberg" wrote in message
| Do you know the proper functions for the UNIX derivates as well?
| Maintianing the platform dependent code is not the problem.
| the problem ist the basic functionality on the different plattforms.
| thanks
| Wolfgang

You mean functions for dereferencing procedures? Well, there's
another way of doing this apart from Crays (less elegant but more
portable). The trick is that, once you get address of the
dllexported routine, put it through an arg-list *by value*
and receive it there *as an EXTERNAL and call it*:

integer(ADDRESS_KIND):: lpfnFunction

call someNameExecutor(%VAL(lpfnFunction), arg1, arg2)
subroutine someNameExecutor(someName, arg1, arg2)
external someName !or, better, full interface for someName
call someName(arg1,arg2)
end subroutine someNameExecutor

This is cheating, as you may see (the point is that *value*
of lpfnSomeName is put on the stack; when someNameExecutor
pops it from stack, it thinks it's an address (which it
actually is) ).

The problem is, how to declare that lpfnSomeName should be
passed by value. I used CVF's %VAL extension, which I think
is rather common but my experience on Unixen is shaky.
Perhaps someone else should know a standard way.

Also, I'm not very familiar with behaviour of Unix's .so
libraries. They're similar but by no means identical as
windows dlls, so I don't know if and what's equivalent
of LoadLibrary/GetProcAddress there.


Leave a Comment

Please sign in to add a comment. Not a member? Join today