This section introduces all the subroutines in the CAT library, with the subroutines arranged by function. For each subroutine the calling sequence and a brief description is given. Standard names are used for the calling arguments. A complete description of each subroutine is given in Appendix A. Following normal Starlink practice the subroutine arguments are arranged in the order:
given,
given and returned,
returned,
global (or running) status.
This manual describes version 9.0 of the CAT library. The original specification for the library is described in the document The Starlink Subroutine Interface for Manipulating Catalogues (StarBase/ACD/3.4)[2]. Version 9.0 of CAT is a subset of this full implementation and some of the items present in it serve no apparent purpose. These items correspond to features which were in the original specification but which are not currently implemented. These items may be implemented in future versions and have been included so that applications written now will be compatible with future versions of the library.
Two INCLUDE files of symbolic constants are available for use with these subroutines: CAT_PAR
and
CAT_ERR
. CAT_PAR
contains symbolic constants which specify the size of various items, codes
corresponding to various types of items, values for various flags etc. CAT_ERR
contains symbolic
constants corresponding to the various error codes which the CAT library can set. Section 3.2 explains
how to access these files. I recommend that you print out copies of these files and have them to hand
when writing applications. The comments included in the files should be sufficient to explain
the purpose of each constant. If your application needs to access one of these values you
should always use the appropriate symbolic constant; never hard-code the actual value into
your code. The values may (and probably will) change in subsequent releases of the CAT
library.
The CAT subroutine names follow the normal Starlink format of a prefix, an underscore (‘_’) and a five-character routine name (see SGP/16[9]).
For most routines, the first letter of the main body of the subroutine name denotes the sort of item that the subroutine operates on, according to the following scheme:
T | - | total, or whole catalogue, |
P | - | part (column or parameter), |
C | - | columns (entire columns), |
R | - | rows, |
Q | - | parameters, |
E | - | expressions (algebraic expressions), |
S | - | selections, |
The ADAM routines (see Section 7.6) are exceptions; they have names chosen to be consistent with the corresponding routines in other ADAM libraries.
CAT identifies catalogues and components by various sorts of identifiers; INTEGER numbers, each with a unique value. In the calling arguments for the subroutines the following names are usually used for the various sorts of identifier:
GI | - | generic, |
CI | - | catalogue, |
PI | - | part (column or parameter), |
FI | - | column (F for field), |
QI | - | parameter, |
EI | - | expression, |
SI | - | selection |
The following rules apply:
Every open catalogue is identified to CAT by a catalogue identifier; an INTEGER number with a
unique value. The catalogue identifier is subroutine argument CI
in the following notes. The ADAM
routines (see Section 7.6, below) provide an alternative to CAT_TOPEN
for opening or creating a
catalogue.
CAT_TOPEN (CNAME, STATE, MODE; CI; STATUS)
CAT_TRLSE (CI; STATUS)
CAT_RSET (CI, ROWS, STATUS)
These subroutines interact with the ADAM parameter system. They provide alternatives to CAT_TOPEN
(see Section 7.5, above) for opening a catalogue. They are provided for compatibility with other
ADAM libraries and each provides analogous functionality to equivalently named routines in other
ADAM libraries.
CAT_ASSOC (PCNAME, MODE; CI; STATUS)
MODE
must always be ‘READ’
in version 9.0 of CAT.
CAT_CREAT (PCNAME; CI; STATUS)
CAT_EXIST (PCNAME, MODE; CI; STATUS)
These routines perform general ‘high-level’ inquiries on a catalogue. CAT_TCOLS
is not strictly
necessary; its function is provided by CAT_TDETL
. However, it is convenient in practice.
CAT_TDETL (CI, COLFLG; NUMROW, NUMCOL, NUMIND, NUMPAR, DATE; STATUS)
COLFLG
should be set to
CAT__GPHYS
.
CAT_TROWS (CI; NUMROW; STATUS)
CAT_TCOLS (CI, COLFLG; NUMCOL; STATUS)
COLFLG
should
be set to CAT__GPHYS
.
CAT_TIDTP (GI; IDTYP; STATUS)
CAT_TIDNT (CI, GNAME; GI; STATUS)
CAT_TNDNT (CI, IDTYP, N; GI; STATUS)
GI
is set to null identifier
CAT__NOID
.
CAT_TIDPR (GI; CI; STATUS)
CAT_TATT<t> (GI, ATTRIB, VALUE; STATUS)
CAT_TIQA<t> (GI, ATTRIB; VALUE; STATUS)
CAT_PNEW0 (CI, PTYPE, PNAME, DTYPE; PI; STATUS)
CAT_CNEWA (CI, FNAME, EXPR, DTYPE, CSIZE, DIMS, SIZEA, NULL, EXCEPT,
SCALEF, ZEROP, ORDER, UNITS, EXTFMT, PRFDSP, COMM; FI; STATUS)
CAT_CNEWS (CI, FNAME, DTYPE, CSIZE, UNITS, EXTFMT, COMM; FI; STATUS)
CAT_TATTC
is used to set the character size.
CAT_CINQ (FI, SZDIM; CI, FNAME, GENUS, EXPR, DTYPE, CSIZE, DIMS, SIZEA,
NULL, EXCEPT, SCALEF, ZEROP, ORDER, UNITS, EXTFMT, PRFDSP, COMM,
DATE; STATUS)
CAT_PPTAt (CI, QNAME, CSIZE, DIMS, SIZEA, UNITS, EXTFMT, PRFDSP, COMM,
VALUE; QI; STATUS)
CAT_PPTSt (CI, QNAME, VALUE, COMM; QI; STATUS)
CAT__SZVAL
will be adopted unless
CAT_TATTC
is used to set the character size.
CAT_PINQ (QI, SZDIM; CI, PNAME, DTYPE, CSIZE, DIMS, SIZEA, UNITS, EXTFMT,
PRFDSP, COMM, VALUE, DATE; STATUS)
CAT_EIDNT (CI, EXPR; EI; STATUS)
The selection routines return a selection identifier which corresponds to the set of rows which satisfy
the criteria of the selection. There are two routines for generating a selection: CAT_SELCT
and
CAT_SFNDt
.
CAT_SELCT
allows complex selections to be performed according to complicated
criteria. A logical (or boolean) expression defining the selection is supplied and all
the rows in the catalogue for which this expression evaluates to .TRUE.
are selected.
CAT_SFNDt
allows a simple range of values to be selected for a sorted column. Usually CAT_SELCT
will execute more slowly than
CAT_SFNDt
because whereas CAT_SELCT
must necessarily access every row in the catalogue,
CAT_SFNDt
can exploit the ordering of the chosen column to immediately identify the required rows (remember
the mnemonic F for Find and Fast, S for Select and Slow).
CAT_SLIST
allows a specialized application to create a non-standard selection.
All the selection routines may operate on either an entire catalogue or some previous selection. They all uniformly and consistently provide an option to create a second selection of all the rejected rows.
CAT_SELCT (CI, EI, REJFLG; SI, NUMSEL, SIR, NUMREJ; STATUS)
CAT_SFNDt (CI, FI, MINRNG, MAXRNG, REJFLG; SI, NUMSEL, SIR, NUMREJ;
STATUS)
CAT_SLIST (NUMSEL, SELIST, CRIT, REJFLG, CI, SI, SIR, NUMREJ, STATUS)
CAT_SINQ (SI; CI, EXPR, NUMSEL, COMM, DATE; STATUS)
The index generation routine generates an index from a given numeric column and returns an identifier which allows the rows in the catalogue to be accessed as though they were sorted on the column. In CAT version 9.0 only temporary indices, which persist for the duration of the application which generated them, are supported.
CAT_INEW (FI, DISP, ORDER; II; STATUS)
CAT_IINQ (II; CI, FI, ORDER, NUMSEL, COMM, DATE; STATUS)
These routines manipulate a single row in a catalogue. They are based around the concepts of the ‘current row’ and the ‘current row buffer’. The current row is a single row in a catalogue which CAT is currently operating on. A copy of the current row is kept in a buffer within CAT. The various row and field manipulation routines operate on the copy of the current row in the current row buffer. As appropriate, the current row buffer can be copied out to the catalogue and a new row copied into the current row buffer.
The ‘current row buffer’ is an abstract concept to describe how CAT behaves when an application calls it. It is my solution to obtaining an arbitrary number of fields of arbitrary type in a single pass through a catalogue. The trick is separating reading rows in the catalogue into the ‘current row buffer’ and having the GET and PUT operations operate on this buffer. Applications should be written in the form:
None of the solutions to this problem are ideal and the disadvantage of the one adopted is that the resulting subroutine interface is quite ‘low level’ and verbose to use. However, it does allow an arbitrary number of columns of arbitrary type to be extracted in a single pass through the catalogue.
New rows can be added to an existing catalogue only by appending them to the end of the catalogue.
When a catalogue is opened (that is, an identifier is obtained for it), its first row is copied into the
current row buffer. Thus, if the current row buffer is accessed without first GETting a specified row
with CAT_RGET
the contents of the first row will be obtained.
CAT_RGET (CI, ROWNO; STATUS)
CI
may be either a
catalogue, selection or index identifier.
CAT_RAPND (CI; STATUS)
CI
must
necessarily be a catalogue identifier.
The basic routines for getting and putting values GET from and PUT to the current row buffer. The following rules apply:
CAT_EGT0t
,
Section 8.2.5 prescribes how applications should handle null values.
CAT_EGT0<t> (GI; VALUE, NULFLG; STATUS)
GI
may be
either: an expression, column, vector column element or parameter identifier.
CAT_EGT0F (GI; VALUE, NULFLG; STATUS)
GI
may be either: an expression, column, vector column element or parameter
identifier.
CAT_PUT0<t> (FI, VALUE, NULFLG; STATUS)
FI
may be either a
column or vector column element identifier.
For convenience two additional routines are provided for getting values which include the
row from which the value is to be obtained. Otherwise they are similar to CAT_EGT0<t>
and CAT_EGT0F
(indeed they are wrap-arounds of CAT_RGET
followed by CAT_EGT0<t>
or
CAT_EGT0F
).
CAT_FGT0<t> (CI, ROWNO, GI; VALUE, NULFLG; STATUS)
CI
may be either: a
catalogue, selection or index identifier. GI
may be either: an expression, column, vector
column element or parameter identifier.
CAT_FGT0F (CI, ROWNO, GI; VALUE, NULFLG; STATUS)
CI
may be either: a catalogue, selection or index identifier. GI
may be either:
an expression, column, vector column element or parameter identifier.
This set of routines provide access to any textual information associated with the catalogue14. They try to keep access to the textual information as simple as possible. The text is accessed one line at a time, with each line corresponding, for example, to a single FITS COMMENT or HISTORY keyword. No facilities are provided to interpret a line. It is assumed that each line will either be displayed to the user or copied to another catalogue.
CAT_GETXT
returns a single line of text. Subsequent calls to CAT_GETXT
work sequentially through
the textual information, returning the lines in sequence. The application cannot specify
that it wants a particular line. However CAT_RSTXT
is provided to ‘reset’ the sequence for
a catalogue, so that the textual information can be read through an arbitrary number of
times.
Each line has a class associated with it. When a line is read the class is returned; an application cannot prescribe that it wants a class of a particular value. The classes supported vary for the different catalogue formats, though on output the standard classes COMMENT and HISTORY are always available. Appendix C lists the classes supported by individual catalogue formats.
A call to CAT_PUTXT
appends a line of textual information to the end of the existing textual information
for a catalogue. The only way to add new textual information is by appending it to the
end.
In all these routines CI
must be a catalogue identifier.
CAT_GETXT (CI; FINISH, CLASS, TEXT; STATUS)
CAT_PUTXT (CI, CLASS, TEXT; STATUS)
CAT_RSTXT (CI; STATUS)
CAT_GETXT
would return the first line of textual information.
CAT_SZTXT (CI, ACCESS; LINESZ; STATUS)
CAT_TUNES (CATPRM, VALUE; STATUS)
CAT_TUNEG (CATPRM; VALUE; STATUS)
CAT_TYFMT (DTYPE, CSIZE; STRING, POSN; STATUS)
CAT_SRNGt (CI, FI, MINRNG, MAXRNG; FIRSTR, LASTR; STATUS)
CAT_SFNDt
,
but it returns the first and last rows within the specified range, rather than generating a
selection.
14These routines were not included in the original specification for the CAT subroutine interface, as described in The Starlink Subroutine Interface for Manipulating Catalogues (StarBase/ACD/3.4)[2]; they were added later.