I have a problem with an old software that used to work with ifort 11 and does not anymore with recent versions.
This software is written in fortan 77 and uses an old trick to manage its memory. This trick leads to the arrays out of their bounds so don’t be shocked!
The idea is, at the beginning of the execution to allocate a big array with a C malloc and to calculate the distance from this array and a reference array (called refarr in the following). To get data with the good type in the allocated array, an equivalence statement is used.
In this software, a loop always return a segmentation fault when it is vectorized and I don’t get why. Here is a simplified source code :
subroutine mysub(datpos,n) c datpos = data position in the allocated array implicit none integer*8 DIST ! distance of the reference array to the allocated array integer datpos,n integer refarr integer*8 adress_arr(1) integer anint,i,j,jj(n) COMMON/MYCOM/DIST,refarr(2) c with this statement, refarr, adress_arr are at the same adress equivalence (refarr(1),adress_arr(1)) c some code her anint = 0 do i=4,n !or anything else here jj(i)=refarr(adress_arr(DIST+datpos)+1+i) if(refarr(adress_arr(DIST+jj(i))+3).EQ.4)THEN anint = 1 ENDIF enddo c more code her return end
With ifort11, this loop was not vectorized and it worked. I obviously found the solution to use the NOVECTOR directive but it does not explain the problem. I found another solution : if I declare a jj array and change the loop this way, the software works (I also needed to use the VECTOR ALWAYS directive because the optimizer says that the vectorization of the modified loop seem unefficient) :
do i=4,n !or anything else here jj(i)=refarr(adress_arr(DIST+datpos)+1+i) if(refarr(adress_arr(DIST+jj(i))+3).EQ.4)THEN anint = 1 ENDIF enddo
Does anyone have an idea of what is the problem ?