Recompiling an old Fortran program and getting this error

245 views Asked by At

The section of code looks like this;

DO i = 1 , no2 + 1
   IF ( Isign.EQ.1 ) THEN
      Ans(i) = fft(i)*Ans(i)/no2
   ELSEIF ( Isign.EQ.-1 ) THEN
      IF ( ABS(Ans(i)) .EQ. 0.0 )
&           PAUSE ' deconvolving at responce zero in convlv'
      Ans(i) =  fft(i)/Ans(i)/no2
   ELSE

The compiler is giving me this error; IF ( ABS(i)).EQ. 0.0) ^ Type disagreement between expressions at (^) and (^)

IF ( ABS(i)).EQ. 0.0)
            ^
invalid form for IF statement at (^)

Can someone tell me how to write this "Intrisic function" line correctly to solve this error? I am new to programing and any help would be great! I am using the GNU G77 compiler if that matters? Thanks

2

There are 2 answers

0
Rook On

Declarations, please. They make a world of difference!

Comparing something to a decimal zero is a very bad practice. It is almost always better to compare it to a value of tolerated error (which should be made small enough).

With the above said, try writing a small compilable example which produces the same error and posting it.

3
toochin On

I see more right brackets than left ones in the second error statement

IF ( ABS(i)).EQ. 0.0)

Also, what is the type and kind of Ans(i) and of 0.0? I remember fortran can be a bit strange about type conversions.