Home > Archive > Fortran > April 2005 > Q: Cray Pointers Redux
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Q: Cray Pointers Redux
|
|
| Gary L. Scott 2005-04-06, 12:21 pm |
| This is my only use of integer/Cray pointers. Upon return from
"createsharebuffer" below, "bufptr" contains the address of an allocated
shareable memory segment. What other method is there to assign the name
"buffer" to that memory segment other than integer pointer as used here?
If I substitute "buffer" in the call list and use a pointer to point
to that argument list (not sure if that's possible) within
"createsharebuffer", can I force the address of "buffer" to be
associated with required address (this question is because I'd like to
eliminate the user's need to use integer pointers by encapsulating that
complexity within my API).
I really don't use pointers much and I sort of think of
pass-by-reference arguments as pointers, so there's probably some
confusion there.
!
! Example Main Program 1
!
integer :: retcode, bufptr, buffer(1024)
pointer (bufptr,buffer)
call CreateShareBuffer('TestBuf',4096,bufptr,
retcode)
! ...code using array BUFFER goes here.
<snip>
--
Gary Scott
mailto:garyscott@ev1.net
Fortran Library: http://www.fortranlib.com
Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html
Why are there two? God only knows.
If electricity comes from electrons, does morality come from morons?
| |
| glen herrmannsfeldt 2005-04-06, 12:21 pm |
| Gary L. Scott wrote:
> This is my only use of integer/Cray pointers. Upon return from
> "createsharebuffer" below, "bufptr" contains the address of an allocated
> shareable memory segment. What other method is there to assign the name
> "buffer" to that memory segment other than integer pointer as used here?
> If I substitute "buffer" in the call list and use a pointer to point to
> that argument list (not sure if that's possible) within
> "createsharebuffer", can I force the address of "buffer" to be
> associated with required address (this question is because I'd like to
> eliminate the user's need to use integer pointers by encapsulating that
> complexity within my API).
As far as the API, I would think an ALLOCATABLE would be a fine choice,
though a Fortran POINTER should also work. I don't know that
CreateShareBuffer can be written in portable Fortran in either case,
though.
> I really don't use pointers much and I sort of think of
> pass-by-reference arguments as pointers, so there's probably some
> confusion there.
In the VAX/VMS days, with %VAL and %REF there were some tricks like
that. If you have an address in an INTEGER variable, possibly from a
system call, you could pass it %VAL to a routine expecting pass by
reference, and it would work. With %LOC you could find the address of
an array if needed. Not very portable, though.
> !
> ! Example Main Program 1
> !
> integer :: retcode, bufptr, buffer(1024)
>
> pointer (bufptr,buffer)
>
> call CreateShareBuffer('TestBuf',4096,bufptr,
retcode)
>
> ! ...code using array BUFFER goes here.
>
> <snip>
OK, so like PL/I pointers, where variables can have an associated
pointer which that variable then uses when referenced.
-- glen
| |
| Walter Spector 2005-04-06, 12:21 pm |
| "Gary L. Scott" wrote:
>
> This is my only use of integer/Cray pointers. Upon return from
> "createsharebuffer" below, "bufptr" contains the address of an allocated
> shareable memory segment...
Sorry, but I know of no better alternative than Cray pointers - until
you have access to F2003 C Interop.
There is the trick of creating an F90 pointer of a Cray pointers' pointee.
This allows one to isolate the Cray pointer code to a very tiny routine,
and use F90 pointers (and F90 style) essentially everywhere else. But
the Cray pointer is still there.
Walt
-...-
Walt Spector
(w6ws at earthlink dot net)
|
|
|
|
|