Here's a bit of code that I believe is standard conforming
but that one compiler (I don't trust) finds an error in:
module intent_error
contains
subroutine apply_double (x)
real, intent(inout) :: x
call apply_proc (x, double) ! (*) ERROR HERE
end subroutine apply_double
subroutine double (x)
real, intent(inout) :: x
x = 2.0 * x
end subroutine double
subroutine apply_proc (x, proc)
real :: x ! No intent; depends on proc
interface
subroutine proc (y)
real :: y ! (**) No intent, but can fix by supplying it.
end subroutine proc
end interface
call proc (x)
end subroutine apply_proc
end module intent_error
The compiler complains that there is an argument type/rank
mismatch at line (*). If on line (**) I provide the the
same intent as for the procedure "double" then the error
goes away. Is my code standard conforming? I think so but
I'm no expert in these subtleties so I'm turning to the list!
This is the background for this example. I want to perform
various operations on the data at each node in a binary tree.
Rather than replicate the code to traverse the tree for each
operator, I write a single procedure to traverse the tree that
applies a dummy procedure to the data at each node. In this way
the operators can be simple procedures that know nothing about
binary trees. As a result, though, it is impossible to specify
the intent of the dummy argument of the traversing procedure
(apply_proc above) or of the dummy argument of the dummy
procedure (line (**) above) as this depends entirely on behavior
of the actual procedure argument.
Thanks in advance for your help.
Neil
--
Neil Carlson Voice: 505-665-1220
Motorola Computational Materials Group FAX: 505-665-5757
Los Alamos National Laboratory [log in to unmask]
Mailstop B221, Los Alamos, NM 87545 [log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|