next up previous contents index
Next: Physical Storage Up: ZEBRA - An Previous: Why ZEBRA?

Logical Data Structures

The bank

Imagine that we wish to store all the information about, say, a track in a single unit, containing perh.gif details of its momentum, direction, coordinates etc. Using a call to the ZEBRA routine MZBOOK, we can ask for an area of contiguous storage of a given length to be provided. The actual location of this area is returned by MZBOOK as a base address which has to be used in all references to that area.

This unit of storage is called a bank, and in Fortran code will be referenced as in:

Addressing data words in a ZEBRA bank

      Q(LTK+1) = PX
      Q(LTK+2) = PY
      etc.
Q, by convention, is the name of the Fortran array underlying the data structure, and LTK is the base address, provided by MZBOOK, being the location of the word preceding the first data word in the bank.

An advantage of ZEBRA is that it allows banks to contain data of differing types. This is explained in detail later, but a simple application would allow us to address another data word in the bank just referenced as an integer, e.g.

Addressing integer data in a ZEBRA bank

      IQ(LTK+19) = NPOINTS
It is important to understand that for data structuring purposes ZEBRA requires no knowledge of or control over the actual contents of a bank. Whether it contains track data or a list of family birthdays is not ZEBRA's concern. The internal details of the data in a bank are solely the responsibility of the user(s), and it is vital to maintain an adequate documentation of bank contents. However, for input/output across computers and for printing purposes, ZEBRA has to know the type of the bank contents, i.e. whether the numbers are floating point, integer, Hollerith, etc. This can be declared by a call to MZFORM.

The linear structure

In our example of a track bank, it is clear that in a given application there may be a large and variable number of tracks to deal with. To permit the realization of sets of objects of the same kind, ZEBRA provides the construct of the linear structure (figure gif). A linear structure consists of a series of linked banks, with each bank holding in a reserved system word, called the next link, the base address of the next member of the set. The next link of the last bank of a linear structure has the value zero, indicating that there is no next bank.

A simple linear structure  

Example of loop over linear chain

      LTK = LFIRST                      ! Address of the first bank
   10 IF (LTK.EQ.0) GO TO finished      ! No next bank left ?
            .....                       ! Process data for the bank at LTK
          LTK = LQ(LTK)                 ! Get the address of the next bank
      GO TO 10                          ! Loop

The next link is stored in the word LQ(LTK) of the bank, with the vector LQ in offset EQUIVALENCE to the vector Q and IQ, as explained later. The example above shows the ZEBRA equivalent of a Fortran DO-loop to process all the banks of a linear structure.

Banks are created dynamically at execution time, and because each bank has one word to connect the rest of the structure of which it is a member, the linear structure permits the creation at execution time of sets of an arbitrary number of objects, independent of any declaration of maximum dimension, either at execution time or at compile time, as would be the case with Fortran arrays.

The order of the banks in a linear structure, although defined, is not normally significant. It depends on the details of the creation process, as will be seen later. The user may, however, associate significance to the defined order, and ZEBRA utilities are provided to re-order the banks in a linear structure by re-arranging the next links (ZSORT).

It will be necessary to refer to the ``address of a linear structure''. This is simply the base address of its first bank. If this address is available, all the banks of the linear structure can be reached.

The general data structure

In the general case, more complex structures are needed than the linear one just described.

An example of a general structure  

For instance, in the context of a high-energy physics program a number of track banks may depend on a bank at a logically higher level which describes a track vertex. This vertex bank will contain a link to the first of the track banks. Such a link is called a down link. It is possible for a given bank to have a large number of down links, and for it to depend similarly on a logically yet higher bank through a down link in that bank. We thus see that the down links allow the construction of a tree structure, and that at each node there may be either a single bank or a linear structure. This may be pictured as in Figure gif.

All the links so far described are stored by ZEBRA as part of the bank concerned. We note that the down and next links are referred to collectively as structural links, as they represent the basic connections of a data structure.

Reverse links

Each ZEBRA bank contains a link pointing to the bank on which the whole linear structure of which it is a member depends. This is called the up link. The value of this link is zero if the bank concerned is itself at the top of the tree structure. Finally, each bank has also an origin link, which points to the structural link supporting the bank. The up link and the origin link are known as reverse links. A summary of the four types of links known to ZEBRA is given in Figure gif

Reference links

The links so far described are an integral part of the data structure which they represent. It often happens that a user wishes to establish links between various banks which are not part of the structure itself, but merely references that the user wishes to record. These are then known as reference links. A bank can contain a large number of such links, and their use is at the discretion of the user, and entirely his responsiblity. For the reference links the task of the ZEBRA system is limited to changing their values in the event that, for reasons to be explained below, banks have to be moved, or relocated, in memory. Reference links provide a high level of generality in the design of complete data structures, and are another of those features which so greatly enhances the power of Fortran.

A schematic overview of the links known to ZEBRA  



next up previous contents index
Next: Physical Storage Up: ZEBRA - An Previous: Why ZEBRA?


Janne Saarela
Mon May 15 08:34:47 METDST 1995