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
Calculational Flow Control Statements
- Component Intrinsic Functions
Print Control - TRACE statement
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:
Each statement contains a maximum of 80 characters.
Statements do not need to start at column 7.
A statement is continued onto the next line by an ampersand (&) at the end of the line.
The symbol for a comment is a currency sign ("$" in United States) - not "C" as in FORTRAN.
A currency symbol may be used anywhere on a line to indicate that all following data is a comment rather than code.
No input or output statements are available.
Addition special Component Intrinsic Functions are available to retrieve component properties.
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.
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.
The following table list the mathematical operations allowed in expressions of the Procedure block statements:
Symbol |
+ |
Addition |
- |
Subtraction |
* |
Multiplication |
/ |
Division |
** |
Exponentiation (raise to a power) |
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.
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:
Flag Setting |
Description |
0 |
The Procedure block has not yet executed (default) or has solved successfully. |
1 |
The Procedure block has solved. |
2 |
The Procedure block did not solve but continue flowsheet calculations within a recycle loop. |
3 |
The Procedure block failed. All calculations stop unconditionally. |
The flow of control within the procedure block can be controlled using the following FORTRAN statements:
Syntax: nn GOTO mm
Branches to statement with label mm unconditionally. "GO TO'" written as two words is also supported.
Syntax: nn CONTINUE
This statement serves as a branch destination or the end of a DO loop. It performs no calculations.
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:
Operator |
Description |
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 |
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.