This bug occurs on gfortran 4.1 and 4.2 . I think it is not a gfortran specific bug; I checked g77 and g95 on gcc 3.4.6..
I had compiled a legacy fortran77 code and foud a bug; $ gfortran -o TMalign TMalign.f $ ./TMalign 1aquA.pdb 1avaC.pdb | grep ^Ali Aligned length= 89, RMSD= 6.41, TM-score= 0.24257, ID=0.042 $ gfortran -O0 -o TMalign TMalign.f $ ./TMalign 1aquA.pdb 1avaC.pdb | grep ^Ali Aligned length= 91, RMSD= 6.35, TM-score=0.24762 , ID=0.024 $ pgf77 -O1 -o TMalign TMalign.f $ ./TMalign 1aquA.pdb 1avaC.pdb | grep ^Ali Aligned length= 91, RMSD= 6.35, TM-score=0.24762, ID= 0.024 $ pgf77 -O0 -o TMalign TMalign.f $ ./TMalign 1aquA.pdb 1avaC.pdb | grep ^Ali Aligned length= 91, RMSD= 6.35, TM-score=0.24762, ID=0.024 That optimization error is on a bellow subroutine; ******************************************************************** * Dynamic programming for alignment. * Input: score(i,j), and gap_open * Output: invmap(j) ******************************************************************** SUBROUTINE DP(NSEQ1,NSEQ2) PARAMETER(nmax=5000) LOGICAL*1 DIR common/dpc/score(nmax,nmax),gap_open,invmap(nmax) dimension DIR(0:nmax,0:nmax),VAL(0:nmax,0:nmax) REAL H,V *** initialize the matrix: val(0,0)=0 do i=1,nseq1 dir(i,0)=.false. val(i,0)=0 enddo do j=1,nseq2 dir(0,j)=.false. val(0,j)=0 invmap(j)=-1 enddo *** decide matrix and path: DO j=1,NSEQ2 DO i=1,NSEQ1 D=VAL(i-1,j-1)+SCORE(i,j) H=VAL(i-1,j) if(DIR(i-1,j))H=H+GAP_OPEN V=VAL(i,j-1) if(DIR(i,j-1))V=V+GAP_OPEN IF(( D.GE.H).AND.(D.GE.V)) THEN DIR(I,J)=.true. VAL(i,j)=D ELSE DIR(I,J)=.false. if(V.GE.H)then val(i,j)=v else val(i,j)=h end if ENDIF ENDDO ENDDO *** extract the alignment: i=NSEQ1 j=NSEQ2 DO WHILE((i.GT.0).AND.(j.GT.0)) IF(DIR(i,j))THEN invmap(j)=i i=i-1 j=j-1 ELSE H=VAL(i-1,j) if(DIR(i-1,j))H=H+GAP_OPEN V=VAL(i,j-1) if(DIR(i,j-1))V=V+GAP_OPEN IF( V.GE.H) THEN j=j-1 ELSE i=i-1 ENDIF ENDIF ENDDO c^^^^^^^^^^^^^^^Dynamical programming done ^^^^^^^^^^^^^^^^^^^ return END Files; http://zhang.bioinformatics.ku.edu/TM-align/TMalign.f http://zhang.bioinformatics.ku.edu/TM-align/benchmark/1aquA.pdb http://zhang.bioinformatics.ku.edu/TM-align/benchmark/1avaC.pdb -- Summary: Default optimization (level 1) bug of loop optimization (maybe) Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sunjoong at gmail dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32391