[Bug fortran/32391] Wrong code with optimization on i686-pc-linux-gnu
------- Comment #16 from sunjoong at gmail dot com 2007-06-20 23:34 -------
Thank all of you.
I could understand what make it different.
There is no 'volatile' statement in fortran77 syntax of gfortran.
Of course, volatile is not fortran77 standard, I think,
but a certian implimentation support volatile.
http://web.utk.edu/~prdaves/Computerhelp/Fortran_Reference/fortran_statements.htm
I made a bellow c function and checked it happends.
Yes, the problem is same
but in the c function, I can use 'volatile' keyword and be happy.
(I hope the next version of gfortran support volatile statement in fortran 77.)
C language version of decide subroutine (or decide_ function);
#define NMAX 5000
extern struct {
float SCORE[NMAX][NMAX];
float GAP_OPEN;
int INVMAP[NMAX];
} dpc_;
void
decide_(int *i, int *j,
int iDIR[NMAX + 1][NMAX + 1], float VAL[NMAX + 1][NMAX + 1])
{
volatile float D;
float H,V;
D = VAL[*j - 1][*i - 1] + dpc_.SCORE[*j - 1][*i - 1];
if(iDIR[*j][*i - 1] == 1) H = VAL[*j][*i - 1] + dpc_.GAP_OPEN;
else H = VAL[*j][*i - 1];
if(iDIR[*j - 1][*i] == 1) V = VAL[*j - 1][*i] + dpc_.GAP_OPEN;
else V = VAL[*j - 1][*i];
if((D >= H) && (D >= V))
{
iDIR[*j][*i] = 1;
VAL[*j][*i] = D;
} else {
iDIR[*j][*i] = 0;
if(V >= H) VAL[*j][*i] = V;
else VAL[*j][*i] = H;
}
}
DP subroutine use above decide subroutine;
SUBROUTINE DP(NSEQ1,NSEQ2)
PARAMETER(nmax=5000)
common/dpc/score(nmax,nmax),gap_open,invmap(nmax)
dimension iDIR(0:nmax,0:nmax),VAL(0:nmax,0:nmax)
REAL H,V
C** initialize the matrix:
val(0,0)=0
do i=1,nseq1
idir(i,0)=0
val(i,0)=0
enddo
do j=1,nseq2
idir(0,j)=0
val(0,j)=0
invmap(j)=-1
enddo
C** decide matrix and path:
DO j=1,NSEQ2
DO i=1,NSEQ1
call decide(i,j,iDIR,VAL)
ENDDO
C** extract the alignment:
i=NSEQ1
j=NSEQ2
DO WHILE((i.GT.0).AND.(j.GT.0))
IF(iDIR(i,j).eq.1)THEN
invmap(j)=i
i=i-1
j=j-1
ELSE
H=VAL(i-1,j)
if(iDIR(i-1,j).eq.1)H=H+GAP_OPEN
V=VAL(i,j-1)
if(iDIR(i,j-1).eq.1)V=V+GAP_OPEN
IF(V.GE.H) THEN
j=j-1
ELSE
i=i-1
ENDIF
ENDIF
ENDDO
return
END
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32391
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
Reply to: