David Smith <[log in to unmask]> asked:
> I have a question about defining array operations for derived-type
> objects. Starting with interfaces and functions to define +-*/ for the
> objects, I want to extend them to provide array operations like A+B
> where A and B are arrays of the objects.
>
> My question concerns how to handle the cases where A and B are
> 1-dimensional arrays, 2-dimensional arrays, etc. Do I have to write
> separate functions for each case, with TYPE (X), DIMENSION(:) :: A
> for one case, and then TYPE (X), DIMENSION(:,:) :: A for the next, or
> is there a way to define the array syntax in a single function that
> handles all the different possible ranks for the arrays?
An elemental procedure is almost certainly what you want. See Section
12.7 of the Fortran 95 or draft Fortran 2003 standards.
--
Van Snyder | What fraction of Americans believe
[log in to unmask] | Wrestling is real and NASA is fake?
Any alleged opinions are my own and have not been approved or disapproved
by JPL, CalTech, NASA, Sean O'Keefe, George Bush, the Pope, or anybody else.
|