Next: Index Up: No Title Previous: No Title

Data structure utilities

MZFLAG et al. - logical walk through a data-structure

By following the structural links, MZFLAG sets the selected status-bit into the status words of all the banks of the data-structure supported by the down-links of the specified start bank. Optionally it can include into the marking also the banks of the linear structure supported by link 0 of the start bank and all their dependents. The start bank itself may or may not be marked.

The request is

CALL MZFLAG (IXSTOR,!L,IBIT,chOPT)

with

IXSTOR  index of the store or of any division in this store,
              zero for the primary store

          !L  address of the start bank supporting
              the partial data-structure; no action if L=0.

        IBIT  the bit-number of the status-bit to be set

       chOPT  character string of options:

         default  mark the bank at L (and its down dependents),
                  the 'next' link of this bank is not followed,
                  status-bit ITBIT is set to one

               L  mark the linear structure pointed to by L
                  ie. the 'next' link of the bank at L is followed

               V  mark only the partial data-structure
                  dependent vertically downwards from the bank at L,
                  but not the bank itself

               Z  set to zero bit IBIT in each bank to be marked

MZFLAG will store into the two words of the common ZLIMIT the addresses of the lowest and of the highest bank marked during the scan, ready for use by the table-building routines of FZOUT for example.

MZFLAG is not a routine commonly called directly by the users; its main current use is as a service routine to MZDROP.

Similarly, the routine MZMARK described below is not normally needed by the users except for a special problem mentioned there. MZMARK is also used as a service routine by FZOUT.

The function MZVOLM walks through a data-structure to calculate the space occupied, returning the number of words as the function value.

NWORDS = MZVOLM (IXSTOR,!L,chOPT)

with

IXSTOR  index of the store or of any division in this store,
              zero for the primary store

          !L  address of the start bank supporting
              the partial data-structure; no action if L=0.

       chOPT  character string of options:

         default  the 'next' link of the bank at L is not followed

               L  the 'next' link of the bank at L is followed

Examples:

CALL MZFLAG (0,LQMAIN,IQDROP,'L')
this will scan the banks of the data-structure supported by the bank at LQMAIN and its sisters (option L), setting the system bit IQDROP to be 'on' in each bank found. This is equivalent to CALL MZDROP (0,LQMAIN,'L'), except that it does not set the contents of the word LQMAIN to zero.

PARAMETER  (NID=3)
      DIMENSION  IDLIST(NID)
      DATA       IDLIST  /  4HBGO , 4HTEC  , 4HMUC  /

      CALL MZMARK (0,LQMAIN,'L-',NID,IDLIST)
this will scan the banks of the data-structure supported by the bank at LQMAIN and its sisters (option L), but exclude (option -) from the scan any lower level linear structure starting with a bank whose IDH is any of BGO, TEC, MUC (and its dependents), setting in each bank found system status bit IQMARK to be 'on'.

The primary purpose of MZMARK is to give the user a possibility to select parts of a data-structure for output with FZOUT. The selection works on IDH, the Hollerith ID, of the first bank of each linear sub-structure of the full data-structure. For convenience, one may give to MZMARK either the list of the IDH's to be included into the scan, or the list of the IDH's to be excluded from the scan; hopefully one gets away with a short list by selecting the right mode.

MZMARK is a modified version of MZFLAG, it is simpler in that the bit-number and the bit value are not parameterized: the bit is IQMARK and the value is 1, as needed by FZOUT; it is more complex in that linear structures can be selected or anti-selected.

The request is

CALL MZMARK (IXSTOR,!L,chOPT,NID,IDLIST)

with

IXSTOR  index of the store or of any division in this store,
              zero for the primary store

          !L  address of the start bank supporting
              the data-structure; no action if L=0.

       chOPT  character string of options:

         default  mark the bank at L (and its down dependents),
                  the 'next' link of this bank is not followed,
                  lower level linear structures are accepted only
                     if they start with a bank whose IDH appears in
                     the list IDLIST (or if NID=0)

               L  mark the linear structure pointed to by L
                  ie. the 'next' link of the bank at L is followed

               V  mark only the partial data-structure
                  dependent vertically downwards from the bank at L,
                  but not the bank itself

               -  accept a lower level linear structure only if
                  it starts with a bank whose IDH does
                  n o t  appear in IDLIST

      NID       number of elements in the list IDLIST,
                if =zero all banks are accepted ('-' option ignored)

      IDLIST    list of the Hollerith ID for selection

On return |litIQUEST(2) contains the total number of words occupied by all the banks marked (unless L is zero on entry).

