This appendix discusses the syntax permitted for expressions passed to the expression parser.
Expressions are input to CAT as argument
EXPR of subroutine
CAT_EIDNT (see Section 7).
Expressions have an algebraic format, and comprise: columns, vector column elements, parameters
and constants linked by arithmetic operators and mathematical functions. For example, suppose that a
catalogue contained scalar columns called
z and parameters called
q. Some valid
Remember that in CAT column and parameter names are not case-sensitive. Thus the following column or parameter names would all be considered equivalent:
FLUXwould be ‘
FLUX + 2.0’.
The arithmetic operators are:
(’ and ‘
)’) may be used as required.
Table 16 lists the mathematical functions which are provided. The letters denote data types permitted, coded as follows: B = BYTE, H = half INTEGER, I = INTEGER, R = REAL, D = DOUBLE PRECISION, C = CHARACTER, L = LOGICAL. The appearance of N as an argument means that any numeric type (BHIRD) is permitted, as a result it means that the type is the widest type of any of the arguments. R/D means that the result is REAL unless one or more arguments is of DOUBLE PRECISION type in which case D is the result.
|B = BYTE(N)||convert to BYTE data type|
|H = HALF(N)||convert to INTEGER*2 data type|
|I = INT(N)||convert to INTEGER data type|
|R = REAL(N)||convert to REAL data type|
|D = DBLE(N)||convert to DOUBLE PRECISION data type|
|I = NINT(N)||convert to nearest INTEGER|
|N = MIN(N,N)||the function must have precisely two arguments|
|N = MAX(N,N)||the function must have precisely two arguments|
|N = MOD(N,N)||remainder|
|N = ABS(N)||absolute value|
|R/D = SQRT(N)||square root|
|R/D = LOG(N)||natural logarithm|
|R/D = LOG10(N)||logarithm to the base 10|
|R/D = EXP(N)||exponential|
|R/D = SIN(N)||sine; argument in radians|
|R/D = COS(N)||cosine; argument in radians|
|R/D = TAN(N)||tangent; argument in radians|
|R/D = ASIN(N)||arc-sine; result in radians|
|R/D = ACOS(N)||arc-cosine; result in radians|
|R/D = ATAN(N)||arc-tangent; result in radians|
|R/D = ATAN2(N,N)||arc-tangent (two arguments) result in radians|
|I = IAND(I,I)||bitwise logical AND|
|I = IOR(I,I)||bitwise logical OR|
|I = XOR(I,I)||bitwise logical exclusive OR|
|R/D = DTOR(N)||degrees to radians conversion|
|R/D = RTOD(N)||radians to degrees conversion|
|C = UPCASE(C)||convert character string to upper case|
|C = STRIP(C)||leading and trailing spaces are removed|
|C = SUBSTR(C,N,N)||returns characters from positions argument 2|
|to argument 3 inclusive, with the positions|
|starting at 1|
|L = NULL(*)||.TRUE. if argument is NULL|
|D = HMSRAD(N,N,N)||converts 3 arguments hours, minutes and|
|seconds to radians|
|D = DMSRAD(C,N,N,N)||first argument is the sign (‘’ or ‘-’ ),|
|converts degrees, minutes and seconds to radians|
|D = GREAT(N,N,N,N)||great circle distance between two spherical|
|coordinates. All the input arguments and the|
|return argument are in radians. The input arguments|
|are in the order: ,|
|D = PANGLE(N,N,N,N)||Position angle of point from point|
|. All the input arguments and the return|
|argument are in radians. The input arguments are in|
|the order: ,|
The expression string can contain constants, column and parameter names, operators, functions, and parentheses. In general the usual rules of algebra and Fortran should be followed, with some minor exceptions, as noted below.
CAT__SZCMPcharacters long, and may consist of letters, digits, and underscores, except that the first character must not be a digit.
MAGNITUDE. The first element of the vector is numbered one.
.FALSE.but abbreviations of these words are allowed down to
.GE. .NE.) as well as in the Fortran 90 forms (for example, ).
.AND. .OR. and .NOT.are provided as an alternative:
.OR.where spaces or parentheses separate them from names or constants, but the logical constants and the
.NOT.operator need the enclosing dots to distinguish them from other lexical items in all cases.
INTfunction should be used (as appropriate) if an INTEGER result is required.
MINmust have exactly two arguments.
-2**3will come out as ‘+8’ not ‘-8’.
The operator precedence rules are show in Table 17. The rules of Fortran 90 are used as far as possible; in this table the larger numbers denote higher precedence (tighter binding).
|2||start/end of expression|
Note that all operators except
** associate from left to right, but
** and functions associate from right