From: deltaquattro on
Hi,

I am an engineer and for my job I need learn how to use pointers and
dynamic data structures in Fortran 90/95. I know Fortran 77 and I have
a good reference for Fortran 90/95, "Fortran 90/95 for Scientists and
Engineers" by Stephen J. Chapman, 2nd ed. 2004. However, my problem is
not the language itself, but the fact that I never programmed with
pointers. I need some references which teaches how to do this, either
using Fortran 90, or at least from a generic point of view, without
referring to any particular languages. Instead, almost everything I
found uses C or C++, and I'd rather not learn yet another language,
since I already have to learn Fortran 90/95. Can you indicate something
useful? Thank you very much,

Greetings,

Sergio Rossi

From: Arjen Markus on
As a rule-of-thumb I think you can look at pointers as "aliases":

Pointers in Fortran have a lot of information associated with them
about the
data object they point to.

That is: they do not merely point to some address, but they can
actually be
queried about the size of the data object.

For instance:

real, dimension(:), pointer :: p
real, dimension(100) :: array

p => array
write(*,*) size(p), size(array) ! The same size is printed
p => array(1:20)
write(*,*) size(p), size(array) ! 20 and 100 are printed

You can also use different strides:

p => array(1:100:2) ! Points to the elements 1, 3, ,,, in the
original array

write(*,*) size(p) ! Should print 50

In almost all respects p acts as a different name for the original
variable "array"

array = 0.0
p(1) = 1.0
write(*,*) array(1) ! Prints 1

Regards,

Arjen

From: Tom Micevski on
Arjen Markus wrote:
> As a rule-of-thumb I think you can look at pointers as "aliases":
>
> Pointers in Fortran have a lot of information associated with them
> about the
> data object they point to.
>
> That is: they do not merely point to some address, but they can
> actually be
> queried about the size of the data object.
>
> For instance:
>
> real, dimension(:), pointer :: p
> real, dimension(100) :: array

shouldn't a target (attribute?) be included?
real, dimension(100), target :: array
From: Michael Metcalf on

"deltaquattro" <deltaquattro(a)hotmail.it> wrote in message
news:1147867626.315048.128110(a)i40g2000cwc.googlegroups.com...
> Hi,
>
> I am an engineer and for my job I need learn how to use pointers and
> dynamic data structures in Fortran 90/95.

We can offer an extended example showing all the principles at
ftp.numerical.rl.ac.uk/pub/MRandC/pointer.f90.

Regards,

Mike Metcalf


From: Arjen Markus on
Oops, yes, you are right.

Regards,

Arjen

 |  Next  |  Last
Pages: 1 2 3 4 5 6
Prev: Data type sizes
Next: Shortage of Fortran Programmers