As for MZFLAG, the addresses of the lowest and the highest bank are stored into ZLIMIT, ready for FZOUT.

LZHEAD - find the first bank of a linear structure

This routine will try to find the first bank of the linear structure of which the bank at LGO is a member. It does this by following the path indicated by the "origin" link of the bank at LGO, and using its "up" link.

!LF = LZHEAD (IXSTOR,!LGO)

It returns the address of the first bank of the linear structure as the function value; or zero if there is trouble.

If the linear structure is not a top-level structure, ie. if the up-link LUP is non-zero, the path of origin-links should end in the link region of the bank at LUP, at a word whose off-set JBIAS can then be calculated. This is returned:

IQUEST(1) negative:  = JBIAS
ie. LQ(LUP+JBIAS) contains the address of the first bank of the linear structure.

If LUP is zero, the origin-path should end at a word outside the bank space of the store IXSTOR, which word should contain the address of the first bank of the linear structure. In this case LZHEAD returns:

IQUEST(1) = 1: top-level structure
      IQUEST(2) = LS, relative adr of the supporting link-area link,
                      ie. LQ(LS) contains LF

If LUP is zero, and if the origin-link in the last bank in the path is zero, this is a stand-alone structure, in which case LZHEAD returns:

IQUEST(1) = 2: stand-alone structure

If there is trouble, LZHEAD will return the function value zero, and set:

IQUEST(3) = 1   if LGO is zero

                  2   if LUP non-zero and the last origin-link
                      points outside bank-space

                  3   if LUP non-zero and LQ(LUP+JBIAS) does not
                      point to the last bank in the origin-path

                  4   if LUP zero, and LQ(LS) does not point to
                      the last bank in the origin-path.

ZSHUNT - change structural relation

Unlike in HYDRA, and because of the reverse pointers, the operation of moving a bank by re-linking from one data-structure to another one is a non-trivial operation. The routine ZSHUNT is provided to execute such an operation.

ZSHUNT may be used to extract either a single bank (IFLAG=0) or a whole linear structure (IFLAG=1) from the old context, for insertion into the new context as described by the parameters LSUP and JB, which have the same significance as in MZLIFT.

CALL ZSHUNT (IXSTOR,!LSH, !LSUP,JB,IFLAG)

with

IXSTOR  index of the store, zero for the primary store;
              IXDIV, the index of the division containing
              the bank to be shunted, may be given instead

        !LSH  address of the bank or of the linear structure

       !LSUP  if JB < 1:  address of the new supporting bank
              if JB = 1:  the new supporting link*

          JB  if JB < 1:  link bias in the new supporting bank
              if JB = 1:  LSUP is the new supporting link,
                           the origin-link in the bank at LSH
                           will be made to point to it
              if JB = 2:  detach without insertion

       IFLAG  if IFLAG = 0:  shunt the one single bank at LSH
              if IFLAG = 1:  shunt the whole linear structure
                              pointed to by LSH
If the bank or the structure to be re-linked is in fact inserted or added into an existing linear structure, both must be contained in the same division.

Examples:

Suppose we have the following data-structures to start with:

______
      |      |                         up
      |  UA  | <---.-------------.-------------.
      |______|     |             |             |
         |         |             |             |
      -3 |         |             |             |
         |       ______        ______        ______
         |      |      |  <-- |      |  <-- |      |
         `----> |  A1  | ---> |  A2  | ---> |  A3  |
                |______|      |______|      |______|

and
       ______
      |      |                              up
      |  UN  | <---.-------------.-------------.
      |______|     |             |             |
         |         |             |             |
      -7 |         |             |             |
         |       ______        ______        ______
         |      |      |  <-- |      |  <-- |      |
         `----> |  N1  | ---> |  N2  | ---> |  N3  |
                |______|      |______|      |______|


and
                    ______        ______        ______
              <--- |      |  <-- |      |  <-- |      |
      LQMAIN  ---> |  X1  | ---> |  X2  | ---> |  X3  |
                   |______|      |______|      |______|
Any bank may support further dependent partial data-structures, the corresponding structural down-links are not changed by ZSHUNT.

In what follows the notation Lxx is used to designate a link pointing to bank xx.

Examples:

CALL ZSHUNT (0,LA2,LUN,-7,0)     gives:
       ______
      |      |
      |  UA  | <---.-------------.
      |______|     |             |
         |         |             |
      -3 |       ______        ______
         |      |      |  <-- |      |
         `----> |  A1  | ---> |  A3  |
                |______|      |______|
and
       ______
      |      |
      |  UN  | <---.-------------.-------------.-------------.
      |______|     |             |             |             |
         |         |             |             |             |
      -7 |       ______        ______        ______        ______
         |      |      |  <-- |      |  <-- |      |  <-- |      |
         `----> |  A2  | ---> |  N1  | ---> |  N2  | ---> |  N3  |
                |______|      |______|      |______|      |______|

