Next: Null and locum values
Up: Features of the library
Previous: Features of the library
Parameters and fields have a defined data type (_DOUBLE, _REAL etc.).
Families of subroutines are available for transferring the values of
parameters, columns and fields between a catalogue and Fortran variables
in an application program invoking the CAT interface. These Fortran
variables may be of a variety of types. The type of the column or
parameter need not correspond to the type of the Fortran variable; the
interface will automatically attempt a type conversion. However,
depending on the types involved, a conversion may not be possible for
some values. The matrix of possibilities is shown in
Table
. This matrix is used for all conversions:
both GET and PUT operations for both columns (or fields) and parameters.
Table:
Conversion matrix for copying different types
|
|
Destination |
Start or initial type |
|
type |
UBYTE |
BYTE |
UWORD |
WORD |
INTEGER |
REAL |
DOUBLE |
LOGICAL |
CHAR |
|
UBYTE |
yes |
maybe |
maybe |
maybe |
maybe |
maybe |
maybe |
yes |
maybe |
|
BYTE |
maybe |
yes |
maybe |
maybe |
maybe |
maybe |
maybe |
yes |
maybe |
|
UWORD |
yes |
yes |
yes |
maybe |
maybe |
maybe |
maybe |
yes |
maybe |
|
WORD |
yes |
yes |
maybe |
yes |
maybe |
maybe |
maybe |
yes |
maybe |
|
INTEGER |
yes |
yes |
yes |
yes |
yes |
maybe |
maybe |
yes |
maybe |
|
REAL |
yes |
yes |
yes |
yes |
yes |
yes |
maybe |
yes |
maybe |
|
DOUBLE |
yes |
yes |
yes |
yes |
yes |
yes |
yes |
yes |
maybe |
|
LOGICAL |
yes |
yes |
yes |
yes |
yes |
yes |
yes |
yes |
yes |
|
CHAR |
maybe |
maybe |
maybe |
maybe |
maybe |
maybe |
maybe |
yes |
maybe |
Key:
- yes
- conversion is always possible,
- maybe
- conversion may be possible.
Note that converting a character string to a character string may result
in an error because truncation may occur.
|
If a type conversion fails the appropriate exception value (null or
locum, see Section
, below) is substituted for the missing
value. The error status is not set (that is, it remains ok) and no
error message is generated.
This procedure is followed consistently for all type conversions. It is
adopted because, in practice, conversion failures are common.
The rules for converting to and from the _LOGICAL data type are as
follows
- From logical
-
- Conversion from LOGICAL to CHARACTER*
gives `TRUE' or
`FALSE' if
is greater than or equal to 5 and `T' or `F'
otherwise.
- Conversion from LOGICAL to INTEGER is defined such that true
converts to 1 and false converts to 0.
- Conversion from LOGICAL to a numeric type except INTEGER is
equivalent to converting LOGICAL to INTEGER and then INTEGER to the
required numeric type.
- To logical
-
- Any character string beginning with `T' (upper or lower case)
converts to true; any other string converts to false.
- Any even INTEGER converts to false; any odd INTEGER converts
to true (this behaviour is specified for compatibility with HDS).
- Conversion for other numeric types is equivalent to
conversion from the type to INTEGER and then from INTEGER to
LOGICAL.
Next: Null and locum values
Up: Features of the library
Previous: Features of the library
CAT [1ex
Starlink User Note 181
A.C. Davenhall
4th April 2001
E-mail:ussc@star.rl.ac.uk
Copyright © 2001 Council for the Central Laboratory of the Research Councils