Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29361 Discussions

Integer variable becomes "undeclared" in the middle of procedure

John4
Valued Contributor I
683 Views

Even though I understand that all compilers have bugs, I would have never expected to see this one. When compiling the following module, I get errors about i, j and k not being declared:

[fortran]module mod1 implicit none private integer, public :: nx, ny, nz type, public :: ArrayType real, allocatable :: a_g(:,:,:), a_k(:,:,:) end type type, public :: Test type(ArrayType) :: array contains procedure :: dosomething end type contains subroutine dosomething(this) class(Test), intent(INOUT) :: this integer :: i, j, k real, allocatable :: a_l(:,:,:), a_n(:,:,:) continue allocate (a_l(-1:nx+2, -1:ny+2, -1:nz+2), a_n(-1:nx+2, -1:ny+2, -1:nz+2)) associate (array => this%array, & a_g => array%a_g, & a_k => array%a_k) forall (i = 1:nx, j = 1:ny, k = 1:nz) a_l(i, j, k) = a_k(i, j, k) - a_g(i, j, k) end forall do k = 1, nz do j = 1, ny do i = 1, nx a_n(i, j, k) = SQRT(a_g(i, j, k) * a_g(i, j, k-1)) enddo enddo enddo end associate end subroutine end module mod1[/fortran] It seems to me that the compiler gets confused by the FORALL construct within an ASSOCIATE construct. Or am I missing something?

0 Kudos
4 Replies
Steven_L_Intel1
Employee
683 Views
I've seen some similar bugs, but this one is quite amusing. Probably something about not checking enough outer scopes. I will let the developers know - thanks.
0 Kudos
Steven_L_Intel1
Employee
683 Views
My testing shows that this bug is not present in the code branch for a new release later this year. Is this problem blocking your development? Removing the IMPLICIT NONE is a workaround.
0 Kudos
John4
Valued Contributor I
683 Views

There seems to be something wrong with my newsfeeds updates, so I just found about your reply while looking for something else.

The "undeclaration" happened while moving some module variables to a derived type, and then using ASSOCIATE to avoid massively adding the this% prefix to the code. FORALL makes things easier to read, but since ASSOCIATE is actually quite useful here, a set of DO constructs will "do" just fine.

I've noticed that the release "later this year" seems to fix a lot of things... May I ask, how late this year?

0 Kudos
Steven_L_Intel1
Employee
683 Views
The current plan is "third quarter".
0 Kudos
Reply