This moves a single bank (with is dependents, if any) out of a linear structure, and inserts it at the head of the linear structure supported by link -7 of the bank UN.

CALL ZSHUNT (0,LA2,LUN,-7,1)     gives:
       ______
      |      |
      |  UA  |
      |______|
         |
      -3 |       ______
         |      |      |
         `----> |  A1  |
                |______|
and   ______
     |      |
     |  UN  |  <--.-------------.-------------.------------------.
     |______|     |             |             |                  |
        |         |             |             |                  |
     -7 |       ______        ______        ______             ______
        |      |      |  <-- |      |  <-- |      |  <- ... - |      |
        `----> |  A2  | ---> |  A3  | ---> |  N1  | -- ... -> |  N3  |
               |______|      |______|      |______|           |______|
This is the same as example 1, except that the (partial) linear structure starting with bank A2 is re-linked.

CALL ZSHUNT (0,LA2,LN2,0,0)      gives:
       ______
      |      |
      |  UN  | <---.-------------.-------------.-------------.
      |______|     |             |             |             |
         |         |             |             |             |
      -7 |       ______        ______        ______        ______
         |      |      |  <-- |      |  <-- |      |  <-- |      |
         `----> |  N1  | ---> |  N2  | ---> |  A2  | ---> |  N3  |
                |______|      |______|      |______|      |______|
This is again like example 1, but the bank is inserted inside the linear structure, rather than ahead of it.

CALL ZSHUNT (0,LA2,LQMAIN,1,0)   gives:

                  0             0             0             0
                  ^             ^             ^             ^
                  |             |             |             |
                 ______        ______        ______        ______
         <----  |      |  <-- |      |  <-- |      |  <-- |      |
  LQMAIN -----> |  A2  | ---> |  X1  | ---> |  X2  | ---> |  X3  |
                |______|      |______|      |______|      |______|

This relinks bank A2 to be the first in the top-level linear structure supported by LQMAIN.

L = LQMAIN
          CALL ZSHUNT (0,LA2,L,1,0)
has exactly the same effect as Example 4 above because, LQMAIN not being zero initially, the origin-link of the bank pointed to by L (and the up-link, but this is zero) is used for the connection.

CALL ZSHUNT (0,LA1,LHEAD,1,1)     gives:
       ______
      |      |
      |  UA  |
      |______|
         |
      -3 |
          ----> zero

and               0             0             0
                  ^             ^             ^
                  |             |             |
                 ______        ______        ______
         <----  |      |  <-- |      |  <-- |      |
  LHEAD  -----> |  A1  | ---> |  A2  | ---> |  A3  |
                |______|      |______|      |______|

supposing LHEAD=0 initially; this connects the linear structure to the (structural) link LHEAD, ie. the origin-link of the header bank A1 points back to the location of LHEAD.

CALL ZSHUNT (0,LA1,LDUMMY,2,1)    gives:
       ______
      |      |
      |  UA  |
      |______|
         |
      -3 |
         `----> zero

and               0             0             0
                  ^             ^             ^
                  |             |             |
                 ______        ______        ______
         0 <--  |      |  <-- |      |  <-- |      |
  LA1    -----> |  A1  | ---> |  A2  | ---> |  A3  |
                |______|      |______|      |______|
This detaches the linear structure from its old context without inserting it into a new one. This should only be temporary, one should insert the floating structure into a new context by a second call to ZSHUNT not too much later.

ZSORT - utility to sort the banks of a linear structure

These routines re-arrange the horizontal linking within a given linear structure such that the key-words contained in each bank increase monotonically when moving through the linear structure with L=LQ(L). For equal key-words the original order is preserved.

Key-words may be either floating, integer or Hollerith. For Hollerith sorting a collating sequence inherent in the representation is used, thus the results will depend on the machine.

Sorting may be done either for a single key-word in every bank or for a key vector in every bank:

CALL ZSORT (IXSTOR,*!LLS*,JKEY)

Sorts banks according to a single floating-point keyword

CALL ZSORTI (IXSTOR,*!LLS*,JKEY)

Sorts banks according to a single integer keyword

CALL ZSORTH (IXSTOR,*!LLS*,JKEY)

Sorts banks according to a single Hollerith keyword

CALL ZSORV (IXSTOR,*!LLS*,JKEY,NKEYS)

