View previous topic :: View next topic |
Author |
Message |
Jim
Joined: 21 Jul 2006 Posts: 24 Location: USA
|
Posted: Fri Sep 23, 2011 12:41 pm Post subject: Error in IF statement. |
|
|
I am getting the error "The condition in an IF statement should be logical".
IF (ETA(I)<0) THEN
HEIGHT(I)=ETA(I)
HEIGHT(I)=HEIGHT(I)*HUP(1,KI)
ELSE IF (ETA(I)=0) THEN
HEIGHT(I)=ETA(I)
ELSE
HEIGHT(I)=ETA(I)
HEIGHT(I)=HEIGHT(I)*HLO(1,KI)
END IF
Any idea what is wrong here? |
|
Back to top |
|
 |
Jim
Joined: 21 Jul 2006 Posts: 24 Location: USA
|
Posted: Fri Sep 23, 2011 12:43 pm Post subject: Addendum to IF statement. |
|
|
I want to set ETA(I) to different values when the number is less than 0, equal to 0 and greater than 0. |
|
Back to top |
|
 |
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: D�sseldorf, Germany
|
Posted: Fri Sep 23, 2011 1:13 pm Post subject: |
|
|
To compare values, use either the traditional ".eq." or the modern "==". In your case:
Code: | ...
else if (eta(i) == 0) then
... |
Regards - Wilfried |
|
Back to top |
|
 |
colt1954
Joined: 21 Dec 2010 Posts: 81
|
Posted: Wed Oct 12, 2011 6:31 pm Post subject: Agree |
|
|
Try IF (ETA(I) .EQ. 0.0) and IF(ETA(I) .LT. 0.0) etc |
|
Back to top |
|
 |
|