Procedure Data Code

The Code section of the Procedure block contains the FORTRAN-based statements which perform the calculations. The following is a list of various elements of the Procedure block code.

 

Procedure Topics

 

Code Overview

Assignment Statements

Variables and Arrays

Mathematical Operators

Calculation Termination

- The Solution Flag

Calculational Flow Control Statements

- GOTO statement

- CONTINUE statement

- IF statement

- DO statement

Intrinsic Functions

- Component Intrinsic Functions

- FORTRAN Intrinsic Functions

Print Control - TRACE statement

 

 

 

Code Overview

 

 

 

The statement RETURN signals the end of the CODE section. If there are two RETURN statements, only the lines prior to the first RETURN are executed.

 

The code statements follow the conventions of FORTRAN 77 with the following differences:

 

image\EDIT03.gif Each statement contains a maximum of 80 characters.

image\EDIT03.gif Statements do not need to start at column 7.

image\EDIT03.gif A statement is continued onto the next line by an ampersand (&) at the end of the line.

image\EDIT03.gif The symbol for a comment is a currency sign ("$" in United States) - not "C" as in FORTRAN.

image\EDIT03.gif A currency symbol may be used anywhere on a line to indicate that all following data is a comment rather than code.

image\EDIT03.gif No input or output statements are available.

 

Addition special Component Intrinsic Functions are available to retrieve component properties.

 

image\BMDMLINE.gif

 

Assignment Statements

 

image\BMDMLINE.gif

 

The standard FORTRAN conventions apply to assignment statements.

 

Syntax

 

nn VAR1 = expression

nn ARRAY(i,j) = expression

nn RRATES(i) = expression

 

where "nn" is an optional statement number.

 

Operator Precedence

The operations on a given statement are executed in the following order:

 

1. Expressions within parenthesis ( )

2. Functions

3. Exponential (**)

4. Multiplications and divisions (*, /)

5. Additions and subtractions (+, -)

 

For calculations with the same precedence, expressions are evaluated from right to left for exponentials and left to right for all others.

 

 

Variables and Arrays

 

image\BMDMLINE.gif

 

Variable and array names may be up to 8 characters in length. As in FORTRAN, names beginning with I - N implicitly are assumed to be integers, others are assumed to be real.

 

You may override the default type by explicitly declaring variables on REAL or INTEGER statements at the start of the code section. Arrays must be declared on REAL, INTEGER or DIMENSION statements at the start of the code section. Arrays may be one or two-dimensional.

 

Syntax

 REAL  rname1,rname2(i),rname3(j,k)

 INTEGER iname1,iname2(i),iname3(j,k)

 DIMENSION name1(i),name2(j,k)

 

Variables names defined in the Defined Procedure Variables table on the Kinetic Procedure Definition Window may not be declared as arrays. The names below are reserved and may not be declared or used on the left hand side of an Assignment Statement.

 

Reserved Variable Names

ACTIVE NOC RLCP RTEMP XL1FUG

CUMLEN NOR RLFRAC RVCOND XL1MFR

DELX ORDER RLMRAT RVCP XL2ACT

DRDT PREEXP RLMW RVMRAT XL2CON

DRDX RAVRAT RLVISC RVMW XL2FUG

ICPFA  RDATA RLVOLU RVVISC XL2MFR

IDATA RGAS RLVRAT RVVOLU XLACT

IDBASE RL1FRA RMRATE RVVRAT XLCONC

ILBASI RL1MRA RMW RWRATE XLFUG

INDX RL1MW RPRES STOICH XLIQ

IOUT RL1VOL RRATES SUPPLE XLIQ1

IPHASE RL1VRA RRDAT1 TDIAM XLIQ2

IRDAT1 RL2FRA RSDAT1 TEXPON XLMFRA

IRPHAS RL2MRA RSDAT2 TLEN XTOTAL

ISOLVE RL2MW RSPGR VOLUME XVAP

ISTEP RL2VOL RSURF XCONC XVCONC

IVBASI RL2VRA RSVRAT XL1ACT XVFUG

MAXNOR RLCOND RTABS XL1CON XVMFRA

 

See Predefined Variables for details of what these names represent.

 

 

Mathematical Operators

 

image\BMDMLINE.gif

 

The following table list the mathematical operations allowed in expressions of the Procedure block statements:

 

image\LINE03.gif

Symbol

image\LINE03.gif

+

Addition 

-

Subtraction 

*

Multiplication 

/

Division 

**

Exponentiation (raise to a power) 

image\LINE03.gif

 

 

image\BMDMLINE.gif

 

Calculation Termination

 

image\BMDMLINE.gif

 

Syntax: nn RETURN

 

This statement signals the end of the code section of the procedure block and must appear as the last statement in the section. Only one RETURN statement is allowed in the Procedure block. The Solution Flag for the calculator should be set according to the user-defined value of ISOLVE at the end of the calculation.

 

image\BMDMLINE.gif

 

Solution Flag

 

image\BMDMLINE.gif

 

You can use the variable ISOLVE to control the flowsheet calculations, based on the Procedure block results. It is initialized to zero upon each entry into the calculation and you will have to assign all subsequent values using an Assignment Statement. The following table lists all the allowed values for the flags:

 

image\LINE02.gif

Flag Setting

Description

image\LINE02.gif

 

The Procedure block has not yet executed (default) or has solved successfully.

The Procedure block has solved.

The Procedure block did not solve but continue flowsheet calculations within a recycle loop.

The Procedure block failed. All calculations stop unconditionally.

image\LINE02.gif

 

image\BMDMLINE.gif

 

Calculational Flow Control Statements

 

image\BMDMLINE.gif

 

The flow of control within the procedure block can be controlled using the following FORTRAN statements:

 

GOTO statement

CONTINUE statement

IF statement

DO statement

 

image\BMDMLINE.gif

 

GOTO Statement

 

Syntax: nn GOTO mm

 

Branches to statement with label mm unconditionally. "GO TO'" written as two words is also supported.

 

image\BMDMLINE.gif

 

CONTINUE Statement

 

Syntax: nn CONTINUE

 

This statement serves as a branch destination or the end of a DO loop. It performs no calculations.

 

image\BMDMLINE.gif

 

IF Statement

 

Syntax: nn IF (expression) conditional clause

 

This statement allows logical branching during calculations. If the parenthetic expression is true, it executes the conditional clause, which may be any Procedure block statement except RETURN, IF or DO. The following table lists all the logical operators allowed in the expression:

 

image\LINE04.gif

Operator

Description 

 

image\LINE04.gif

Equal to

.NE.

Not equal to

.LT.

Less than

.GT.

Greater than

.GE.

Greater than or equal to

.LE.

Less than or equal to

.AND.

Both true

.OR.

Either true

.EQV.

Equivalent

.NEQV.

Not equivalent

.NOT.

True/false toggle

image\LINE04.gif

 

 

DO Statement

 

Syntax: nn DO mm iname = j,k

 

This statement indicates the beginning of DO loops having a range extending through statement label mm. "i" and "j" are initial and final indices respectively. The incremental step index "k" is optional and defaults to 1.