Next: Subject-Oriented Programming
Previous: The Data Analysis System for the SUBARU Telescope
Table of Contents --- Search --- PS reprint


Astronomical Data Analysis Software and Systems V
ASP Conference Series, Vol. 101, 1996
George H. Jacoby and Jeannette Barnes, eds.

Controlling Foreign Tasks with the IRAF cl

David L. Terrett

Rutherford Appleton Laboratory, Chilton, Didcot, Oxfordshire OX11 0QX, United Kingdom

Abstract:

The IRAF command language (cl) can run non-IRAF programs but not interact with them in any way; any i/o that the program does is directed to the user's terminal. This paper describes how, by using another process as a front-end, applications written for a different data reduction environment (in this case, the Starlink ADAM system) can be made to behave as if they were native IRAF applications. The messages and signals that the cl sends to an application and appropriate actions taken by the front-end are outlined and the various ways in which the front-end can manipulate the state of the IRAF parameter system are described.

1. Introduction

As astronomical data reduction packages have become larger and more complex it has become increasingly difficult for users to make use of more than one package. The barriers to using a second package include a new command language, a different look-and-feel to the applications and an unfamiliar documentation layout. This leads to ever-increasing duplication of functionality between packages as the users of any particular package demand that the full range of applications they require are available in their chosen environment in spite of the same applications already being available in other systems. Furthermore, by restricting their choice in this way they may not be using the best available algorithms for the job in hand. If the applications from other environments could be run from within the user's current environment the choice of applications would be wider and there would, perhaps, be less wasteful duplication.

The architectures of IRAF and the Starlink software environment are very similar in that they both have tasks which run as independent processes which are sent commands by the command language, and individual commands each have a set of named parameters. In view of these similarities we have attempted to construct an ``adaptor'' that enables the IRAF command language (cl) to load and control Starlink applications.

2. The Adaptor Process

The adaptor communicates with the IRAF cl using the clio protocol, and communicates with Starlink applications using the Starlink inter-process messaging system; to the cl it behaves like a normal IRAF task and to the Starlink application it appears to be a command language (Figure 1). It is written in tcl, which has been extended to include commands for sending and receiving messages with both messaging systems.

 
Figure 1: IRAF/Starlink adaptor architecture.

2.1. The clio Protocol

The IRAF cl (as implemented on UNIX) communicates with a task by reading from and writing to the task's standard output and standard input. Each message has a 2 byte header, a 2 byte byte count and then the message itself as a stream of 2 byte characters. This protocol is implemented in os$zfiopr.c. Anything the task writes to its standard error stream will be written to the terminal window running the cl and can be used for debugging output.

3. Typical cl/Task Dialog

A task is loaded the first time one of the commands it supports is used and the cl sends it a series of set commands to set the task's environment. For example,

set editor=vi
set clobber=no
set host=/iraf/iraf/unix/
set iraf=/iraf/iraf/
These are followed by a chdir command to set the task's current directory, e.g.,
chdir rlssp0!/home/user/dlt/
When the setup phase is complete the cl sends:
_go_
At this point the adapter process loads the Starlink application and is ready to receive commands for the application task to execute.

A typical command looks like:

cadd in=comwest label="Kappa - Cadd" mode='ql' $nargs=0
i.e., a command name followed by a list of names and values of parameters. All the parameters that are either hidden and have values, or have had their values specified on the command line that was typed by the user will appear on this list. ``mode'' and ``$args'' are special parameters that exist for all tasks.

The adapter now sends all the parameter values to the Starlink application, followed by the instruction to start executing the command. The adaptor now switches to waiting for messages from the task. In the case of Starlink applications, the sorts of messages that can be expected are:

Once a ``bye'' or ``error'' command has been set to the cl, the adaptor reverts to waiting for the next command from the cl. This can be any of the messages discussed so far or ``bye'' which is a signal to the adaptor to unload the application task and exit.

4. Interacting with the Parameter System

A task can interact with the parameter system in a number of ways in addition to simply retrieving the values of parameters.

A parameter's value can be set by sending, for example:

in=comwest
This can be used to change the default value (displayed in brackets) when the cl prompts for a parameter value (but only if the parameter's mode is ``query''; if it is ``hidden'' the cl will simply return the value set when asked for the value, and not prompt the user) and to set parameters to values calculated by an application and make them available to cl procedures.

The various parameter attributes can be obtained by, for example:

=in.p_type
to get the parameter's type. The adaptor needs this information in order to translate the representation of certain data types (e.g., boolean) before sending the value to the Starlink application.1 A complete list of parameter attributes can be found in the cl help under `parameters'.

It is also possible to change some parameter attributes (but not p_name, p_type or p_xtype), but the changes may not have the desired effect while a task is active. Also, the storage for the prompt string ( p_prompt) is allocated when the task's parameter file is read and cannot be increased.

5. Signals

The adaptor must also handle the SIGTERM signal that the cl sends to a task when the user attempts to interrupt a task by typing Control C. The cl expects the task to respond with an ``error'' command and return to a state where it is ready for another command to the cl. If this is impossible, it is acceptable for the adaptor to exit after sending the ``error'' command; when the next command is typed, the cl will report that the task has died unexpectedly and re-load it.

Acknowledgments:

I would like to thank Doug Tody, NOAO, for encouraging me to embark on this project, describing the clio protocol for me and answering my many questions about the internal workings of IRAF.

1The value of p_type is not necessarily the same as the type field in the parameter file; for example. ``file'' is changed to ``string'' by the cl.


Next: Subject-Oriented Programming
Previous: The Data Analysis System for the SUBARU Telescope
Table of Contents --- Search --- PS reprint
Wed Jul 3 08:11:35 MST 1996