KUIP overview

by Alfred Nathaniel / CERN CN-AS

What is KUIP?

Many users of CERN software have probably been in contact with KUIP without knowing it. KUIP is a user interface package contained in the CERN library and is used in interactive programs like PAW, GEANT or CMZ. The task of KUIP is to prompt the user for the next command, call the action routine linked to that command and pass the arguments to it. KUIP is also responsible for executing macro scripts (KUMACs) and storing vectors which can be accessed from other library packages like SIGMA and COMIS. The coming KUIP release contains an enhanced Motif-based user interface. The main features of this new interface are:

Object browser

The browser allows one to traverse a hierarchical tree of objects. The objects contained in the current directory are displayed as icons. Operations on the selected object can be choosen from a menu of actions depending on the object type (class). Application specific classes and their corresponding menus can be described in the Command Definition File (CDF). Two examples of applications using the browser for their objects are PAW and GEANT. In PAW the prime objects are histograms and N-tuples contained in ZEBRA/RZ files while GEANT allows browsing of the lists of volumes, materials, tracks, etc.

Command panels

Panels to fill in the arguments for each command are derived from the existing CDF.

Object identification in graphics window

KUIP/Motif is interfaced to the IGPID mechanism of HIGZ which allows to identify the object pointed at in the graphics window. The menu of possible actions on the picked object can be described in the Command Definition File (CDF). * Adding application specific Motif code: KUIP/Motif allows one to provide a useful Motif interface without any Motif code inside the application itself. If necessary, application specific Motif code can be integrated by binding it to buttons or menu entries described in the CDF. The Motif part of KUIP is written in the C language. In order to facilitate the implementation of new features in the Motif interface, essential parts of the basic KUIP have also been rewritten in C. This implies that from now on the installation of KUIP based applications like PAW, interactive GEANT, the FATMEN shell, ZFTP etc. requires a C compiler. Before the presence of a C compiler was not mandatory because C code was restricted to Unix systems or special versions, like the X-windows interface for HIGZ.

Because KUIP relies heavily on dynamic allocation of structures, string handling and indirect calls to subroutines through pointers the transition to C on all platforms brings a number of advantages:

The Motif part needs access to the CDF information stored by basic KUIP. It is very convenient to access this information directly through a C structure.

A number of Fortran routines had to be duplicated or even triplicated in order to avoid recursive calls. The problem of recursion also led to the intricate difference between KUEXEC and KUEXEL. The first one can execute macros but cannot be used in an action routine while the second one can execute any command except EXEC. Since C is intrinsically recursive these problems disappear completely. In addition, many KUIP tasks can be solved more elegantly using recursivity, e.g. descending the command tree, to find a match for the abbreviation typed by the user.

Although KUIP was using the dynamic memory management of ZEBRA to store the command tree there were still a multitude of manifest constants in form of CHARACTER dimensions. This affected both functionality in case the string length was too short and performance in case the string was overdimensioned. Remember that for CHARACTER*256 CHLINE the assignment CHLINE = 'ABC' requires not only to copy the three characters ABC but also to fill the remainder of CHLINE with 253 blanks. Using pointers and dynamic memory allocation through malloc, C allows arbitrary dimensions with high efficiency. By convention every C string is terminated by a null byte to indicate the string length, i.e. if chline = "ABC" in C we have to look at four bytes to find out that lline = strlen(chline) is 3. The Fortran version of KUIP was spending a sizable fraction of its whole execution time to determine the logical length of CHARACTER strings, since LLINE = LENOCC(CHLINE) has to start at the end in order to locate the last non-blank character.

As has been the case already for applications using the HIGZ/X11 interface on VM/CMS Fortran programs calling C routines have to establish a runtime environment. In order to do that the main program should contain CALL INITC as the very first call to a subroutine.

An application has to describe the command tree structure and the parameters for each command in the CDF. The KUIP compiler KUIPC translates the CDF text into source code which then has to be compiled and linked with the application program. KUIPC has also been rewritten in C and can now generate either the old-style Fortran code or alternativly produce C code to make the command tree known to KUIP.

The Fortran option is mainly intended for application managers who don't want to change their library installation procedures in order to envoke the C compiler.

Parts of the CDF specific to the Motif interface will be honoured only in the C code output by KUIPC. A major advantage of using C code (even without Motif interface) is a sizeable reduction of the start-up time. While the Fortran code involves hundreds of subroutine calls to store the command definitions, the C code contains statically initialized structures which can be merged into the command tree by changing a few pointers only. The drawback of this approach is that the CDF must be run through KUIPC whenever the implementation of new features require a change of the structures used by KUIP.

The new KUIP version is intended to be backwards compatible to the old one but because of the large amount of new code involved we cannot exclude that some incompatibilities remain. We want to urge all users to test the new KUIP library and KUIP based applications like PAW available in the new area before going into production.

KUIP and PAW with OSF/MOTIF

The new release of the KUIP package includes an interface to OSF/MOTIF (X Toolkit Intrinsics and Motif) available on most Unix workstations (HP, IBM 6000, Silicon Graphics, etc.). PAW is the first application which has been modified to make use of this new interface. It provides a menu-driven mode of interaction as well as a command mode with a command history mechanism. Various new features have also been included.

All the applications based on KUIP should easily be modifiable to access this Motif interface. Very few changes are required at initialization time and in the main program of the application (the new routine KUWHAM, which gives control to Motif, has to be called instead of KUWHAT or KUWHAG). The main features of this interface is an automatic generation of the tree command structure into a pulldown menu-bar. It also provides handling of multiple and editable panels, and facilities to find, recall and get help on a command.

No written documentation is provided at the moment as several changes or features will still be added in the coming weeks. Our main objective is to reduce to the minimum the number of changes to be done in a KUIP based application (like PAW or GEANT).

The main reason to release this new interface at this stage is to familiarize potential users with the installation procedure and the various Motif files. To install these versions of KUIP and PAW on a Unix workstation you just have to select the Patchy flag "MOTIF" and include the Motif libraries in the link procedure. In case of problems or to have more information on the installation of these packages please contact cremel@cernvm.