Sorts banks according to a floating-point key vector

CALL ZSORVI (IXSTOR,*!LLS*,JKEY,NKEYS)

Sorts banks according to an integer key vector

CALL ZSORVH (IXSTOR,*!LLS*,JKEY,NKEYS)

Sorts banks according to a Hollerith key vector

with the parameters

      IXSTOR  index of the store or of any division in this store,
              zero for the primary store;

      *!LLS*  the address of the first bank of the linear structure,
              reset on return to point to the new first bank;

        JKEY  in each bank at L, Q(L+JKEY) is the key word,
                                 or the first word of the key vector;

       NKEYS  the number of words in the key vector.

The execution time taken by these routines is a function of the re-ordering which needs to be done. For perfect order the operation is a simple verification pass through the structure. The maximum time is taken if the banks are initially arranged with decreasing key words.

Sorting re-links the banks such that the key-words are in increasing order. If one needs them in decreasing order on may use CALL ZTOPSY (IXSTOR,LLS) which reverses the order of the banks in the linear structure pointed to be LLS.

ZTOPSY et al. - utilities to operate on linear structures

These routines perform service operations on linear structures. The parameter LLS is the address of the first bank of the linear structure.

CALL ZTOPSY (IXSTOR,*!LLS*)

reverses the order of the banks in the linear structure, ie. the first bank becomes the last, and the last the first, for walking through the structure with L=LQ(L). Starting with Zebra version 3.67, LLS is updated to point to the first bank of the inverted structure on return.

CALL ZPRESS (IXSTOR,!LLS)

removes by bridging dead banks still present in the linear structure pointed to by LLS.

LZFIND et al. - utilities to interrogate linear structures

These routines perform service functions for linear structures. The parameter LLS is the address of the first bank of the linear structure.

!LF = LZLAST (IXSTOR,!LLS)

searches the linear structure pointed to by LLS for its end. It returns in LF the address of the last bank in the structure. LF = 0 is returned if the structure is empty.

!LF = LZFIND (IXSTOR,!LLS,IT,JW)

searches the linear structure pointed to by LLS for the first bank containing IT in word JW; it returns its address in LF. If none: LF=0.

!LF = LZLONG (IXSTOR,!LLS,NW,ITV,JW)

has the same function as LZFIND, but ITV is a vector of NW words expected in words JW to JW+N-1 of the bank.

!LF = LZBYT (IXSTOR,!LLS,IT,JBIT,NBITS)

has the same function as LZFIND, but it looks for a bank having IT in byte (JBIT,NBITS) of the status word.

!LF = LZFVAL (IXSTOR,!LLS,VAL,TOL,JW)

has the same function as LZFIND, but it looks for a bank having in word JW a floating point number which is equal to VAL within the tolerance TOL.

N = NZBANK (IXSTOR,!LLS)

counts the number of banks in the linear structure pointed to by LLS.

N = NZFIND (IXSTOR,!LLS,IT,JW)

searches like LZFIND, but for all banks. It returns the number of such banks in N and stores the addresses of the first 100 such banks into IQUEST, starting at IQUEST(1).

N = NZLONG (IXSTOR,!LLS,NW,ITV,JW)

searches like LZLONG, but for all banks. It returns the number of such banks in N and stores the addresses of the first 100 such banks into IQUEST, starting at IQUEST(1).

LZFID et al. - utilities to find a bank by sequential scan

Unlike the routines of the previous paragraphs which access banks by following the links of the structure, the routines of this paragraph perform a scan over the memory, looking at each bank in turn in the order in which they happen to be in the dynamic store, to find the bank wanted. For large memories with many banks this is likely to be an expensive operation and should not be used unless there is no other way.

!LF = LZFID (IXDIV, IDH,IDN, !LGO)

searches the division indicated by IXDIV, either starting at its beginning if LGO=0 or with the first bank after the bank at LGO, for the first bank with has the identifiers IDH and IDN.

!LF = LZFIDH (IXDIV, IDH, !LGO)

searches the division indicated by IXDIV, either starting at its beginning if LGO=0 or with the first bank after the bank at LGO, for the first bank with has the Hollerith identifier IDH.

!LF = LZSCAN (IXDIV, !LGO)

searches the division indicated by IXDIV, either starting at its beginning if LGO=0 or with the first bank after the bank at LGO, for the first bank.

LZSCAN returns IQUEST(1) containing zero if the bank at LF is live, or one if the bank is dead.

References

Global CERN library references

/user/goossens/cnasall/cnasbibl,/user/goossens/cnasall/textproc}



Next: Index Up: No Title Previous: No Title


goossens@cern.ch