pr22146 - elemental subroutines
THOMAS Paul Richard 169137
paul.richard.thomas@cea.fr
Wed Jan 4 14:57:00 GMT 2006
Richard,
I have to thank you for triggering a useful line of investigation, following your pedagogic message. The following program is broken in the second forall block because gfortran turns the interface assignment into a subroutine call, which gfc_trans_forall_1 has no means to deal with. The frontend catches an explicit subroutine call, so I propose to add code to the middle-end to translate a subroutine call. Lahey thinks the code is good.
Cheers
Paul
module type
type itype
integer :: i
end type itype
end module type
module assign
interface assignment (=)
module procedure itype_to_int
end interface
contains
elemental subroutine itype_to_int (i, it)
use type
type(itype), intent(in) :: it
integer, intent(out) :: i
i = it%i
end subroutine itype_to_int
elemental function i_from_itype (it) result (i)
use type
type(itype), intent(in) :: it
integer :: i
i = it
end function i_from_itype
end module assign
program test_assign
use type
use assign
type(itype) :: x(2, 2)
integer :: i(2, 2)
x = reshape ((/(itype (2*j), j = 1,4)/), (/2,2/))
forall (j = 1:2, k = 1:2)
i(j, k) = i_from_itype (x (j, k))
end forall
forall (j = 1:2, k = 1:2)
i(j, k) = x (j, k) ! ICE at trans-stmt.c:2562
end forall
print *, i
end program test_assign
More information about the Fortran
mailing list