Hi,
We recently upgraded our SGI F90 compiler to version 7.4.4m, and
have noticed that code that used to compile fine now doesn't.
When we tried to pass a pointer component of an element of an
array of structures to a subroutine, the compiler complained that
the argument being passed was not definable when the subscript
to the top-level structure was an expression.
For example, look at the attached sample code. The calls
to sub1 don't work when the argument is x(i-1)%y, but do
work for x(j)%y. We only hit this when the structure component
being passed is an array. It doesn't matter whether the top-level
structure is allocated or not, nor does it make a difference if
the array being passed is a pointer or statically sized array.
The actual compiler error we get is:
> call sub1(x(i-1)%y) ! <--- This is NOT allowed.
> ^
> f90-786 f90: ERROR TEST, File = subscript.f90, Line = 58, Column = 21
> An actual argument must be definable when associated with a dummy
> argument that has INTENT(OUT) or INTENT(INOUT).
>
> call sub1(y(i-1)%y) ! <--- This is NOT allowed.
> ^
> f90-786 f90: ERROR TEST, File = subscript.f90, Line = 59, Column = 21
> An actual argument must be definable when associated with a dummy
> argument that has INTENT(OUT) or INTENT(INOUT).
>
> call sub1(y(i-1)%z) ! <--- This is NOT allowed.
>
> f90-786 f90: ERROR TEST, File = subscript.f90, Line = 60, Column = 21
> An actual argument must be definable when associated with a dummy
> argument that has INTENT(OUT) or INTENT(INOUT).
Is the compiler correct in flagging this as an error? Does
anybody know the details of the SGI compiler upgrade to 7.4.4m?
We only hit this error after we upgraded - previous versions
of the compiler accepted this construct without complaint.
The Portland group compiler also compiles this sample code without
error.
Catherine
module interface_module
interface
subroutine sub1(a)
integer, dimension(:), intent(out) :: a
end subroutine sub1
subroutine sub2(a)
use type_module, only: my_type
type(my_type), intent(inout) :: a
end subroutine sub2
end interface
end module interface_module
module type_module
type my_type
integer :: ii
integer, dimension(:), pointer :: y
integer, dimension(10) :: z
end type my_type
end module type_module
subroutine sub1(a)
integer, dimension(:), intent(out) :: a
a(1) = 2
end subroutine sub1
subroutine sub2(a)
use type_module
type(my_type), intent(inout) :: a
a%ii = 0
end subroutine sub2
subroutine sub3(a)
integer :: a
a = 2
end subroutine sub3
program test
use interface_module
use type_module
type ( my_type ) , dimension(:), allocatable :: x
type ( my_type ), dimension(10) :: y
integer :: i, j
i = 2
allocate( x(5))
do j = 1,5
allocate( x(j)%y(3))
end do
call sub1(x(i-1)%y) ! <--- This is NOT allowed.
call sub1(y(i-1)%y) ! <--- This is NOT allowed.
call sub1(y(i-1)%z) ! <--- This is NOT allowed.
call sub2(x(i-1)) ! <--- But this is allowed
call sub3(x(i-1)%ii) ! <--- This is also allowed.
j = i - 1
call sub1(x(j)%y) ! <--- This is allowed.
call sub1(y(j)%y) ! <--- This is allowed.
call sub2(x(j)) ! <--- This is also allowed.
call sub3(x(j)%ii) ! <--- This is also allowed.
end program test
----------------------------------------------------
Catherine Moroney Jet Propulsion Lab, CalTech
MailStop 168-414 4800 Oak Grove Drive
Pasadena, CA 91109-8099
Phone: 818-393-3392
Fax: 818-393-3134
Email: [log in to unmask]
|