association of pointers
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
association of pointers         


Author: John Harper
Date: Nov 13, 2007 15:09

In an attempt to understand pointers, I wrote the following:

PROGRAM testassoc3
INTEGER, TARGET :: beast = 666
INTEGER, POINTER :: ptr => NULL()
ALLOCATE(ptr)
ptr = beast
PRINT "(A,I4)",' After ptr = beast, ptr is',ptr
PRINT "(A,L2)",' associated(ptr,beast) is',associated(ptr,beast)
PRINT "(A,L2)",' associated(ptr) is',associated(ptr)
END PROGRAM testassoc3

The output from four different f95 compilers was

After ptr = beast, ptr is 666
associated(ptr,beast) is F
associated(ptr) is T

That appears to suggest that ptr was associated with something at the
time of printing, but not with beast even though its value was that
of beast. What was ptr associated with?
Show full article (0.92Kb)
5 Comments
Re: association of pointers         


Author: glen herrmannsfeldt
Date: Nov 13, 2007 16:16

John Harper wrote:
> PROGRAM testassoc3
> INTEGER, TARGET :: beast = 666

beast has value 666 and may be the target of a pointer
> INTEGER, POINTER :: ptr => NULL()
> ALLOCATE(ptr)

A new variable is allocated, pointed to by ptr.
> ptr = beast

The value of beast is copied to the variable pointed
to by ptr.
> PRINT "(A,I4)",' After ptr = beast, ptr is',ptr
> PRINT "(A,L2)",' associated(ptr,beast) is',associated(ptr,beast)
> PRINT "(A,L2)",' associated(ptr) is',associated(ptr)

ptr and beast point to different variables, so are not associated.
Show full article (0.93Kb)
no comments
Re: association of pointers         


Author: nospam
Date: Nov 13, 2007 16:18

John Harper mcs.vuw.ac.nz> wrote:
Show full article (3.27Kb)
no comments
Re: association of pointers         


Author: jtravs
Date: Nov 14, 2007 11:35

On Nov 14, 12:18 am, nos...@see.signature (Richard Maine) wrote:
> I'll get it down in a more permanent form. From the Fortran 2003
> Handbook (no, you can't buy it yet - this is a sneak preview):

Hi, this is the first I have heard of the Fortran 2003 Handbook. I
presume it's a book by you? Out of interest do you have a plan of when
it might be available? I'd very much like to get a copy.

Best regards,
John
no comments
Re: association of pointers         


Author: Paul van Delst
Date: Nov 14, 2007 12:23

jtravs wrote:
> On Nov 14, 12:18 am, nos...@see.signature (Richard Maine) wrote:
>> I'll get it down in a more permanent form. From the Fortran 2003
>> Handbook (no, you can't buy it yet - this is a sneak preview):
>
> Hi, this is the first I have heard of the Fortran 2003 Handbook. I
> presume it's a book by you? Out of interest do you have a plan of when
> it might be available? I'd very much like to get a copy.

Not to preempt one of the co-authors, but I also am waiting. Until then have a lookee at:

http://www.springer.com/west/home/computer/programming?SGWID=4-40007-22-141350063...

(and also any amazon.com besides the US one. All the "other" amazons have it listed as "to
be published". But not the US one. Weird.)

cheers,

paulv
no comments
Re: association of pointers         


Author: nospam
Date: Nov 14, 2007 15:37

jtravs gmail.com> wrote:
> On Nov 14, 12:18 am, nos...@see.signature (Richard Maine) wrote:
>> I'll get it down in a more permanent form. From the Fortran 2003
>> Handbook (no, you can't buy it yet - this is a sneak preview):
>
> Hi, this is the first I have heard of the Fortran 2003 Handbook. I
> presume it's a book by you? Out of interest do you have a plan of when
> it might be available? I'd very much like to get a copy.

Springer says May. And I think we are actually on schedule (the current
one). It's been slow. :-(

The writing is done. Just needs final editing, index, and then whatever
Springer does to get it out the door.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
no comments