Implicit and Conditional Variables

Variables and Math Operations

Numeric variables are implicitly typed according to the default Fortran convention. Integer numeric variables must have names beginning with the letters I-N e.g:

symb n = -12 

Real numeric variables must have names beginning with the letters A-H, O-Z e.g.

symb radius = 35.97 

Assigning a real value to an integer variable results in a warning and a change of value e.g.

symb innerrad = 4.7e-3     /* will result in 
symb innerrad = 0 /* (rounds to nearest integer) 

Variables are case sensitive Use ‘$’ before variable name to represent value of the variable, e.g.

symb radius = 1.0     
symb pi = 3.14159
symb circum = s2. * $pi * $radius

All symbol entries must be blank delimited, e.g.

symb val3 = sqrt ( 5. * $val1 / ( $val2 - 3.9 ) ) 

Space must be present between all numbers, variables, operands and parentheses. Sequence of operations conform to Fortran standard. The symb statement can also take the form:

symb vname = <expression>   

The <expression>  may be composed of the following mathematical operations:

cos, sin, tan, exp, alog, alog10, acos, asin, atan, atan2, sqrt, abs, sign, int, nint, max, min, **, *, /, +, and -.

Parentheses may be used to control the sequence in which the expression is evaluated (innermost parentheses evaluated first). Within parentheses, the evaluation is done from left to right for each operator listed above in the order listed.

The real number equivalence of all arguments to cos, sin, tan, exp, alog, alog10, acos, asin, atan, atan2, sqrt, abs, int, and nint are used.

Note that Symbol does not allow a real expression in which a negative number is taken to an exponential power (even the power of 2), as the real number representation of the exponent is used in the expression and math libraries do not allow this operation.

Multiple arguments may be provided to the max, min, atan2, and sign functions.

These arguments must be separated by commas (which are themselves blank delimited) and be bounded by parentheses.

Examples of arithmetic expressions are:

symb x = sqrt ( 5. ** 2 + 10. ** 2 )    /* compute hypotenuse of triangle
symb maxm = max ( $m1 , $m2 , $m3 )     /* compute maximum of 3 values
symb pi = 4. * atan ( 1. )              /* compute value of pi 

Conditional Variables

The two forms of the symb statement discussed above can also have conditional operators appended to them.

The SYMB statement with a conditional operator has the form:

symb vname  =  value  if datum1  op  datum2
symb vname  =  if  datum1  op  datum2 

where op is any of the conditional operators: eq, ne, lt, le, gt, and ge whose meanings correspond to their usage in Fortran.

datum1 and datum2 can be either numeric or character data.

If the values being compared are numeric, they are compared as real numbers (i.e., the real number representation of an integer is used in the comparison).

The effect of the conditional operator is:

  1.  If the conditional is true, then the symbol value assignment is made.
  2.  If the conditional is not true, then this symb statement is skipped and the assignment is not made. One other type of conditional assignment is based on the current existence of a variable name.

The conditional can take the following two forms:

symb vname = value if exist
symb vname = value if noexist

where exist and noexist refer to the variable name.

In the first case, if vname currently exists, the conditional is true and the value assignment is made. If vname does not exist, no assignment is made.

The second case is the opposite. Multiple conditional operators can be appended to an expression. This type of expression takes the form:

symb   vname  =    if  datum1  op  datum2  if  datum3  op  datum4  etc.

For a symbol equivalence with multiple conditionals, all conditionals must be true before the value assignment is made.