Hello,

I have encountered following problem with ifort compiler v 12.1.3 on x86_64 GNU/Linux.

When I compile the following minimal example with the options "-O2 -implicitnone" I get

different results for the two loops in the "compute_matrix_H" subroutine (i.e. the two DO loops,

where the first one has as upper bound the variable N, while a fixed value is used in the second one).

It seems that with "-O1", or adding "-g" to "-O2" resolves this issue as well as allocating the working

array mp_v3 dynamically as indicated in the subroutine. Also not allocating the (unused) array mat_SS

seems to have a positive effect.

The included module "parameters" is stored in an external file and contains solely the declaration

INTEGER, PARAMETER :: adequate = KIND(1D0)

INTEGER :: NDim

INTEGER :: NGWPs

It seems that the problem is also resolved when this declaration is moved into the

main program and the inclusion of the "parameters" module is therefore avoided.

Any ideas why this occurs?

Thanks in advance,

M.

!------------------------------------------------------------------------------- PROGRAM gdr USE parameters ! INTEGER, PARAMETER :: adequate = KIND(1D0) ! INTEGER :: NDim ! INTEGER :: NGWPs COMPLEX(adequate), ALLOCATABLE :: mat_SS(:, :) NDim = 2 NGWPs = 16 ALLOCATE(mat_SS(NGWPs, NGWPs)) CALL compute_matrix_H(NDim) DEALLOCATE(mat_SS) CONTAINS SUBROUTINE compute_matrix_H(N) INTEGER, INTENT(IN) :: N COMPLEX(adequate) :: N_mat(1:N, 1:N), mp_v3(1:N, 1:N, 1:N) REAL(adequate) :: x, y, beta INTEGER :: M, l, k ! COMPLEX(adequate), ALLOCATABLE :: N_mat(:, :), mp_v3(:, :, :) ! ALLOCATE(n_mat(N, N), mp_v3(N, N, N)) WRITE(*, *) "size of mp_v3 = ", SIZE(mp_v3) x = 3 y = 2 beta = 0.01_adequate mp_v3(1, 1, 1) = 6*x*beta mp_v3(2, 1, 1) = 2*y mp_v3(1, 2, 1) = 2*y mp_v3(2, 2, 1) = 2*x mp_v3(1, 1, 2) = 2*y mp_v3(2, 1, 2) = 2*x mp_v3(1, 2, 2) = 2*x mp_v3(2, 2, 2) = 6*y*beta N_mat = 0 DO k = 1, N DO l = 1, N N_mat(l, k) = mp_v3(l, l, k) END DO END DO WRITE(*, '(2(2F22.15,/))') ABS(N_mat) N_mat = 0 DO k = 1, 2 DO l = 1, 2 N_mat(l, k) = mp_v3(l, l, k) END DO END DO WRITE(*, '(2(2F22.15,/))') ABS(N_mat) END SUBROUTINE END PROGRAM