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?
|
|
0
|
|
|
|
Reply
|
garyscott (569)
|
4/3/2005 3:01:37 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
|
|
0
|
|
|
|
Reply
|
gah (12258)
|
4/3/2005 10:08:44 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)
|
|
0
|
|
|
|
Reply
|
w6ws_xthisoutx (399)
|
4/4/2005 1:35:37 AM
|
|
"Gary L. Scott" <garyscott@ev1.net> wrote in message
news:11501anshfik7f7@corp.supernews.com...
F90/95, whether thro' Fortran-style pointers or otherwise, can accomplish
everything that Cray/integer (sure, former Digital wah wah's lay claim to
their invention, but today they're the same cowering Intel wah wah's who
once thought that they had concocted the ieee fp standard, that the Itanium
processor would never see the light of day, that the alpha processor and
not Britannia ruled the bathtub, etc., testimony that the now
self-proclaimed 'gold standard' and 'world class experts' in Fortran
compiler production could never substantiate anymore than Bush and cohorts
could produce a single Iraqi WMD) pointers can do with one exception: they
can point to absolute and relative addresses; Fortran 90/95 can't.
Consequently, F90/95 compilers often additionally support integer pointers
(eg, LF 95/.NET, etc.) for a host of reasons that users' demand, the
Fortran standard be damned.
Ciao,
Gerry T.
--
"As a native of the snow belt of upstate New York, I too claim the feisty
independence of the Northerner. I was raised, I like to say, breathing
cold, clear Canadian air." Camille Paglia.
|
|
0
|
|
|
|
Reply
|
gfthomas (618)
|
4/4/2005 8:24:22 AM
|
|
|
3 Replies
52 Views
(page loaded in 0.093 seconds)
|