0

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

1
  • 1
    The compiler presumably gives you a line number for the error. Is that line number one of the lines shown? It's superficially similar to one of them. If not, find the line with the error and fix it. Commented Feb 7, 2011 at 18:13

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

With the source code better displayed, we can now see that the parentheses balance. Probably the answer is that array "Ans" has a type other than real, the type of "0.0". Change the constant to be the same type as "Ans". P.S. Exact comparisons of floating point values are risky.
Could it also be same type, different kinds? I remember I had a lots of issues with that in subroutine calls.
Also it seems a bit strange that the compiler would replace Ans(i) with i. Are we really looking at the code snippet that causes the error?
0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.