IF THEN ELSEIF ELSE

IF statement handling in PetroVisor.

Syntax

 IF [conditional expression] THEN [true case statement] ELSE [false case statement] END IF

Description

First the IF function evaluates the condition expression. In case of a true return statement the true case statement after THEN is executed, in case of a false result the false case statement after ELSE is executed. The condition is closed with END IF.

Examples

IF  "produced oil per time increment" in "STB" < "produced water per time increment" in "STB" THEN

 "produced water per time increment" in "STB"

ELSE

 "produced oil per time increment" in "STB"

END IF

This condition evaluates if the "produced oil per time increment" signal for the certain time step is smaller then the "produced water per time increment" signal. In case of true, when the "produced oil per time increment" signal for the certain time step is smaller then the "produced water per time increment" the true case statement is executed, which means that the  "produced water per time increment" signal is returned. In case the evaluation returns false the false case statement after ELSE is executed, which returns the "produced oil per time increment" signal. Finally, the condition expression has to be closed by END IF.

The IF condition can not only handle signals but also constants, for example:

IF  "produced oil per time increment" in "STB" < "produced water per time increment" in "STB" THEN

 "produced water per time increment" in "STB"

ELSE

 367.0

END IF

NOTE: When constants are returned instead of signals it is required to enter a decimal number with at least one digit.

This condition evaluates if the "produced oil per time increment" signal for the certain time step is smaller then the "produced water per time increment" signal. In case of true, when the "produced oil per time increment" signal for the certain time step is smaller then the "produced water per time increment" the true case statement is returned, which is the "produced water per time increment" signal. In case of false the false case statement after ELSE is returned, which is the constant 367.0 (please pay attention to the decimal number requirement). Finally, the condition expression has to be closed by END IF.

More complex IF condition example:

IF  "produced water per time increment" in "STB" > 100 THEN

 "produced water per time increment" in "STB"

ELSEIF

 "produced water per time increment" in "STB" > 20 THEN

         20.0

ELSEIF

 "produced oil per time increment" in "STB" > 5 THEN

 5.0

ELSE

 0.0

END IF

This condition evaluates if the "produced water per time increment" signal for the certain time step is larger than 100. In case of true  the actual "produced water per time increment" signal value is the return , in case of false the first ELSEIF statement is validated. If this first ELSEIF condition is true the return value is 20.0. If false the next ELSEIF condition is checked. If the value is again true, in this case larger than 5,  the return value is 5.0 and the condition tree is left. In case no ELSEIF condition was met the ELSE statement is returned, which is zero and the condition tree is left. Finally, the condition expression has to be closed by END IF.

The input data and the result data of the above mentioned example in tabular form:

Date

"produced water per time increment" in "STB"

RESULT

01/01/2012

145

145

01/02/2012

23

20.0

01/03/2012

12

5.0

01/04/2012

2

0.0