Paul
(Sorry to have called you Peter earlier).
You are quite correct about this.
It seems to me that the group of WHERE, PURE and ELEMENTAL work fine
together if you stick to objects of the same rank at any one time.
However, the fact that all the compilers have different interpretations for
this program is interesting (more later).
I tried to rewrite your program using a generic function, and found it
difficult to understand your intent. (This may say more about me, than it
does about you!). However if a human being had difficulty understanding the
intent, then the compiler may well have the same problem. The point at
which I had difficulty following was the following:
PURE TYPE(pointer_vector_I4) ELEMENTAL FUNCTION &
& elemental_pointer_fun(index) RESULT(ans)
USE kind_mod, ONLY : I4
USE pointer_mod, ONLY : pointer_vector_I4, ASSIGNMENT(=)
IMPLICIT NONE
INTEGER(I4), INTENT(IN) :: index
ALLOCATE(ans%vect(2_I4))
ans%vect=(/index,-index/)
END FUNCTION elemental_pointer_fun
You have allocated the ans%vect to be of size 2. However the space
available in the result vector in pointer_vector_I4 may or may not be
allocated and it may or may not be 2. It was at that point that the run
time system failed.
If you call this routine as a vector (since it is pure) do you want a vector
of vectors of rank 2?
I seriously suggest that you try to write your program using generic
routines and avoid ELEMENTAL. Of course you have to avoid WHERE also. I
think that if you do that you may have something which you can trust (ie it
is quite reliable and gives the same result on everything). In the meantime
you can send your program to the compiler writers as a challenge!
Hope that this helps and is received in the friendly spirit in which it is
offered!
Alistair
-----Original Message-----
From: Fortran 90 List [mailto:[log in to unmask]] On Behalf Of P
Suckling
Sent: 02 April 2003 12:06
To: [log in to unmask]
Subject: Re: Compiler differences
In response to Alistair's comments.
I tried to use ELEMENTAL procedures because I read that within a WHERE
construct:
The assignment can be a defined assignment only if the routine implementing
the defined assignment is elemental.
I think this rules out the use of module procedures in this instance.
Paul
|