CERN Accelerating science

This website is no longer maintained. Its content may be obsolete. Please visit http://home.cern/ for current CERN information.



next up previous
Next: X-Window Resources Specification Up: Fortran 90 Tutorial: Previous: Arrays of pointers

Pointers as dynamic aliases

Given an array

     REAL, TARGET :: table(100,100)
that is frequently referenced with the fixed subscripts

     table(m:n, p:q)
these references may be replaced by

     REAL, DIMENSION(:, :), POINTER :: window
       :
     window => table(m:n, p:q)
The subscripts of window are 1:n-m+1, 1:q-p+1. Similarly, for

           tar%u
(as defined in Part 7: ``Array Handling II'', CNL213, page 23), we can use, say,

           taru => tar%u
to point at all the u components of tar, and subscript it as

           taru(1, 2)
The subscripts are as those of tar itself. (This replaces yet more of EQUIVALENCE.)

The source code of an extended example of the use of pointers to support a data structure can be obtained by anonymous ftp to jkr.cc.rl.ac.uk (130.246.8.23). The directory is /pub/MandR and the file name is appxg.f90.

In the next article we shall have a more complete look at specification statements.



Janne Saarela
Tue May 16 13:43:26 METDST 1995