C   01/05/96 605011927  MEMBER NAME  MANUAL   (BOSLIB.S) M  FVS
C
C               BBBBBB      OOOOO      SSSSS
C               B     B    O     O    S     S
C               B     B    O     O    S
C               BBBBBB     O     O     SSSSS
C               B     B    O     O          S
C               B     B    O     O    S     S
C               BBBBBB      OOOOO      SSSSS
C
C               ======== M A N U A L ========
C
C
C     -----------------------------------------------------
C     BANK ORGANISATION SYSTEM                      - BOS -
C     -----------------------------------------------------
C           DYNAMIC STORAGE ORGANISATION WITH FORTRAN
C                        1979 VERSION
C
C
C
C
C     AUTHOR  -  V.BLOBEL
C                II.INSTITUT FUER EXP.PHYSIK
C                UNIVERSITY OF HAMBURG   AND   DESY
C
C
C
C
C             ABSTRACT
C             ========
C             THE BOS SYSTEM AND ITS SUBSYSTEM SBOS
C             ALLOW THE EFFICIENT MANAGEMENT OF DATA
C             ARRAYS IN MEMORY AND ON MASS STORAGE
C             DEVICES. THE SYSTEMS ARE DEVELOPPED
C             ESPECIALLY FOR THE USE IN THE ANALYSIS
C             OF HIGH ENERGY PHYSICS EXPERIMENTS.
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C         TABLE OF CONTENT                             PAGE
C     -----------------------------------------------------
C
C
C
C     1.  INTRODUCTION                                    4
C
C     2.  CREATION OF BANKS                               9
C         2.1 CREATION OF A BANK
C         2.2 CHANGING THE LENGTH OF A BANK
C         2.3 STORAGE OF DATA IN A BANK
C         2.4 RENAMING A BANK
C         2.5 CALL OF THE PREVIOUS VERSION
C
C     3.  LOCATING OF BANKS                              12
C         3.1 LOCATING A BANK
C         3.2 LOCATING ALL BANKS OF THE SAME NAME
C         3.3 FASTER METHODS
C
C     4.  SETS OF BANKS                                  14
C         4.1 THE CURRENT LIST
C         4.2 THE SPECIAL LIST
C
C     5.  PRINTOUT OF BANKS                              18
C         5.1 SINGLE BANKS
C         5.2 SETS OF BANKS
C
C     6.  DELETING BANKS AND GARBAGE COLLECTION          18
C         6.1 SINGLE BANKS
C         6.2 SETS OF BANKS
C         6.3 GARBAGE COLLECTION
C
C     7.  INPUT FROM CARDS                               19
C         7.1 FREE FORMAT
C         7.2 FORMATED
C         7.3 SPECIAL CARDS
C         7.4 EXAMPLE
C
C     8.  UNFORMATED INPUT/OUTPUT OF BANKS               21
C         8.1 STANDARD OUTPUT AND INPUT
C         8.2 OUTPUT MODES AND RECORD TYPES
C         8.3 USER WRITE AND READ STATEMENTS
C         8.4 BUFFER BANKS
C         8.5 STANDARD EVENT READING/WRITING
C
C
C
C
C
C     9.  BANKS ON DIRECT ACCESS DATA SETS               27
C         9.1 INITIALIZATION OF A DADS
C         9.2 STORING AND RETRIEVING BANKS
C         9.3 UNLOADING AND LOADING THE DADS
C         9.4 PROTECTED DADS
C
C     10. PRINTING STATISTIC AND A DUMP                  30
C
C
C     APPENDIX A - THE SBOS SYSTEM                       34
C
C
C         A.1  INITIALIZATION
C         A.2  FUNCTION ILOC
C         A.3  FUNCTION IBLN
C         A.4  SUBROUTINE BMLT
C         A.5  SUBROUTINE BLST
C         A.6  SUBROUTINE BDLM
C         A.7  SUBROUTINE BGAR
C         A.8  SUBROUTINE BSIN
C         A.9  SUBROUTINE BSOUT
C
C
C     APPENDIX B - APPLICATION PROGRAMS                  40
C
C
C         B.1  PRINTOUT AND COMMENTS
C         B.2  COUNT IN A 32768 * 32768 ARRAY
C         B.3  COUNT IN A 256 * 16 ARRAY
C         B.4  HISTOGRAM
C         B.5  CORRELATION PLOT
C         B.6  STORE VECTORS
C         B.7  DETERMINE MEAN VALUES
C         B.8  DETERMINE PEAK VALUES
C         B.9  STORE SINGLE VALUES
C         B.10 BIN DEFINITION
C         B.11 INTERPOLATION OF TABULATED DATA
C         B.12 DETERMINATION OF A LINEAR DEPENDENCE
C         B.13 DETERMINATION OF AN EMPIRICAL FUNCTION
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C     -----------------------------------------------------------------1
C     1.  INTRODUCTION
C
C     LARGE AMOUNT OF DATA ARE TO BE ANALYSED IN HIGH-ENERGY
C     PHYSICS EXPERIMENTS. DATA ON ONE EVENT CONSIST OF DATA
C     FROM SEVERAL SOURCES, E.G. TRACK CHAMBERS, SHOWER COUNTERS
C     AND SCALERS. DURING THE ANALYSIS NEW DATA ARE ADDED
C     BY COMPUTATION, E.G. DATA ON SINGLE TRACKS. ALSO DATA
C     MAY BE COMPRESSED BY DATA REDUCTION PROGRAMS.
C     THE COMPLEXITY OF ANALYSIS DEPENDS VERY MUCH ON THE
C     ORGANISATION OF THE DATA IN STORAGE AND ON MASS STORAGE
C     DEVICES, E.G. TAPES. A FLEXIBLE DATA ORGANISATION
C     SIMPLIFIES THE ANALYSIS.
C     THE SYSTEM DESCRIBED HERE IS DESIGNED ACCORDING TO THE
C     NEEDS OF HIGH-ENERGY PHYSICS EXPERIMENTS. ALL DATA ARE
C     STRUCTURED IN SO CALLED BANKS OF VARIABLE LENGTH. DATA
C     IN ONE BANK REFER E.G. TO A SINGLE PARTICLE TRACK. A
C     BANK HAS TWO IDENTIFIERS NA AND NR, CALLED NAME AND
C     NUMBER. NORMALLY THE IDENTIFIER NA CONSISTS OF UP TO
C     FOUR CHARACTERS, WHILE IDENTIFIER NR IS AN INTEGER.
C
C     ALL BANKS ARE STORED IN A SINGLE COMMON/BCS/IW(NSPACE).
C     AN INDEX IND IS ASSIGNED TO EACH BANK, WHERE IW(IND)=NW
C     CONTAINS THE NUMBER OF DATA WORDS IN THAT BANK. DATA
C     ARE STORED IN IW(IND+1) TO IW(IND+NW). IN ADDITION
C     THERE ARE THREE WORDS CONTAINING NAME, NUMBER AND A
C     POINTER ACCORDING TO THE FOLLOWING SCHEMA.
C
C              I      IW(I)
C          --------   -------------------------------------
C          IND -  3   NA (NAME)
C          IND -  2   NR (NUMBER)
C          IND -  1   POINTER TO NEXT BANK OF SAME NAME
C                     -------------------------------------
C          IND        NW = NUMBER OF DATA WORDS IN THE BANK
C                     -------------------------------------
C          IND +  1   DATA WORD 1
C          IND +  2   DATA WORD 2
C          ...        ...
C          IND + NW   DATA WORD NW
C          --------   -------------------------------------
C
C     NO LIMITATIONS EXIST FOR THE LENGTH OF A SINGLE BANK OR
C     THE NUMBER OF BANKS, EXCEPT FOR THE TOTAL LENGTH OF
C     ALL BANKS.
C     OUTPUT OF SETS OF BANKS IS SIMPLY DONE BY SPECIFYING
C     ALL NAMES OF BANKS, BELONGING TO THE OUTPUT RECORD.
C     THE MAIN ADVANTAGES OF THE SYSTEM ARE -
C             - EFFICIENT USE OF STORAGE
C             - EASY ADDITION OF NEW BANKS
C             - FLEXIBLE INPUT/OUTPUT
C
C
C
C     THIS MANUAL DESCRIBES THE BOS VERSION RELEASED IN THE
C     BEGINNING OF 1979. THE MAIN CHANGES IN THIS VERSION TO
C     THE VERSION DESCRIBED IN THE INTERNAL REPORT DESY F14/76-01
C     ARE INTERNALLY, TO INCREASE THE SPEED ESPECIALLY FOR
C     INPUT AND OUTPUT. ALL CALLS OF THE PREVIOUS VERSION ARE ALSO
C     EXISTING IN THE CURRENT VERSION.
C     THE MAIN CHANGES ARE THE FOLLOWING
C     CHAPTER 2.   DIFFERENT ACTION IN CASE OF ERRORS IN BCRE
C     CHAPTER 4.   ADDITIONAL CALLS FOR LIST HANDLING
C     CHAPTER 6.   MODIFIED RULES FOR INPUT FROM DATA CARDS
C     CHAPTER 8.   NEW MODES FOR OUTPUT (AND INPUT)
C     CHAPTER 9.   NEW SUBROUTINES FOR DIRECT ACCESS DEVICES
C
C
C
C     LIBRARIES. THE SUBPROGRAMS OF THE BANK-SYSTEMS BOS AND
C     SBOS ARE ON THE DESY-NEWLIB LIBRARIES
C              DSN=F1EBLO.BOSLIB.L    (LOAD)
C         AND  DSN=F1EBLO.BOSLIB.S    (SOURCE)
C
C     THE FULL BOS SYSTEM IS DESCRIBED IN CHAPTER 2 - 10. IN
C     APPENDIX A A SMALL SUBSYTEM CALLED SBOS IS DESCRIBED, WHICH
C     HAS A TOTAL PROGRAM LENGTH OF BELOW 10 K BYTES. THIS SMALLER
C     SYSTEM IS FULLY COMPATIBLE WITH THE FULL SYSTEM, SUBROUTINES
C     FROM BOTH SYSTEMS MAY BE USED TOGETHER. THE SBOS SYSTEM IS
C     DEVELOPPED MAINLY FOR ONLINE APPLICATIONS. NEARLY ALL
C     FUNCTIONS DESCRIBED IN CHAPTER 2, 3, 4, 6 AND SOME OF THE
C     FUNCTIONS DESCRIBED IN CHAPTER 8 ARE POSSIBLE.
C     IN APPENDIX B APPLICATION PROGRAMS ARE DESCRIBED. THEY CAN
C     BE USED FOR COUNTING, MAKING HISTOGRAMS ETC AND MAY BE
C     USEFUL IN THE TESTING PHASE OF ANALYSIS PROGRAMS.
C
C     THE SBOS SYSTEM CONSISTS OF THE FOLLOWING SUBPROGRAMS.
C
C
C           SUBPROGRAM
C
C      0.1  BENT AND BDMPA
C      0.2  ILOC
C      0.3  IBLN                    (IDENTICAL IN BOS)
C      0.4  BMLT                    (IDENTICAL IN BOS)
C      0.5  BLST
C      0.6  BDLM                    (IDENTICAL IN BOS)
C      0.7  BGAR                    (IDENTICAL IN BOS)
C      0.8  BSIN
C      0.9  BOUT
C        +  ENTRIES VZERO, UCOPY AND UCOPY2
C
C     THE BOS SYSTEM (EXCLUDING THE APPLICATION PROGRAMS)
C     CONSISTS OF THE FOLLOWING SUBROUTINES.
C
C           SUBPROGRAM   ENTRIES
C
C      1.1  BINT         BINT1
C      1.2  BDMPA
C      1.3  IBLN         -
C      1.4  BRNM         BSPC
C      1.5  BCRE         -
C      1.6  CCRE         -
C      1.7  BLOC         -
C      1.8  CLOC         -
C      1.9  BCHM         BCHF   BSTR   BMRT
C      1.10 BDAR         -
C      1.11 BPOS         CPOS   BPRL
C      1.12 BNXT         -
C      1.13 CNXT         -
C      1.14 BMLT
C      1.15 BSAW         BDEF   BSAT   BSAD
C      1.15 BDLS         BPRS
C      1.17 BDLM
C      1.18 BDLG         BPRM   BSLW   BSLC   BSLT
C      1.19 BGAR         -
C      1.20 BDMP         BDMPF
C      1.21 BSTA         -
C      1.22 DUMP0C       -
C      1.23 BCHL         BMVE
C      1.24 CCHL         CMVE
C      1.25 BGAC         -
C      1.26 BSLS         BSLR
C      1.27 INDAR
C      + ENTRIES VZERO, UCOPY AND UCOPY2
C      + SUBR. UWP
C      + SUBR. DAY, ITRACE, NTIME FROM DESYLIB
C
C      2.1  BREADC       -
C      2.2  READHL       -
C
C      3.1  BREAD        -
C      3.2  CREAD        -
C      3.3  BWRITE       -
C      3.4  BRDS         -
C      3.5  BWRS         BWRO
C      3.6  BFRD         BFWR
C      3.7  BINP         BFRR
C      3.8  BOUTP        BORDP
C      3.9  BSEQ         BSEW   BSET   BSEL
C      3.10 RDVAR        WRVAR  WRFIX
C      3.11 MSGPR        MSGTXT MSGINT
C
C      4.1  BLOCDA       BDLSDA BCREDA BCHKDA
C      4.2  BINLDA       -
C      4.3  BLOADA       -
C      4.4  PODA         CHDIR
C      4.5  DADA         -
C      4.6  RDDA         WRDA   RDSQ   WRSQ
C      4.7  BPASDA       -
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C     INITIALIZATION IS DONE BY THE FOLLOWING STATEMENTS.
C
C     COMMON/BCS/IW(NSPACE)
C     REAL RW(NSPACE)
C     EQUIVALENCE (IW(1),RW(1))
C        WHERE NSPACE = INTEGER CONSTANT
C
C               ------ ---- ---- ----
C     CALL BINT(NSPACE,NREC,NDMP,NADD)
C
C
C        WHERE NREC  = MAX.NO OF WORDS IN A OUTPUT RECORD,
C                      IF BWRO IS NOT CALLED (SEE CH. 8.2)
C                      (DEFAULT 4000)
C              NDMP  = NR OF WORDS, PRINTED IN A DUMP
C                      (DEFAULT  500)
C              NADD  = NR OF WORDS FOR LOW PRIORITY BANKS
C                      (DEFAULT IS 10 PERCENT OF NSPACE)
C
C
C     HERE AND IN THE FOLLOWING INPUT ARGUMENTS HAVE
C     A LINE ABOVE, OUTPUT ARGUMENTS HAVE A LINE BELOW.
C     ARGUMENTS, WHICH ARE CHANGED BY THE PROGRAM, HAVE A LINE
C     ABOVE AND BELOW. THE ARGUMENT IER IN SOME CALLS IS AN
C     ERROR CODE WITH THE VALUE ZERO, IF NO ERROR WAS DETECTED.
C
C     THE DEFAULT VALUES ARE USED, IF THE ARGUMENTS ARE ZERO.
C     IF ERROR CONDITIONS E.G. ILLEGAL VALUES OF POINTERS ARE
C     DETECTED, THE DUMP PROGRAM BDMP IS CALLED AND THE PROGRAM
C     IS STOPPED WITH CALL ABEND. THE OUTPUT OF THE DUMP PROGRAM
C     IS EXPLAINED IN CH. 10.
C
C
C     BANKS WITH NAMES, WHERE THE FOURTH CHARACTER IS A '*',
C     E.G. 'HST*', ARE CONSIDERED AS BANKS OF LOW PRIORITY.
C     THEY CAN ONLY BE CREATED UP TO A TOTAL AMOUNT OF
C     NADD WORDS.
C
C     NAMES WITH CHARACTER '+' AS THE FIRST CHARACTER,
C     E.G. '+BUF', ARE NAMES OF SYSTEM BANKS. THE USER SHOULD
C     NOT USE NAMES STARTING WITH THE CHARACTER '+'.
C
C
C
C     OPTIONALLY THE USER CAN CALL BINT1 IMMEDIATELY AFTER
C     BINT, TO CHANGE SOME DEFAULT PARAMETERS OF THE SYSTEM.
C
C                --- --- --- ---
C     CALL BINT1(NNA,NNL,NNE,NNP)
C
C        WHERE NNA = MAX. NR OF DIFFERENT NAMES      (DEFAULT 200)
C              NNL = MAX. NR OF ENTRIES IN LISTS     (DEFAULT 100)
C              NNE = MAX. NR OF READ ERRORS ALLOWED  (DEFAULT  10)
C              NNP = MAX. NR OF LISTINGS FOR RECORDS
C                    WITH CERTAIN TYPES OF INPUT
C                    BANK ERRORS                     (DEFAULT   2)
C
C     THE DEFAULT VALUES ARE USED, IF BINT1 IS NOT CALLED. ABOUT
C     5*NNA + 3*NNL WORDS IN THE COMMON/BCS/ ARE USED FOR INTERNAL
C     TABLES (1312 WORDS FOR DEFAULT VALUES).
C
C     SOME INFORMATION ON THE FREE SPACE IN COMMON/BCS/ ETC
C     CAN BE OBTAINED BY
C
C     CALL BSPC(IND,NUS,NAS,NSL)
C               --- --- --- ---
C
C        WHERE IND = INDEX OF FIRST UNUSED WORD BEHIND THE BANKS
C              NUS = NR OF UNUSED WORDS BEHIND BANKS
C              NAS = NR OF ADDITIONAL FREE WORDS FROM DELETED BANKS
C              NSL = NR OF ENTRIES IN THE SPECIAL LIST
C
C     THE UNUSED SPACE  IW(IND) . . . IW(IND+NUS)  CAN BE USED
C     AS AN INTERMEDIATE STORAGE BETWEEN CALLS TO BOS SYSTEM
C     PROGRAMS.
C
C     -----------------------------------------------------------------2
C     2.  CREATION OF BANKS
C
C     2.1  CREATION OF A BANK
C
C                   -- -- --                               -- -- --
C     CALL BCRE(IND,NA,NR,NW,&S1,IER)        CALL CCRE(IND,NA,NR,NW,IER)
C               ---          --- ---                   ---          ---
C
C        WHERE NA = NAME OF THE BANK
C              NR = NUMBER OF THE BANK
C              NW = NUMBER OF WORDS OF THE BANK (NW.GE.0)
C             IND = INDEX OF BANK (IER=1, IF BANK ALREADY EXISTING)
C        ALL WORDS OF THE BANK ARE SET TO ZERO.
C
C
C     SPECIAL CONDITIONS
C                              BCRE              CCRE
C
C     BANK ALREADY PRESENT *)  IER=1             IER=1
C                              NORMAL RETURN
C
C     NOT ENOUGH SPACE         IND=0             IND=0
C                              IER=2             IER=2
C                              RETURN 1
C
C     *) IF THE ARGUMENT NW IS LARGER THAN THE LENGTH OF THE
C     EXISTING BANK, THE LENGTH OF THE BANK IS CHANGED TO THE
C     LENGTH GIVEN IN THE ARGUMENT, ALL ADDITIONAL WORDS ARE
C     SET TO ZERO (THE BANK IS MOVED TO THE END OF THE USED
C     BANK SPACE).
C     NOTE, THAT IN THE PREVIOUS BOS-VERSION THE LENGTH WAS
C     LEFT UNCHANGED.
C
C
C     IF THE NEW CREATED BANK BELONGS TO AN EVENT IN AN
C     EVENT-BY-EVENT PROCESSING PROGRAM, THE NAME OF THE
C     CREATED BANK SHOULD BE ADDED TO THE SPECIAL LIST (SEE
C     CH. 4).
C     THE BANK NAME IS ADDED TO THE SPECIAL LIST BY ONE OF
C     THE STATEMENTS
C         CALL BSAW(1,NA)     OR    BSAT(1,NA).
C     BSAT HAS TO BE USED, IF THE BANK SHOULD NOT BE ADDED
C     TO THE EVENT IN AN OUTPUT RECORD, BUT HAS TO BE DELETED
C     AFTER PROCESSING THE EVENT.
C
C
C
C
C
C
C
C     2.2  CHANGING THE LENGTH OF A BANK
C
C
C               --- --
C     CALL BCHM(IND,NW,IER)
C               ---    ---
C
C        WHERE NW = CHANGE IN LENGTH OF THE BANK (NW.LT.0 VALID)
C             IND = INDEX OF THE BANK TO BE CHANGED IN LENGTH
C
C     IF POSSIBLE, THE LENGTH OF THE BANK IS CHANGED WITHOUT MOVING
C     THE BANK. FOR NW=0, THE BANK IS MOVED TO THE END.
C
C
C     A BANK LENGTH OF AT LEAST NW WORDS IS OBTAINED BY THE FOLLOWING
C     CALL.
C               --- --
C     CALL BCHF(IND,NW,IER)
C               ---    ---
C
C        WHERE NW = MINIMUM LENGTH OF THE BANK
C             IND = INDEX OF THE BANK
C
C     THE BANK LENGTH IS CHANGED, IF THE ACTUAL LENGTH IS LESS
C     THAN NW.
C
C     ADDITIONAL WORDS OF THE BANK ARE NOT SET TO ZERO (SEE REMARK
C     IN CH. 2.1).
C
C
C     SPECIAL CONDITIONS
C                                               BCHM,BCHF
C
C     WRONG INDEX IND IN ARGUMENT, OR            IER = 1
C     BANK LENGTH WILL BECOME NEGATIVE
C
C     NOT ENOUGH SPACE                           IER = 2
C
C
C
C     2.3  STORAGE OF DATA IN A BANK
C
C               --- -- --
C     CALL BSTR(IND,JW,NW)
C
C
C     WHERE IND = INDEX
C           JW  = ARRAY TO BE STORED
C           NW  = LENGTH OF JW
C
C     JW(1) IS STORED IN IW(IND+1) ETC.
C
C
C
C
C
C
C     2.4  RENAMING A BANK
C
C     THE NAME AND NR OF A BANK CAN BE CHANGED (IN PLACE).
C
C               ------ ----- ------ -----
C     CALL BRNM(NAMOLD,NROLD,NAMNEW,NRNEW)
C
C        WHERE NAMOLD, NROLD = NAME AND NR OF AN EXISTING BANK
C              NAMNEW, NRNEW = NEW NAME AND NR OF THE BANK
C
C
C
C     2.5  CALLS OF THE PREVIOUS VERSION
C
C
C
C               --                                   --
C     CALL BCHL(NW,&S1)                    CALL CCHL(NW,IER)
C                  ---                                  ---
C
C        WHERE NW = CHANGE IN LENGTH OF THE BANK (NW.LT.0 VALID)
C
C
C
C     NOTE, THAT ONLY THE LENGTH OF THE LAST CREATED BANK CAN
C     BE CHANGED DIRECTLY. A SAFER WAY OF CHANGING THE LENGTH
C     OF A BANK IS BY USING BCHM OR BCHF (SEE CH. 2.2).
C
C               ---                                     ---
C     CALL BMVE(IND,&S1)                      CALL CMVE(IND,IER)
C               --- ---                                 --- ---
C        WHERE IND = INDEX OF BANK TO BE MOVED
C     THE BANK IS MOVED TO THE END OF THE USED STORAGE, IND
C     IS CHANGED. AFTER BMVE THE LENGTH OF THE BANK CAN BE CHANGED
C     BY BCHL.
C
C     SPECIAL CONDITIONS
C                                  BCHL,BMVE   CCHL,CMVE
C     NOT ENOUGH SPACE              RETURN 1     IER=2
C
C
C
C
C
C
C
C
C
C
C
C
C
C     -----------------------------------------------------------------3
C     3.  LOCATING OF BANKS
C
C     3.1  LOCATING A BANK
C
C
C                   -- --                                     -- --
C     CALL BLOC(IND,NA,NR,&S1)                  CALL CLOC(IND,NA,NR)
C               ---       ---                             ---
C
C        WHERE NA = NAME OF THE BANK
C              NR = NUMBER OF THE BANK
C              IND = INDEX OF THE BANK (NORMAL RETURN)
C
C     SPECIAL CONDITIONS
C                           BLOC             CLOC
C
C     BANK NOT EXISTING     IND=0            IND=0
C                           RETURN 1
C
C
C     3.2  LOCATING ALL BANKS WITH THE SAME NAME
C
C
C     LOCATING OF ALL BANKS OF A GIVEN NAME IN ASCENDING ORDER
C     OF NR IS DONE IN THE FOLLOWING WAY.
C
C               ----                               ----
C     CALL BPOS(NAME)                    CALL CPOS(NAME)
C
C        WHERE NAME = NAME OF THE BANKS
C
C               ---                                ---
C     CALL BNXT(IND,&S1)                 CALL CNXT(IND)
C               --- ---                            ---
C
C        WHERE IND = INDEX OF NEXT BANK OF THE SAME NAME
C
C     SPECIAL CONDITION
C                              BNXT             CNXT
C
C     NO FURTHER BANK          IND=0            IND=0
C                              RETURN 1
C
C     EXAMPLE FOR A LOOP ON ALL BANKS OF THE SAME NAME
C        CALL BPOS(NAME)
C     10 CALL BNXT(IND,&20)
C        . . .
C        GOTO 10
C     20 CONTINUE
C
C     BPOS/BNXT-LOOPS MAY BE NESTED. BNXT MAY ALSO BE USED
C     WITHOUT BPOS TO OBTAIN THE INDEX OF THE NEXT BANK OF
C     THE SAME NAME. THE INDEX IND IS A INPUT- AND OUTPUT-
C     ARGUMENT IN BNXT, EXCEPT FOR THE FIRST CALL AFTER THE
C     CALL OF BPOS, WHERE IT IS AN OUTPUT-ARGUMENT.
C
C
C
C     LOCATING ALL BANKS OF A GIVEN NAME CAN ALSO BE DONE USING
C     SUBROUTINE BDAR.
C
C                ----        ----
C     CALL  BDAR(NAME,N,INDA,NLIM)
C                     - ----
C
C        WHERE NAME = NAME OF THE BANKS
C              NLIM = NR.OF WORDS OF ARRAY INDA( )
C        INDA( ) = ARRAY CONTAING N INDICES (N.LE.NLIM)
C
C     EXAMPLE, EQUIVALENT TO THE ONE IN 3.2
C        INTEGER INDA(20)
C        CALL BDAR(NAME,N,INDA,20)
C        DO 20 I=1,N
C        IND=INDA(I)
C        . . .
C     20 CONTINUE
C
C
C
C
C     3.3  FASTER METHODS
C
C
C     TO LOCATE BANKS, FASTER METHODS CAN BE USED THAN THE METHODS
C     DESCRIBED ABOVE. THE DECREASE OF TIME IS OBTAINED BY AVOIDING
C     ANY SUBROUTINE CALLS.
C
C     THE INDEX IND OF THE FIRST BANK OF A GIVEN NAME (THE BANK WITH
C     THE SMALLEST VALUE OF NR) IS STORED IN ONE OF THE LOCATIONS
C     IW(1) TO IW(NAMAX), WHERE NAMAX IS THE MAXIMUM NR OF DIFFERENT
C     NAMES. THE INDEX I OF THIS LOCATION IS FIXED DURING THE JOB.
C     IT CAN BE OBTAINED BY THE FUNCTION IBLN, E.G.
C                  I = IBLN(NAME)
C     THUS IW(I) IS ZERO, IF NO BANK WITH THAT NAME EXISTS. IF
C                IND = IW(I)
C     IS NOT EQUAL TO ZERO, THEN IND IS THE INDEX OF THE
C     FIRST BANK FOR THAT NAME. THE POINTER TO THE NEXT BANK
C     OF THE SAME NAME (NEXT LARGER VALUE OF NR) IS STORED
C     IN THE LOCATION IW(IND-1), THUS CAN BE OBTAINED BY THE
C     STATEMENT
C                IND = IW(IND-1)
C
C
C
C
C
C
C
C
C
C
C
C
C     BELOW THE PROGRAMMING IS DESCRIBED FOR THE CASE, WHERE A LOOP
C     ON ALL BANKS OF THE SAME NAME IS EXECUTED. A LOCAL VARIABLE
C     INDF IS INITIALIZED TO ZERO BY A DATA STATEMENT, AND IS
C     DEFINED AS
C               INDF = IBLN(NAME)+1
C     AT THE FIRST EXECUTION OF THE LOOP.
C
C           DATA INDF/0/
C           IF(INDF.EQ.0) INDF=IBLN(NAME)+1
C           IND=INDF
C        10 IND=IW(IND-1)                         CALL BPOS(NAME)
C           IF(IND.EQ.0)    GOTO 30            10 CALL BNXT(IND,&30)
C      C    NEXT BANK FOUND                       . . .
C           . . .                                 . . .
C           . . .                                 . . .
C           GOTO 10                               GOTO 10
C      C    END OF LOOP                        30 . . .
C        30 . . .
C
C
C     BELOW THE PROGRAMMING IS DESCRIBED FOR THE CASE, WHERE A
C     CERTAIN BANK (NAME,NR) HAS TO BE LOCATED.
C
C
C           DATA INDF/0/
C           IF(INDF.EQ.0) INDF=IBLN(NAME)+1
C           IND=INDF
C        10 IND=IW(IND-1)
C           IF(IND.EQ.0)    GOTO 30
C           IF(IW(IND-2)-NR) 10,20,30         CALL BLOC(IND,NAME,NR,&30)
C      C    BANK (NAME,NR) FOUND              . . .
C        20 . . .
C
C      C    BANK NOT FOUND
C        30 . . .                          30 . . .
C
C     -----------------------------------------------------------------4
C     4.  SETS OF BANKS
C
C     SEVERAL SUBROUTINES WORK ON SET OF BANKS. THESE SETS ARE
C     DEFINED BY DEFINING A LIST OF NAMES, EVERY BANK WITH A NAME,
C     WHICH IS CONTAINED IN THE LIST, BELONGS TO THE SET OF BANKS.
C     THERE ARE TWO LISTS, ONE CALLED THE CURRENT LIST AND THE OTHER
C     THE SPECIAL LIST. THE CURRENT LIST IS USED IN THE SUBROUTINES
C            BDLM AND BDLG      TO DELETE A SET OF BANKS,
C            BPRM               TO PRINT A SET OF BANKS,
C            BWRITE ETC.        TO WRITE A SET OF BANKS (EVENT).
C
C     THE SPECIAL LIST IS DEFINED BY EACH INPUT ROUTINE, IT CONTAINS
C     AFTER THE INPUT OF ONE EVENT ALL NAMES (WITH MARKER EQUAL
C     TO 1) BELONGING TO THAT EVENT, AND IS LATER USED TO WRITE
C     THE BANKS AND TO DELETE THE BANKS. IF NEW BANKS ARE CREATED,
C     THEIR NAMES CAN BE ADDED TO THE SPECIAL LIST.
C
C
C     4.1  THE CURRENT LIST
C
C     THERE ARE THREE CALLS TO DEFINE THE CURRENT LIST.
C
C               - ----
C     CALL BMLT(N,LIST)
C
C        WHERE LIST( ) = ARRAY OF N NAMES
C
C
C
C     CALL BSLT
C
C     ALL NAMES OF THE SPECIAL LIST ARE DEFINED AS THE CURRENT LIST.
C
C
C
C     CALL BSLW
C
C     THE NAMES OF THE SPECIAL LIST WITH THE MARKER = 1 ARE DEFINED
C     AS THE CURRENT LIST.
C
C
C
C     THE LATTER TWO CALLS ARE USUALLY USED IN THE FOLLOWING
C     CONNECTION.
C
C     CALL BSLW
C     CALL BWRITE(IUN)      WRITE AN EVENT OF BANKS WITH NAMES OF
C                           THE SPECIAL LIST WITH MARKER +1.
C
C     CALL BSLT
C     CALL BDLG             DELETE ALL BANKS WITH NAMES OF THE
C                           SPECIAL LIST AND MAKE A GARBAGE
C                           COLLECTION.
C
C
C
C     THE CURRENT LIST OF NAMES CAN BE STORED IN AN USER DEFINED
C     ARRAY BY THE CALL
C
C                      -----
C     CALL BMRT(N,LIST,NLIST)
C
C        WHERE LIST( ) = ARRAY OF LENGTH NLIST
C                    N = NR OF NAMES STORED IN THE LIST
C
C     UP TO NLIST NAMES OF THE CURRENT LIST OF NAMES ARE STORED
C     INTO THE ARRAY LIST( ).
C
C
C
C     4.2  THE SPECIAL LIST
C
C
C                - ----                      - ----
C      CALL BSAT(N,LIST)           CALL BSAW(N,LIST)
C
C
C         WHERE LIST( ) = ARRAY OF N NAMES
C
C     IN BOTH CASES THE NAMES ARE ADDED TO THE SPECIAL LIST
C     (IF NOT ALREADY PRESENT), AND THE MARKER IS SET
C     =0 FOR BSAT AND =1 FOR BSAW.
C
C
C
C               - ----
C     CALL BSAD(N,LIST)
C
C     THE NAMES OF THE LIST ARE DELETED FROM THE SPECIAL LIST.
C
C
C
C
C
C     THERE ARE THREE ADDITIONAL CALLS, WHICH MAY BE USEFUL
C     UNDER SPECIAL CIRCUMSTANCES. THESE CALLS ALLOW TO CLEAR
C     THE SPECIAL LIST, TO SAVE THE SPECIAL LIST AND TO RESTORE
C     THE SAVED SPECIAL LIST.
C
C     CALL BSLC
C
C     THE SPECIAL LIST IS CLEARED (IT WILL CONTAIN NO NAMES).
C
C               --                     --
C     CALL BSLS(IS)          CALL BSLR(IS)
C
C     THE SPECIAL LIST IS SAVED BY BSLS UNDER AN ARBITARY
C     NUMBER IS. BY BSLR THE SAVED LIST IS RESTORED AS THE
C     SPECIAL LIST. THE ROUTINES USE A BANK TO STORE THE
C     SPECIAL LIST.
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C     THE CONNECTION BETWEEN THE TWO LISTS AND THE DIFFERENT
C     CALLS IS ILLUSTRATED IN THE FLOW DIAGRAM BELOW
C
C
C
C
C                        +---------------+
C                        I               I
C                        I SPECIAL LIST  I
C                        I     OF NAMES  I
C                ADDS    I               I
C        BSAW   ->->->->-I->->->-+-<-<-<-I-<-<-<-<-   INPUT ROUTINE
C                CHANGES I       |       I DEFINES
C                        I       V       I
C                        I       |       I
C                        I       V       I
C                ADDS    I       |       I
C        BSAT   ->->->->-I->-+-<-+->-+   I
C                CHANGES I   |       |   I
C                        I   V       V   I
C                        I   |       |   I
C                        +---------------+
C                            |       |
C                            V       V
C                            |       |
C
C          (USUALLY FOR    BSLT    BSLW   (USUALLY FOR
C       DELETING BANKS)                   WRITING BANKS)
C                            |       |
C                            V       V
C                            |DEFINES|
C                            V       V
C                            |       |
C                        +---------------+
C                        I               I
C                        I CURRENT LIST  I
C                        I     OF NAMES  I
C                DEFINES I               I
C        BMLT   ->->->->-I               I
C                        I               I
C                        I               I
C                        I               I
C                        +---------------+
C                                |
C                                V
C                                |
C                                V
C
C                        USED IN BPRM
C                                BDLM, BDLG
C                                OUTPUT ROUTINES
C
C
C
C
C     -----------------------------------------------------------------5
C     5.  PRINTOUT OF BANKS
C
C     5.1  SINGLE BANKS
C
C               -- --
C     CALL BPRS(NA,NR)
C
C
C        WHERE NA = NAME
C              NR = NUMBER OF BANK TO BE PRINTED
C
C
C     5.2  SETS OF BANKS
C
C                                      ---
C     CALL BPRM              CALL BPRL(LIM)
C
C     ALL BANKS OF THE CURRENT LIST OF NAMES ARE PRINTED. THE
C     CALL OF BPRL IS IGNORED AFTER LIM EXECUTIONS.
C
C     THE PRINTING FORMAT OF EACH WORD IS CHOSEN AUTOMATICALLY
C     (TEXT, INTEGER, REAL), NOT ALWAYS CORRECT.
C     -----------------------------------------------------------------6
C     6.  DELETING BANKS AND GARGAGE COLLECTION
C
C
C     6.1  SINGLE BANKS
C
C
C               -- --
C     CALL BDLS(NA,NR)
C
C
C        WHERE NA = NAME
C              NR = NUMBER OF BANK TO BE DELETED
C
C     IF THE DELETED BANK IS THE LAST IN STORAGE, ITS SPACE IS
C     IMMEDIATELY FREE FOR NEW BANKS, OTHERWISE BGAR HAS TO BE CALLED
C
C
C     6.2  SETS OF BANKS
C
C     CALL BDLM                   CALL BDLG
C
C     ALL BANKS OF THE CURRENT LIST OF NAMES ARE DELETED. IN BDLG
C     IN ADDITION A GARBAGE COLLECTION IS DONE.
C     A DELETED BANK IS NO LONGER ACCESSIBLE BY A CALL BLOC. IF THE
C     DELETED BANKS ARE THE LAST BANKS IN STORAGE, THEIR SPACE
C     IS IMMEDIATELY FREE FOR NEW BANKS ALSO FOR BDLM. OTHERWISE
C     THERE HAS TO BE AN EXTRA CALL OF BGAR.
C
C
C     6.3  GARBAGE COLLECTION
C
C     IN A GARBAGE COLLECTION THE ACTIVE (NOT DELETED) BANKS ARE
C     SHIFTED IN STORAGE, IF THERE ARE BANKS DELETED.
C
C
C
C     CALL BGAR(IGA)
C               ---
C
C        IGA = 0 NO GARBAGE COLLECTION DONE (IF NO BANKS WERE DELETED)
C        IGA = 1 GARBAGE COLLECTION DONE
C
C     WARNING. BECAUSE IN A GARBAGE COLLECTION, SOME BANKS (ALL BANKS
C     BEHIND DELETED BANKS) ARE SHIFTED, THE INDICES OF THE BANKS
C     CHANGE. AUTOMATIC GARBAGE COLLECTIONS ARE DONE IN THE INPUT-
C     OUTPUT ROUTINES (SEE 9.)
C
C
C     6.4   CALL OF THE PREVIOUS VERSION
C
C                   --
C     CALL BGAC(IGA,NW)
C               ---
C
C        WHERE NW = NR.OF WORDS OF A NEW BANK
C     NO GARBAGE COLLECTION IS DONE, IF THERE IS SPACE ENOUGH
C     FOR AN ADDITIONAL BANK WITH NW WORDS
C
C
C     -----------------------------------------------------------------7
C     7.  INPUT FROM CARDS
C
C     DATA CAN BE READ FROM CARDS IN FREE FORMAT OR IN A FORMAT GIVEN
C     ON THE CARDS ITSELF, AND STORED IN BANKS. THE LAST 8 COLS OF THE
C     CARDS ARE NOT USED IN FREE FORMAT MODE.
C
C     CALL BREADC
C
C     DATA ARE READ FROM CARDS (UNIT 5) UNTIL DATA END OR A CARD WITH
C     ENDQ IS READ.
C
C
C
C     7.1 FREE FORMAT
C
C     READING A CARD OF THE TYPE
C     NAME A B C . . .
C     CREATES A BANK (NAME,0) WITH DATA A, B ,C . . .
C     A SECOND CARD WITH THE SAME NAME CREATES A BANK (NAME,1) ETC.
C     IF THE FIRST CHARACTER OF NAME IS THE DOLLARSIGN $, THAN
C     THE INPUT IS ACCORDING TO THE MODE DESCRIBED BELOW.
C
C     NAME N / A B C . . .
C     CREATES A BANK (NAME,N) WITH DATA A, B, C . . .
C     A SECOND CARD WITH THE SAME (NAME,N) IS NOT STORED.
C
C     THE BANK NAME  CONSISTS OF THE FIRST FOUR CHARACTERS OF
C     NAME.
C     N, A, B, C, . . . ARE CONSTANTS.
C     INTEGER CONSTANTS ARE TO BE WRITTEN WITHOUT A DOT (.),
C     REAL CONSTANTS WITH DOT (.) AND OPTIONALLY WITH EXPONENT.
C     CONTINUATION CARDS STARTING IMMEDIATELY WITH CONSTANTS ARE
C     ALLOWED. NON-NUMERIC CHARACTERS BETWEEN CONSTANTS ARE
C     IGNORED.
C
C     7.2  FORMATED
C
C     AFTER READING A CARD
C
C     NAME N NW '(FORMAT)
C
C     NW WORDS ARE READ ACCORDING TO THE GIVEN FORMAT FROM CONSECUTIVE
C     CARDS AND STORED IN A BANK (NAME,N). THE FORMAT
C     SHOULD START WITH 1X (SEE EXAMPLE), TO ALLOW ECHO-PRINTOUT
C     WITHOUT LINE SKIPPING.
C
C
C     7.3  SPECIAL CARDS
C
C                                 ACTION
C
C     ENDQ                        BREADC RETURNS
C
C     POFF                        PRINTING OF CARDS IS SWITCHED OFF
C
C     PON                         PRINTING OF CARDS IS SWITCHED ON AGAIN
C
C     UNIT N     (N = INTEGER)    THE NEXT CARDS ARE READ FROM
C                                 UNIT N UNTIL DATA END, THEN AGAIN
C                                 FROM UNIT 5.
C
C
C
C     7.4  EXAMPLE
C
C
C     CONSTANTS 1.7 2.3 7 1.23E-4
C     RUN 2769 / 1.520 16.0
C     0.7 2.0
C     TITL 2000 5 '(1X,5A4)
C      PI+ PI+ PI- PI- PI0
C     ENDQ
C
C
C
C
C     BANKS STORED
C
C     NAME             CONS   RUN    TITL
C     NUMBER              0   2769   2000
C     NR.OF WORDS         4      4      5
C
C     1.DATA WORD       1.7  1.520   PI+
C     2.DATA WORD       2.3   16.0   PI+
C     3.DATA WORD         7    0.7   PI-
C     4.DATA WORD   1.23E-4    2.0   PI-
C     5.DATA WORD                    PI0
C
C     INDICES ARE OBTAINED BY
C     CALL BLOC(IND,'CONS',0,&S1)
C     CALL BLOC(IND,'RUN ',2769,&S1)
C     CALL BLOC(IND,'TITL',2000,&S1)   RESP.
C
C     -----------------------------------------------------------------8
C     8.  UNFORMATED INPUT/OUTPUT OF BANKS
C
C     BANK RECORDS ARE OF THE FORM
C        NTOT, BANK1, BANK2, . . . BANKN
C     WITH NTOT = NR OF WORDS OF ALL BANKS, THE TOTAL NR OF (USED)
C     WORDS IN A RECORD IS THEREFORE NRECL = NTOT +1.
C
C        FIRST WORD IN RECORD   = NTOT
C        NEXT WORD              = NAME
C        NEXT WORD              = NUMBER OF FIRST BANK
C        NEXT WORD              = POINTER (NO MEANING IN RECORD)
C        NEXT WORD              = NR.OF WORDS OF THE FIRST BANK
C        ETC.
C
C
C
C
C     8.1 STANDARD OUTPUT AND INPUT
C
C
C     OUTPUT IS DONE BY FIRST SELECTING THE NAMES OF ALL BANKS
C     TO BE WRITTEN AND THEN BY CALLING THE OUTPUT PROGRAM. THE
C     SET OF BANKS DEFINES ONE EVENT. IF THE EVENT IS WRITTEN,
C     THE ORDER OF THE BANKS IS ALWAYS THE SAME AS WITHIN THE LIST,
C     WITH BANKS OF THE SAME NAME IN THE ORDER OF INCREASING NUMBER.
C     ALL BANKS OF ONE EVENT ARE READ INTO THE COMMON/BCS/ BY
C     ONE CALL OF THE INPUT PROGRAM.
C
C
C
C
C
C
C
C     OUTPUT OF ONE EVENT
C
C        CALL BSLW               OR  CALL BMLT(N,LIST OF NAMES)
C
C
C        CALL BWRITE(IUN)
C
C     AFTER THE LAST EVENT, A ZERO LIST OF NAMES HAS TO BE DEFINED
C     AND BWRITE HAS TO BE CALLED AGAIN.
C
C        CALL BMLT(0,DUMMY)
C        CALL BWRITE(IUN)
C
C
C
C     INPUT OF ONE EVENT
C
C        CALL BREAD(IUN,&1,&2)         CALL CREAD(IUN,IER)
C
C     SPECIAL CONDITIONS
C
C                      BREAD                    CREAD
C
C     READ ERROR       RETURN1 (&1)             IER=1
C     END-OF-DATA      RETURN2 (&2)             IER=2
C
C
C
C     8.2 OUTPUT MODES AND RECORD TYPES
C
C
C     THERE ARE TWO TYPES OF RECORDS AND THREE MODES OF OUTPUT.
C
C     TYPES OF RECORDS
C
C     S-RECORDS     ONE RECORD CONTAINS ONE EVENT
C
C     M-RECORDS     ONE RECORD MAY CONTAIN SEVERAL EVENTS OR PARTS
C                   OF EVENTS. WITHIN THE RECORD, EVENTS OR PARTS
C                   OF EVENTS ARE WITHIN BANKS WITH THE NAME 'HIDD'.
C
C     FOR BOTH RECORD TYPES, THE INPUT PROGRAM ALWAYS PUTS THE
C     BANKS OF ONE EVENT INTO COMMON/BCS/.
C
C     THE OUTPUT MODE AND A MAXIMUM RECORD LENGTH IS DEFINED BY ONE
C     CALL (BEFORE THE FIRST CALL OF THE OUTPUT PROGRAM) FOR THE
C     OUTPUT UNIT IUNIT.
C
C                  ----- ----- ----
C        CALL BWRO(IUNIT,NRECL,MODE)
C
C     IF NOT CALLED, MODE = 0 IS ASSUMED WITH NRECL TAKEN FROM THE
C     CALL TO THE BOS INITIALIZATION PROGRAM BINT (SEE CH. 1).
C
C
C
C
C     MODES OF OUTPUT
C
C     MODE = 0     S-RECORDS ARE WRITTEN. THE EVENT IS NOT WRITTEN, IF
C                  THE LENGTH OF THE EVENT EXCEEDS NRECL WORDS.
C
C     MODE = 1     S-RECORDS OR M-RECORDS ARE WRITTEN. M-RECORDS ARE
C                  WRITTEN, IF THE LENGTH OF ONE EVENT EXCEEDS NRECL
C                  WORDS.
C
C     MODE = 2     M-RECORDS ARE WRITTEN.
C
C     THE RECORD LENGTH WILL NEVER EXCEED NRECL WORDS. IT IS POSSIBLE
C     (AND DONE IN BWRITE), TO WRITE RECORDS OF FIXED LENGTH NRECL
C     (ADDING UNUSED WORDS, IF NTOT IS LESS THAN NRECL - 1)
C
C
C     8.3 USER WRITE AND READ STATEMENTS
C
C     THE USER CAN USE HIS OWN WRITE AND READ STATEMENTS, TO ALLOW
C     E.G. USING THE IBM-FORTRAN DIRECT ACCESS STATEMENTS.
C     FOR OUTPUT THE STATEMENT CALL BWRITE(IUN) HAS TO BE REPLACED
C     (ALSO FOR THE CALL AFTER THE LAST EVENT) BY THE FOLLOWING
C     STATEMENTS.
C
C        1  CALL BWRS(IUN,NREC,INIW)
C           IF(INIW.EQ.0) GOTO 2
C           WRITE ONE RECORD ON UNIT IUN OF TOTAL NREC WORDS
C           IW(INIW),IW(INIW+1), . . . IW(INIW+NREC-1)
C           GOTO 1
C        2  CONTINUE
C
C     REMARK. IW(INIW) CONTAINS NTOT. FOR MODE = 0 OR = 1, NREC
C     IS EQUAL TO NTOT+1, FOR MODE = 2 NREC IS EQUAL TO NRECL
C     (FIXED NUMBER OF WORDS).
C
C
C     FOR INPUT THE STATEMENT CALL BREAD(IUN,&1,&2) HAS TO BE
C     REPLACED BY THE FOLLOWING STATEMENTS.
C
C
C        1  CALL BRDS(IUN,NREC,INIR)
C           IF(INIR.EQ.0) GOTO 2
C           READ ONE RECORD FROM UNIT IUN INTO WORDS
C           IW(INIR),IW(INIR+1), . . .
C           (SEE REMARKS BELOW)
C           GOTO 1
C        2  CONTINUE
C
C     REMARKS. THE ARGUMENT NREC IS (FOR INIR NOT EQUAL 0) EQUAL
C     TO THE LARGEST ALLOWED NUMBER OF WORDS, WHICH CAN BE READ.
C     SAFE INPUT IS POSSIBLE USING A SUITABLE ASSEMBLER READ ROUTINE.
C     THE END-OF-DATA CONDITION HAS TO BE HANDLED BY THE USER. IN
C     CASE OF READ ERRORS THIS CONDITION CAN BE SIGNALLED TO THE
C     BRDS PROGRAM BY DEFINING IW(INIR) = 0 AND GOTO 1. OTHERWISE
C     IW(INIR) CONTAINS NTOT = NR OF WORDS OF THE RECORD FOLLOWING.
C
C     FOR THE USE IN SPECIAL USER-WRITTEN INPUT-OUTPUT PROGRAMS
C     OR OTHER APPLICATIONS, THERE ARE TWO CALLS, WHICH ASSEMBLE
C     BANKS BELONGING TO THE CURRENT LIST IN CONTIGUOUS BANKSPACE
C     (BOUTP) AND STORE BANKS FROM AN ARBITRARY ARRAY INTO THE
C     COMMON /BCS/ (BINP).
C
C     CALL BOUTP(NRW,INIW)
C                --- ----
C     ALL BANKS BELONGING TO THE CURRENT LIST ARE ARRANGED IN
C     CONTIGUOUS BANK SPACE, STARTING AT LOCATION IW(INIW) WITH
C     A TOTAL OF NRW WORDS (INIW = 0 IN CASE OF ERRORS).
C
C               --- --
C     CALL BINP(NRW,AR)
C
C     ALL BANKS STORED IN THE ARRAY AR(1) . . . AR(NRW) ARE STORED
C     IN THE COMMON /BCS/, IF THERE IS ENOUGH SPACE AND IF THE ARRAY AR
C     CONTAINS CORRECT BANKS.
C
C
C
C     8.4   BUFFER BANKS
C
C     FOR EACH INPUT/OUTPUT UNIT IUN A BANK ('+BUF',IUN) IS USED
C     WITH BETWEEN 11 AND 10 +NRECL WORDS DEPENDING ON RECORD TYPE.
C     THESES BANKS ALSO CONTAIN STATISTIC ON INPUT/OUTPUT,
C     WHICH IS PRINTED BY CALLING THE STATUS-PRINT ROUTINE BSTA.
C     AFTER THE END OF INPUT/OUTPUT THESE BANKS CAN BE DELETED BY THE
C     USUAL CALL
C        CALL BDLS('+BUF',IUN)
C     THIS IS NECESSARY, IF THE SAME UNIT NUMBER IUN IS USED AFTERWARDS.
C     THE CONTENT OF THE BUFFER BANKS IS DESCRIBED IN CH. 10.
C
C
C
C     8.5    STANDARD EVENT READING/WRITING
C
C     PROGRAMMING EXAMPLE OF STANDARD EVENT PROCESSING WITH REPEATED
C     EXECUTION OF
C
C             INPUT OF ONE EVENT
C             PROCESS EVENT
C             OUTPUT OF EVENT
C             DELETE BANKS AND GARBAGE COLLECTION.
C
C     INPUT IS ASSUMED FROM UNIT 1, OUTPUT TO UNIT 2 WITH OUTPUT
C     MODE 0 AND A LIMIT OF 5000 WORDS PER RECORD.
C
C
C           CALL BINT(10000,0,0,0)
C           CALL BWRO(2,5000,0)
C     C
C     C     EVENT LOOP
C     C
C         1 CALL BREAD(1,&1,&2)
C     C     PROCESS EVENT
C           .....
C           .....
C           .....
C           CALL BSLW
C           CALL BWRITE(2)
C           CALL BSLT
C           CALL BDLG
C           GOTO 1
C     C
C     C     END OF EVENT LOOP
C     C
C         2 CALL BMLT(0,DUMMY)
C           CALL BWRITE(2)
C           STOP
C           END
C
C
C
C
C     THERE IS A STANDARD PROGRAM BSEQ, WHICH INCLUDES THE STANDARD
C     BOS PROGRAMS FOR INPUT, OUTPUT AND THE DELETING OF BANKS, AS
C     SHOWN IN THE EXAMPLE ABOVE.
C
C
C     CALL BSEQ(MARK)
C               ----
C
C        WHERE MARK = 0   ONE EVENT READ
C                   = 1   END, NO EVENT READ
C
C
C     BESQ, WHICH IS USED IN A LOOP, READS, EACH TIME CALLED, ONE
C     EVENT FROM UNIT 1. BSEQ RETURNS WITH MARK =1 IN THE END-OF-DATA
C     CONDITION, OR NSEC = 2 SECONDS BEFORE TIME OVERFLOW (TIME IS
C     CHECKED USING THE PROGRAM JUHR). THIS LIMIT CAN BE CHANGED
C     BY (BEFORE THE LOOP)
C
C     CALL BSET(NSEC)
C
C
C     IT IS ALSO POSSIBLE, TO DELIMIT THE NR OF EVENTS TO BE READ
C     BY (BEFORE THE LOOP)
C
C     CALL BSEL(LIMIT)
C
C     BSEQ WILL RETURN WITH MARK = 1 AFTER LIMIT EVENTS.
C
C     OUTPUT IS POSSIBLE WITH BSEQ ONTO THREE DIFFERENT OUTPUT UNITS.
C     IF AN EVENT SHOULD BE WRITTEN ONTO UNIT IUN, THIS HAS TO
C     SIGNALLED BY
C
C     CALL BSEW(IUN)
C
C     IF THE EVENT SHOULD NOT BE WRITTEN ONTO UNIT IUN, THIS IS
C     SIGNALLED BY (WITH A NEGATIVE UNIT)
C
C     CALL BSEW(-IUN)
C
C     DEFAULT IS NO OUTPUT FOR ALL EVENTS. THE OUTPUT ROUTINES ARE
C     CALLED WITHIN BSEQ AT THE NEXT ENTRY, USING THE SPECIAL LIST
C     OF NAMES (BSLW FOR OUTPUT, BSLT FOR DELETING BANKS).
C     THE OUTPUT MODES HAVE TO BE DEFINED BEFORE THE LOOP.
C
C
C
C     EXAMPLE FOR A COMPLETE MAIN PROGRAM.
C     1000 EVENTS ARE TO BE READ FROM UNIT 1, OUTPUT IS TO
C     UNIT 2 FOR ALL EVENTS, AND, FOR CERTAIN EVENTS, ALSO TO
C     THE UNITS 3 AND 4.
C
C
C           CALL BINT(10000,0,0,)
C           CALL BSET(5)
C           CALL BSEL(1000)
C           CALL BWRO(2,5000,0)
C           CALL BWRO(3,2000,1)
C           CALL BWRO(4,2000,1)
C     C
C     C     EVENT LOOP
C     C
C         1 CALL BSEQ(MARK)
C           IF(MARK.EQ.1) GOTO 2
C     C     PROCESS EVENT
C           .....
C           CALL BSEW(2)
C           CALL BSEW(3)
C           .....
C           .....
C           IF(.....) CALL BSEW(-3)
C           IF(.....) CALL BSEW(4)
C           GOTO 1
C     C
C     C     END OF EVENT LOOP
C     C
C         2 CALL BSTA
C           STOP
C           END
C
C
C     THERE IS ALSO THE POSSIBILITY IN BSEQ, TO READ WITH AN
C     ASSEMBLER PROGRAM (VBS RECORDS). IF THIS IS WANTED, ONE
C     HAS TO CALL
C
C     CALL ASVBS(IU)
C
C     BEFORE THE FIRST CALL OF BSEQ , TO DEFINE THE INPUT UNIT
C     NUMBER IU (DDNAME FTIUF001).
C
C
C
C
C     -----------------------------------------------------------------9
C     9.  BANKS ON DIRECT ACCESS DATA SETS
C
C     THE DIRECT ACCESS BOS ROUTINES ALLOW TO STORE BANKS ON A DIRECT
C     ACCESS DATA SET, CALLED DADS, AND, IN THE SAME JOB OR IN A LATER
C     JOB, TO GET THE BANKS BACK TO THE COMMON/BCS/ OR TO DELETE BANKS
C     ON THE DADS (SEE CH. 9.2). THE ROUTINES USE THE IBM-FORTRAN
C     DIRECT ACCESS FEATURES (E.G. DEFINE FILE), THEY WORK WITH
C     RECORDS OF FIXED LENGTH 1610 WORDS, HOWEVER THE BANKS MAY HAVE
C     ANY LENGTH BETWEEN 1 WORD AND 3200 WORDS.
C     THE DADS HAS TO BE INITIALIZED (SEE CH 9.1) BEFORE THE FIRST
C     BANK IS ADDED TO THE DADS.
C
C
C     9.1  INITIALIZATION OF A DADS
C
C     A DADS IS INITIALIZED BY THE FOLLOWING STATEMENTS, USING THE
C     DD-CARD SHOWN.
C
C          DEFINE FILE IU(NREC,1610,U,IVAR)
C          CALL BINLDA(IU,NREC,IPASS)
C
C     //FTIUF001 DD DSN=DSNAME,DISP=(NEW,CATLG),UNIT=FAST,
C     //   SPACE=(6440,(NREC))
C
C          WHERE    IU = (CONSTANT) FORTRAN=NR. OF THE DADS, EQUAL
C                        TO 17, 18 OR 19
C                 NREC = (CONSTANT) NR OF RECORDS, OF LENGTH 1610 WORDS.
C                        AT LEAST NREC = 10.
C                IPASS = PASSWORD (SEE CH.9.4) FOR PROTECTION
C                        OF THE DADS (NO PROTECTION FOR IPASS = 0)
C                 IVAR = DUMMY VARIABLE
C               DSNAME = DSNAME OF THE DADS
C
C     IN LATER JOBS, THE DD-CARD SHOULD CONTAIN DISP=SHR. THE
C     DEFINE FILE STATEMENT IS NOT NECCESSARY IN LATER JOBS,
C     UNLESS NREC IS GREATER THAN 200.
C
C     WITH NREC = 70, THERE IS SPACE ON THE DADS FOR ABOUT
C     100 000 WORDS.
C
C
C     9.2   STORING AND RETRIEVING BANKS
C
C     IF ANY OF THE CALLS DESCRIBED HERE IS USED, A STATEMENT
C     EXTERNAL BLOCDA
C     SHOULD BE INCLUDED IN THE USER-PROGRAM, TO MAKE SHURE
C     THAT THE SUBROUTINE BLOCDA, WHICH HAS THE ADDITIONAL
C     ENTRIES BCREDA, BDLSDA AND BCHKDA, IS INCLUDED BY THE
C     LINK EDITOR.
C     SEE CH. 9.4 FOR THE USE OF PROTECTED DADS.
C
C
C                 ----- ---
C     CALL BCREDA(IUNDA,IND)
C
C        WHERE IUNDA = FORTRAN UNIT OF DADS (17, 18 OR 19)
C              IND   = INDEX OF THE BANK TO BE STORED ON THE DADS
C
C     THE BANK AT THE INDEX IND IS STORED ON THE DADS, IF THE LENGTH
C     OF THE BANK IS BETWEEN 1 AND 3200 WORDS, AND IF THERE IS ENOUGH
C     SPACE ON THE DADS. IF THERE IS ALREADY A BANK WITH THE SAME
C     NAME AND NR ON THE DADS, THEN THE OLD ONE IS REPLACED BY THE
C     NEW ONE. IF THE LENGTH OF THE OLD BANK IS EQUAL TO THE LENGTH
C     OF THE NEW BANK, NO ADDITIONAL SPACE IS USED ON THE DADS.
C
C
C
C                 -----     ---- --
C     CALL BLOCDA(IUNDA,IND,NAME,NR,&1)
C                       ---         --
C
C        WHERE IUNDA = FORTRAN UNIT OF DADS (17, 18 OR 19)
C              IND   = INDEX OF THE BANK TO BE STORED ON THE DADS
C              NAME  = NAME OF THE BANK
C              NR    = NUMBER OF THE BANK
C              &1    = RETURN 1, IF BANK NOT FOUND (IND=0)
C
C     IF THE BANK IS ALREADY IN STORAGE, THE INDEX IND IS GIVEN
C     WITHOUT SEARCHING THE DADS. OTHERWISE THE DADS IS SEARCHED FOR
C     THE BANK (NAME,NR). IF FOUND, THE BANK IS STORED IN THE
C     COMMON/BCS/.
C
C
C
C
C                 ----- ---- --
C     CALL BDLSDA(IUNDA,NAME,NR)
C
C
C        WHERE IUNDA = FORTRAN UNIT OF DADS (17, 18 OR 19)
C              NAME  = NAME OF THE BANK
C              NR    = NUMBER OF THE BANK
C
C     THE BANK IS DELETED FROM THE DADS. THE SPACE USED ON THE DADS
C     CANNOT BE USED FOR NEW BANKS.
C
C
C
C
C                 ----- ---- --
C     CALL BCHKDA(IUNDA,NAME,NR,NW)
C                               --
C
C        WHERE IUNDA = FORTRAN UNIT OF DADS (17, 18 OR 19)
C              NAME  = NAME OF THE BANK
C              NR    = NUMBER OF THE BANK
C              NW    = NR OF WORDS OF THE BANK (NW = 0, IF NOT FOUND
C                      ON THE DADS)
C
C     THE DADS IS SEARCHED FOR THE BANK (NAME,NR). IF FOUND, THE
C     LENGTH OF THE BANK IS GIVEN IN NW (OTHERWISE NW = O).
C
C
C     9.3   UNLOADING AND LOADING THE DADS
C
C     THE SUBROUTINE DESCRIBED BOTH NEED ABOUT 6000 WORDS OF
C     BANK STORAGE, BOTH MAKE A GARBAGE COLLECTION BEFORE THEY
C     RETURN.
C
C                 ----- ----- ---- ----- -----
C     CALL BUNLDA(IUNDA,IUNTP,NREC,NPAGE,IPASS)
C
C
C        WHERE IUNDA = FORTRAN UNIT OF DADS (17, 18 OR 19)
C              IUNTP = FORTRAN UNIT OF THE SEQUENTIAL DA
C              NREC  = NR OF USED RECORDS OF THE DADS, TO BE UNLOADED,
C                      USUALLY THIS ARGUMENT CAN BE ZERO(SEE BELOW)
C              NPAGE = NR OF PAGES FOR PRINTOUT
C              IPASS = PASSWORD
C
C     ALL BANKS FROM THE DADS ARE WRITTEN (S-TYPE RECORDS) ONTO
C     THE SEQUENTIAL DATASET. THIS IS ALSO DONE, IF THE PASSWORD
C     IS NOT CORRECT. IF NREC = 0, THEN THE NR OF RECORDS
C     IS TAKEN FROM THE DADS (USUAL CASE). NREC SHOULD ONLY BE
C     GIVEN IN SPECIAL CASES.
C     DURING UNLOADING A TABLE (NAMES, NUMBERS, LENGTHS) IS
C     PRINTED (MAXIMUM NPAGE PAGES). IF IUNTP = 0, THEN ONLY
C     THE TABLE OF CONTENT IS PRINTED.
C
C
C
C
C                 ----- ----- -----
C     CALL BLOADA(IUNDA,IUNTP,IPASS)
C
C
C        WHERE IUNDA = FORTRAN UNIT OF DADS (17, 18 OR 19)
C              IUNTP = FORTRAN UNIT OF SEQUENTIAL DATA SET,
C                      OBTAINED BY THE USE OF BUNLDA.
C              IPASS = PASSWORD
C
C     THE PROGRAM STOPS, IF THE DADS IS PROTECTED AND AN
C     INCORRECT PASSWORD IS USED.
C     ALL BANKS OF THE SEQUENTIAL DATA SET ARE STORED ON THE
C     DADS, THE PREVIOUS CONTENT OF THE DADS IS OVERWRITTEN.
C
C
C
C     BUNLDA CAN BE USED TO WRITE BACKUP-COPIES OF THE DADS.
C     THE DADS CAN BE COMPRESSED BY THE USE OF BUNLDA, FOLLOWED
C     THE USE OF BLOADA.
C
C
C
C
C     9.4   PROTECTED DADS
C
C
C     IT IS POSSIBLE TO DEFINE A PASSWORD AT THE TIME OF INITIALIZATION
C     OF THE DADS. THEN, FOR ALL CALLS, WHICH MODIFY THE DADS, THE
C     CORRECT PASSWORD HAS TO BE GIVEN. IN ADDITION THERE IS A
C     SPECIAL PASSWORD, WHICH ALLOWS TO MODIFY PROTECTED DADS
C     WITHOUT KNOWING THE CORRECT PASSWORD.
C
C     THE PASSWORD IS GIVEN BY THE CALL
C
C                 ----- ----
C     CALL BPASDA(IUNDA,PASS)
C
C        WHERE  IUNDA = FORTRAN UNIT OF DADS
C               IPASS = PASSWORD
C
C
C
C     BPASDA HAS TO BE CALLED ONCE BEFORE ANY CALL OF
C     BCREDA OR BDLSDA, IF THE DATA SET IS PROTECTED AND
C     SHALL BE MODIFIED BY BCREDA OR BDLSDA. OTHERWISE THE
C     CALLS OF BCREDA AND BDLSDA ARE IGNORED.
C
C
C     ----------------------------------------------------------------10
C
C     10.  PRINTING STATISTIC AND A DUMP
C
C     THE STATUS OF THE BOS-SYSTEM, EXPECIALLY STATISTICS ON INPUT/
C     OUTPUT IS PRINTED BY
C
C     CALL BSTA
C
C
C
C     A DUMP CONTAINING RELEVANT STATUS INFORMATION AND NDMP
C     WORDS OF THE COMMON/BCS/IW(NSPACE) IS PRINTED BY
C
C     CALL BDMP
C
C     THE PROGRAM STOPS CALLING ABEND.
C     BDMP IS CALLED AUTOMATICALLY IN BOS-ROUTINES UNDER SEVERAL
C     ERROR CONDITIONS, DESCRIBED BELOW. IT IS ALSO CALLED IN
C     CASE OF A SYSTEM COMPLETION CODE 0CX, IF THE STATEMENT
C
C     CALL DUMP0C
C
C     IS USED AFTER BINT.
C
C
C
C     ICOND  SUBPGM   CONDITION                               REMARK
C     -----  ------   --------------------------------------  -------
C         1    IBLN   TOO MANY NAMES USED                     1,2
C        11  BREADC   NOT ENOUGH SPACE IN COMMON/BCS/         3
C        12    BRDS   NOT ENOUGH SPACE IN COMMON/BCS/         3
C        13    BWRS   NOT ENOUGH SPACE IN COMMON/BCS/         3
C        14  BLOADA   NOT ENOUGH SPACE IN COMMON/BCS/, OR     3,4
C                     ILLEGAL DADS
C        15    PODA   NOT ENOUGH SPACE IN COMMON/BCS/, OR     3,4
C                     ILLEGAL DADS
C        21    BRDS   TOO MANY READ ERRORS                    5,1
C        22    BRDS   RECORD READ TOO LONG                    5,3
C        23    BRDS   WRITE-UNIT USED FOR READING
C        24    BWRS   READ-UNIT USED FOR WRITING
C        31    ----   FORTRAN ERROR 240 (0CX)                 6,7
C        32    BGAR   WRONG INDEX FOUND                       6
C        41   BREADC  INCORRECT CARD FOR FORMATED INPUT
C
C
C     REMARKS
C     1   CHANGE PARAMETERS IN BINT1
C     2   PROBABLY USER ERROR, WRONG VARIABLE USED AS A NAME
C     3   INCREASE TOTAL SPACE IN COMMON/BCS/
C     4   PROBABLY USER ERROR, WRONG DATA SET USED
C     5   READ ERRORS
C     6   PROBABLY USER ERROR, BANK STRUCTURE OVERWRITTEN
C     7   PROBABLY USER ERROR, IN MOST CASES A WRONG INDEX IS USED
C
C
C
C
C     DESCRIPTION OF THE VARIABLES OF THE COMMON/ACS/, PRINTED
C     IN A DUMP.

C     INDEX    VARIABLE     MEANING
C
C       1      ICOND        ERROR CONDITION
C       2      NLAST        LENGTH OF COMMON/BCS/
C       3      NDUMP        NR OF WORDS PRINTED IN A DUMP
C       4      NSPL         NR OF WORDS FOR LOW PRIORITY BANKS
C       5      NAMAX        NR OF DIFFERENT NAMES ALLOWED
C       6      NAMAX1       NAMAX+1
C       7      NLIST        NR OF ENTRIES IN LISTS ALLOWED
C       8      NPRIME       PRIME NR USED IN IBLN
C       9      NFRS         FIRST LOCATION FOR BANKS
C      10      NLST         LAST LOCATION FOR BANKS
C
C      11      NEXT         NEXT LOCATION FOR BANKS
C      12      NCI          ACTUAL NR OF DIFFERENT NAMES
C      13      NFRE         NR OF FREE LOCATIONS
C      14      IN           ACTUAL NR OF NAMES IN LIST
C      15      KPOS         INDEX FROM BPOS/CPOS
C      16      LIND         INDEX OF LAST CREATED BANK
C      17      ILOW         LOWEST INDEX OF DELETED BANK
C      18      LFDI         LAST I-INDEX
C      19      LFDK         LAST K-INDEX
C      20      NCPL         ACTUAL NR OF WORDS OF LOW PRIORITY SPACE
C
C      21-30   NHISTH(10)   HISTOGRAM FOR TOTAL SPACE
C
C      31      NHISTH(11)   OVERFLOWS TOTAL SPACE
C      32      NCOL         NR OF GARBAGE COLLECTIONS
C      33      NZT          TIME OF BOS-START
C      34      IBFI         INDEX FOR BUFF-BANK
C      35      NLAST1       COPY OF NLAST
C      36      ISLST        INDEX FOR SPECIAL LIST OF NAMES
C      37      IMLST        INDEX FOR MARKERS OF SP. LIST O.N.
C      38      INAMV        INDEX FOR NAMES
C      39      IOLST        INDEX FOR IO-LIST
C      40      IPLST        INDEX FOR POINTERS TO NAMES
C
C      41-50   NER(10)      INPUT ERROR CODES FROM BINP/BRDS
C
C      51      NRECL        DEFAULT RECORD LENGTH FOR OUTPUT
C      52      NERRL        NR OF ERRORS ALLOWED
C      53      NRIN         NR OF INPUT EVENTS
C      54      NROUT        NR OF OUTPUT EVENTS
C      55      NS           ACTUAL NR OF NAMES IN SPECIAL LIST
C      56      NEXTI        NEXT INDEX FOR BANKS IN BRDS
C      57      NEXTA        INDEX OF BEGIN OF NEW EVENT
C      58      NEXTB        INDEX BEHIND NEW EVENT
C      59      ISAVB        INDEX OF SAVED LOCATION IN BWRS
C      60      NSAVB        CONTENT OF SAVED LOCATION IN BWRS
C
C      61-70   NHISTL(10)   HISTOGRAM FOR LOW PRIORITY SPACE
C
C      71      NHISTL(11)   OVERFLOWS OF LOW PRIORITY SPACE
C      72      MARKWR       MARKER FOR BSEQ
C      73-75   NOUT(3)      OUTPUT UNITS FOR BSEQ
C      76      IASW         SWITCH FOR FORTRAN/ASSEMBLER READ (BSEQ)
C      77      NPRE         NR OF BPRE PRINTOUTS
C      78      IDUMMY(1)    ONE DUMMY WORD (ZERO)
C      79      NEOTP        NR OF LISTINGS FOR INPUT-BANK ERRORS WITH
C                           ERROR CODE LESS THAN 6
C      80      NDUMP1       SAME AS NDUMP
C
C
C
C
C     DESCRIPTION OF BANKS ('+BUF',IUN) FOR INPUT AND OUTPUT
C
C
C
C     BUFFER FOR INPUT = BANK ('+BUF',IUN), LENGTH = 11,
C              LENGTH = 10 + NRECL FOR M-RECORDS
C
C     IBF+ 1   =1 (INPUT)
C          2   BUFFER SIZE USED
C          3   NR OF IO-ERRORS
C          4   NR OF RECORDS
C          5   NR OF EVENTS ACCEPTED
C          6   NR OF EVENTS, WHICH ARE TOO LARGE
C          7   SUM OF NR OF WORDS IN ALL EVENTS
C          8   MAX NR OF WORDS IN AN EVENT
C          9   LIMIT FOR NR OF ERRORS
C         10   POINTER WITHIN RECORD TO NEXT EVENT
C         ----------------
C         11   NTOT (= NR OF WORDS IN THE RECORD FOLLOWING)
C         12   RECORD
C          .   . . .
C          .   . . .
C
C     BUFFER FOR OUTPUT = BANK ('$BUF',IUN), LENGTH = 11
C              LENGTH = 10 + NRECL FOR M RECORDS
C
C     IBF+ 1   =2 (OUTPUT)
C          2   BUFFER SIZE
C          3   OUTPUT MODE
C          4   NR OF RECORDS
C          5   NR OF EVENTS ACCEPTED
C          6   NR OF EVENTS, WHICH ARE TOO LARGE
C          7   SUM OF NR OF WORDS IN ALL EVENTS
C          8   MAX NR OF WORDS IN AN EVENT
C          9   HIDD-NR
C         10   POINTER WITHIN RECORD TO NEXT EVENT
C         ----------------
C         11   NTOT (= NR OF WORDS IN THE RECORD FOLLOWING)
C         12   RECORD
C          .   . . .
C          .   . . .
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C     -----------------------------------------------------------------A
C
C     APPPENDIX A.   THE SBOS - SYSTEM
C
C
C     THE SBOS SYSTEM IS A SMALL SYSTEM FOR MEMORY MANAGEMENT.
C     IT CONSISTS OF TEN SUBROUTINES WITH A TOTAL LENGTH BELOW
C     10 K BYTES. NO MULTIPLE ENTRIES OR MULTIPLE RETURNS ARE
C     USED. ALL ENTRIES ARE FULLY COMPATIBLE WITH THE BOS SYSTEM.
C     THE SBOS SYSTEM CONTAINS ALL BASIC FUNCTIONS OF THE BOS
C     SYSTEM INCLUDING INPUT AND OUTPUT OF S-TYPE RECORDS.
C     SOME OF THE SUBPROGRAMS ARE IDENTICAL TO THE BOS SYSTEM.
C     THE ADDITIONAL SUBPROGRAMS MAY ALSO BE USED IN THE BOS
C     SYSTEM. ALL BOS SYSTEM SUBPROGRAMS MAY BE USED WITHIN THE
C     SBOS SYSTEM, HOWEVER, BECAUSE OF THE USE OF MULTIPLE ENTRIES
C     IN SOME BOS SUBPROGRAMS EVENTUALLY EXTERNAL STATEMENTS ARE
C     NECESSARY, IF THE MAIN ENTRY IS NOT USED OTHERWISE.
C
C     BASIC ELEMENTS FOR THE MEMORY MANAGEMENT IN THE SBOS AND
C     BOS SYSTEMS ARE SO CALLED BANKS. A BANK HAS TWO IDENTIFIERS
C     NA AND NR, CALLED NAME AND NUMBER, AND A DATA PART OF VARIABLE
C     LENGTH. NORMALLY THE IDENTIFIER NA CONSISTS OF FOUR
C     CHARACTERS, WHILE IDENTIFIER NR IS AN INTEGER.
C
C     ALL BANKS ARE STORED IN A SINGLE COMMON/BCS/IW(NSPACE).
C     AN INDEX IND IS ASSIGNED TO EACH BANK, WHERE IW(IND)=NW
C     CONTAINS THE NUMBER OF DATA WORDS IN THAT BANK. DATA
C     ARE STORED IN IW(IND+1) TO IW(IND+NW). IN ADDITION
C     THERE ARE THREE WORDS CONTAINING NAME, NUMBER AND A
C     POINTER ACCORDING TO THE FOLLOWING SCHEMA.
C
C              I      IW(I)
C          --------   -------------------------------------
C          IND -  3   NA (NAME)
C          IND -  2   NR (NUMBER)
C          IND -  1   POINTER TO NEXT BANK OF SAME NAME
C                     -------------------------------------
C          IND        NW = NUMBER OF DATA WORDS IN THE BANK
C                     -------------------------------------
C          IND +  1   DATA WORD 1
C          IND +  2   DATA WORD 2
C          ...        ...
C          IND + NW   DATA WORD NW
C          --------   -------------------------------------
C
C     NO LIMITATIONS EXIST FOR THE LENGTH OF A SINGLE BANK OR
C     THE NUMBER OF BANKS, EXCEPT FOR THE TOTAL LENGTH OF
C     ALL BANKS AND FOR THE NUMBER OF DIFFERENT NAMES.
C     FOR MORE DETAILS OF THE SYSTEM, CONSULT THE MANUAL OF
C     THE BOS SYSTEM.
C
C
C
C
C     THE SBOS SYSTEM CONSISTS OF THE FOLLOWING NINE SUBPROGRAMS
C
C      1.   SUBROUTINE   BENT   AND SUBROUTINE BDMPA
C      2.   FUNCTION     ILOC
C      3.   FUNCTION     IBLN
C      4.   SUBROUTINE   BMLT
C      5.   SUBROUTINE   BLST
C      6.   SUBROUTINE   BDLM
C      7.   SUBROUTINE   BGAR
C      8.   SUBROUTINE   BSIN
C      9.   SUBROUTINE   BOUT
C      +    ENTRIES      VZERO, UCOPY, UCOPY2
C
C
C
C
C     A.1   INITIALIZATION
C     ------------------
C
C     INITIALIZATION IS DONE BY THE FOLLOWING STATEMENTS.
C
C     COMMON/BCS/IW(NSPACE)
C     REAL RW(NSPACE)
C     EQUIVALENCE (IW(1),RW(1))
C        WHERE NSPACE = INTEGER CONSTANT
C
C     CALL BENT(NSPACE,NADD,NNA,NNL)
C
C
C        WHERE NADD  = NR OF WORDS FOR LOW PRIORITY BANKS
C                      (DEFAULT IS 10 PERCENT OF NSPACE)
C              NNA   = MAX. NR OF DIFFERENT NAMES      (DEFAULT 100)
C              NNL   = MAX. NR OF ENTRIES IN LISTS     (DEFAULT 100)
C
C
C
C     THE DEFAULT VALUES ARE USED, IF THE ARGUMENTS ARE ZERO.
C     IF SUBPROGRAMS OF THE SBOS AND OF THE BOS SYSTEM ARE USED,
C     EITHER BINT OR BENT HAS TO BE CALLED FOR INITIALIZATION.
C     IF ERROR CONDITIONS E.G. ILLEGAL VALUES OF POINTERS ARE
C     DETECTED, THE PROGRAM STOPS.
C         STOP 1   ILLEGAL POINTER DETECTED DURING GARBAGE COLLECTION
C         STOP 2   MORE THAN NNA NAMES USED
C         STOP 3   MORE THAN NNL NAMES USED IN LISTS
C         STOP 4   UNKNOWN CONDITION
C
C
C     BANKS WITH NAMES, WHERE THE FOURTH CHARACTER IS A '*',
C     E.G. 'HST*', ARE CONSIDERED AS BANKS OF LOW PRIORITY.
C     THEY CAN ONLY BE CREATED UP TO A TOTAL AMOUNT OF
C     NADD WORDS.
C
C
C
C     ABOUT 5*NNA + 3*NNL WORDS IN THE COMMON/BCS/ ARE USED FOR
C     INTERNAL TABLES ( 801 WORDS FOR DEFAULT VALUES). BANKS ARE
C     STORED INTO THE COMMON BEGINNING WITH WORD IW(NNA+1).
C
C     IN THE FOLLOWING ARGUMENTS OF SUBPROGRAMS, WHICH ARE CHANGED
C     BY THE CALLED PROGRAM, ARE INDICATED BY A LINE BELOW THE ARGUMENT.
C
C
C
C     A.2   FUNCTION ILOC
C     -----------------
C
C     THIS FUNCTION PERFORMS DIFFERENT OPERATIONS, DESCRIBED BELOW.
C
C
C     2.1    IND=ILOC(NA,NR,NW)    CREATION OF BANK (NA,NR) WITH
C                                  NW DATA WORDS. IF THE BANK IS
C                                  ALREADY EXISTING, THE LENGTH IS
C                                  CHANGED TO THE GIVEN VALUE,
C                                  ADDITIONAL VALUES ARE SET TO 0.
C                                  IND=0, IF INSUFFICIENT SPACE.
C
C     /SBOS/ IND=ILOC(NA,NR,NW)    /BOS/ CALL BCRE(IND,NA,NR,NW,&S1,IER)
C            IF(IND.EQ.0) GOTO S1
C
C
C     2.2    IND=ILOC(NA,NR,0)     LOCATING BANK (NA,NR). IND=0, IF
C                                  BANK NOT EXISTING.
C
C     /SBOS/ IND=ILOC(NA,NR,0)     /BOS/ CALL BLOC(IND,NA,NR,&S1)
C            IF(IND.EQ.0) GOTO S1
C
C
C     2.3    IND=ILOC(NA,NR,-1)    DELETE BANK (NA,NR). IND=0, IF BANK
C                                  NOT EXISTING, OTHERWISE IND = LAST
C                                  INDEX OF BANK, HOWEVER IW(IND) IS
C                                  CHANGED TO -(NW+4).
C
C     /SBOS/ IND=ILOC(NA,NR,-1)    /BOS/ CALL BDLS(NA,NR)
C
C
C     2.4    IND=ILOC(NA,NR,-2)    DELETE BANK (NA,NR) AND DO GARBAGE
C                                  COLLECTION, BUT NOT IN THE REGION
C                                  BEFORE THE DELETED BANK.
C
C
C     2.5    IND=ILOC(NA,NR,-3)    MOVE BANK (NA,NR) TO THE END. IND=0,
C                                  IF INSUFFICIENT SPACE.
C
C     /SBOS/ IND=ILOC(NA,NR,-3)    /BOS/ CALL BLOC(IND,NA,NR,&1)
C            IF(IND.EQ.0) GOTO S1        CALL BCHM(IND,0,IER)
C                                        IF(IER.NE.0) GOTO S1
C
C
C     2.6    IND=ILOC(NA,NR,-4)    CHANGE THE NAME AND NUMBER OF THE
C                                  BANK OF THE PREVIOUS CALL OF ILOC
C                                  TO NA AND NR, RESP. IND=0 IN CASE
C                                  OF AN ERROR (BANK NOT EXISTING OR
C                                  NEW NAME,NR ALREADY IN USE).
C
C     /SBOS/ IND=ILOC(NA1,NR1,0)   /BOS/ CALL BRNM(NA1,NR1,NA2,NR2)
C            IND=ILOC(NA2,NR2,-4)
C
C
C     2.7    IND=ILOC(0,0,0)       OBTAIN INDEX OF UNUSED SPACE BEHIND
C                                  BANKS. THE LENGTH OF THE UNUSED SPACE
C                                  IS STORED IN IW(IND)=NUS. (THERE IS
C                                  ENOUGH SPACE TO CREATE A BANK OF UP
C                                  TO NUS WORDS).
C
C
C
C
C     A.3   FUNCTION IBLN
C     -----------------
C
C     THE VALUE OF THE FUNCTION IBLN(NA) WITH NAME NA IS THE INDEX I
C     CORRESPONDING TO THIS NAME. IW(I) WILL CONTAIN THE INDEX OF THE
C     FIRST BANK OF THE GIVEN NAME.
C                                  /BOS/ IDENTICAL
C
C
C     3.1    IND=IW(IBLN(NA))      OBTAIN INDEX IND OF THE FIRST BANK
C                                  WITH THE NAME NA. IND=0, IF NO BANK
C                                  BANK OF THE NAME EXISTS.
C
C
C     3.2    IND=1+IBLN(NA)        INITIALIZATION OF A LOOP, SEE BELOW.
C
C     /SBOS/ IND=1+IBLN(NA)        /BOS/ CALL BPOS(NA)
C         S1 IND=IW(IND-1)            S1 CALL BNXT(IND,&S2)
C            IF(IND.EQ.0) GOTO S2        . . .
C            . . .                       . . .
C            GOTO S1                     GOTO S1
C         S2 . . .                    S2 . . .
C
C
C
C
C     A.4   SUBROUTINE BMLT
C     -------------------
C
C     4.1    CALL BMLT(NL,LIST)    DEFINE LIST(1) . . . LIST(NL) TO BE
C                                  THE CURRENT LIST.
C                                  /BOS/ IDENTICAL
C
C
C     4.2    CALL BMLT(-1,0)       ALL NAMES OF THE SPECIAL LIST ARE
C                                  DEFINED AS THE CURRENT LIST.
C
C     /SBOS/ CALL BMLT(-1,0)       /BOS/ CALL BSLT
C
C
C     4.3    CALL BMLT(-1,1)       ALL NAMES OF THE SPECIAL LIST WITH
C                                  MARKER=1 ARE DEFINED AS THE CURRENT
C                                  LIST.
C
C     /SBOS/ CALL BMLT(-1,1)       /BOS/ CALL BSLW
C
C
C
C
C     A.5   SUBROUTINE BLST
C     -------------------
C
C     5.1 CALL BLST(NL,LIST,0)     THE NAMES LIST(1) . . . LIST(NL) ARE
C                                  ADDED TO THE SPECIAL LIST WITH
C                                  MARKER=0.
C     /SBOS/ CALL BLST(NL,LIST,0)  /BOS/ CALL BSAT(NL,LIST)
C
C
C     5.2 CALL BLST(NL,LIST,1)     THE NAMES LIST(1) . . . LIST(NL) ARE
C                                  ADDED TO THE SPECIAL LIST WITH
C                                  MARKER=1.
C
C     /SBOS/ CALL BLST(NL,LIST,1)  /BOS/ CALL BSAW(NL,LIST)
C
C
C     5.3    CALL BLST(NL,LIST,-1) THE NAMES LIST(1) . . . LIST(NL) ARE
C                                  DELETED FROM THE SPECIAL LIST.
C
C     /SBOS/ CALL BLST(NL,LIST,-1) /BOS/ CALL BSAD(NL,LIST)
C
C
C     5.4    CALL BLST(0,0,-1)     THE SPECIAL LIST IS CLEARED.
C
C     /SBOS/ CALL BLST(0,0,-1)     /BOS/ CALL BSAC
C
C
C     5.5    CALL BLST(NL,LIST,ND) THE NAMES OF THE CURRENT LIST ARE
C                      --          STORED IN THE USER ARRAY LIST( ),
C                                  WHERE ND IS THE DIMENSION OF LIST( ).
C                                  ND GREATER THAN 1. UP TO ND NAMES
C                                  ARE STORED.
C
C     /SBOS/ CALL BLST(NL,LIST,ND) /BOS/ CALL BMRT(NL,LIST,ND)
C
C
C
C
C     A.6  SUBROUTINE BDLM
C     ------------------
C
C     6.1 CALL BDLM                ALL BANKS OF THE CURRENT LIST ARE
C                                  DELETED.
C                                  /BOS/ IDENTICAL
C
C
C
C
C     A.7  SUBROUTINE BGAR
C     ------------------
C
C     7.1 CALL BGAR(IGA)           THE ACTIVE (NOT DELETED) BANKS ARE
C                   ---            SHIFTED TO THE BEGIN OF THE BANK
C                                  SPACE. IGA=0, IF NO BANKS WERE
C                                  DELETED.
C                                  /BOS/ IDENTICAL
C
C
C
C     A.8  SUBROUTINE BSIN
C     ------------------
C
C     THIS SUBROUTINE IS TO BE USED, IF BANK RECORDS OF TYPE S ARE
C     TO BE READ. THE ACTUAL READ STATEMENT TO READ A RECORD HAS TO
C     BE GIVEN IN THE USER PROGRAM, THE RECORD HAS TO BE STORED
C     AT THE BEGIN OF THE FREE SPACE OF THE COMMON/BCS/. THEN SUBROU-
C     TINE BSIN HAS TO BE CALLED, TO ACCEPT THE BANKS OF THE RECORD,
C     I.E. TO DEFINE THE POINTERS.
C
C     8.1 CALL BSIN(NRW,ICD)       THE BANKS OF THE RECORD WITH NRW
C                       ---        WORDS, READ INTO THE UNUSED BANKSPACE
C                                  IS ACCEPTED. ICD IS AN ERROR CODE.
C                                  ICD=1  RECORD LENGTH LESS THAN 4
C                                  ICD=2  BANK LENGTH NEGATIVE
C                                  ICD=3  BANK LENGTH TOO LARGE
C                                  ICD=4  WRONG ORDER IN BANK NRS
C                                  ICD=5  WRONG RECORD END
C
C     EXAMPLE
C
C     IND=ILOC(0,0,0)              SUBROUTINE FREAD(IUN,NTOT,BIN,*,*)
C     CALL FREAD(IUN,NRW,          REAL BIN(NTOT)
C                IW(IND),&S1,&S2)  READ(IUN,ERR=1,END=2) NTOT,BIN
C     CALL BSIN(NRW,ICD)           RETURN
C     IF(ICD.NE.0) GOTO S1       1 RETURN 1
C                                2 RETURN 2
C                                  END
C
C
C
C
C     A.9   SUBROUTINE BOUT
C     -------------------
C
C     THIS SUBROUTINE IS TO BE USED, IF BANK RECORDS OF TYPE S ARE
C     TO BE WRITTEN. THE SUBROUTINE BGAR IS CALLED INTERNALLY.
C
C
C     9.1   CALL BOUT(NRW,INIW)    ALL BANKS BELONGING TO THE CURRENT
C                     --- ----     LIST ARE ARRANGED IN CONTIGUOUS
C                                  BANK SPACE. THE ACTUAL WRITESTATEMENT
C                                  SHOULD WRITE A RECORD, CONSISTING OF
C                                  THE WORD NRW (LENGTH), FOLLOWED BY
C                                  THE NRW WORDS IW(INIW), IW(INIW+1)
C                                  . . . IW(INIW+NRW-1).
C                                  NRW=0 IF NO BANKS.
C
C     EXAMPLE
C
C     DEFINE CURRENT LIST          SUBROUTINE FWRITE(IUN,NTOT,BIN)
C     CALL BOUT(NRW,INIW)          REAL BIN(NTOT)
C     IF(NRW.EQ.0) GOTO S1         WRITE(IUN) NTOT,BIN
C     CALL FWRITE(IUN,NRW,         RETURN
C                IW(INIW))         END
C
C
C
C
C     ------------------------------------------------------------------
C
C
C     APPENDIX B.    APPLICATION PROGRAMS
C
C
C
C     THE SUBROUTINE DESCRIBED HERE USE BANK STORAGE OF LOW
C     PRIORITY. THEY CAN BE USED FOR COUNTING, HISTOGRAMMING,
C     STORING OF VECTORS ETC. AND MAY BE USEFUL IN THE TESTING
C     PHASE OF LARGE PROGRAMS.
C     THE TOTAL NUMBER OF WORDS USED IN THE BANK COMMON /BCS/ CAN
C     NEVER EXCEED NADD WORDS (NADD IS AN ARGUMENT OF BINT).
C     THE SUBROUTINES START WITH A LETTER U FOR A NEW ENTRY, AND
C     WITH A LETTER P FOR PRINTOUT.
C
C     THE ARGUMENT N IN THE CALLS SHOULD ALWAYS BE A POSITIVE
C     INTEGER WITH LESS THAN 9 DIGITS.
C
C
C     B.1  PRINTOUT AND COMMENTS
C
C     FOR ALL APPLICATION PROGRAMS DESCRIBED IN APPENDIX A.2 TO A.6
C     PRINTOUT CAN BE DONE USING ONE CALL
C
C     CALL PALL
C
C
C
C     FOR SEVERAL APPLICATION PROGRAMS DESCRIBED IN THIS APPENDIX
C     COMMENT CAN BE DEFINED BY THE FOLLOWING CALLS. THIS COMMENT
C     IS PRINTED TOGETHER WITH THE RESULT
C
C                                         -NOT YET AVAILABLE-
C     CALL TCOND(N,'COMMENT    $')
C        COMMENT FOR UCOND
C
C     CALL TTABL(N,'COMMENT    $')
C        COMMENT FOR UTABL
C
C     CALL THIST(N,'COMMENT    $')
C        COMMENT FOR UHIST
C
C     CALL TCORR(N,'COMMENT    $')
C        COMMENT FOR UCORR
C
C     CALL TSTOR(N,'COMMENT    $')
C        COMMENT FOR USTOR/USTOS
C
C     CALL TMEAN(N,'COMMENT    $')
C        COMMENT FOR UMEAN
C
C     CALL TPEAK(N,'COMMENT    $')
C        COMMENT FOR UPEAK
C
C     CALL TLIND(N,'COMMENT    $')
C        COMMENT FOR ULIND
C
C     CALL TEMPF(N,'COMMENT    $')
C        COMMENT FOR UEMPF
C
C     THE COMMENT-TEXT IS DELIMITED BY A $ SIGN, MAXIMUM NUMBER
C     OF CHARACTERS IS 60.
C
C
C     A BANK WITH NAME 'TEX*' IS USED FOR EACH COMMENT.
C
C
C     B.2  COUNT IN A 32768 * 32768 ARRAY
C
C                - -
C     CALL UCOND(I,J)
C        INCREASE COUNT IN ELEMENT I,J BY ONE.
C        0 .LE. I .LE. 32767  AND 0 .LE. J .LE. 32767
C
C     CALL PCOND
C        PRINT ALL ELEMENTS .NE. 0. ALL BANKS USED ARE DELETED.
C
C                - -
C     CALL QCOND(I,J,NR)
C                    --
C        WHERE I,J = INDICES OF ELEMENT
C               NR = NUMBER OF COUNTS IN ELEMENT
C
C     BANKS (CON*,IJ) OF LENGTH 8(+4) ARE USED, WHERE IJ IS CALCULATED
C     FROM I AND J.
C
C
C     B.3  COUNT IN A 256 * 16 ARRAY
C
C                - - -
C     CALL UTABL(N,I,J)
C        INCREASE COUNT IN ELEMENT I,J BY ONE.
C        0 .LE. I .LE. 255  AND  0 .LE. J .LE. 15.
C        MAXIMUM COUNT IN ONE ELEMENT IS 65535.
C
C                -
C     CALL PTABL(N)
C        THE I/J ARRAY NUMBER N IS PRINTED. FOR N=0 ALL ARRAYS
C        ARE PRINTED.
C
C                - -
C     CALL QTABL(N,I,AR)
C                    --
C        WHERE AR( ) = ARRAY OF LENGTH 16 CONTAINING THE COUNTS
C                      IN THE I-ROW OF ARRAY NUMBER N.
C
C     A BANK (TAB*,N*16+I/16) OF LENGTH 128(+4) IS USED FOR EACH
C     FILLED 16 * 16 SUBARRAY.
C
C
C     B.4  HISTOGRAM
C
C                - -
C     CALL UHIST(N,X)
C        ADD NEW ENTRY X INTO HISTOGRAM N WITH 100 BINS. THE BIN SIZE
C        IS CHOOSEN AUTOMATICALLY, UNLESS DHIST IS USED.
C
C                - -- --
C     CALL DHIST(N,XL,XH)
C        FOR HISTOGRAM N THE VALUES XL AND XH ARE DEFINED AS LOWER
C        AND UPPER LIMITS, RESP.. (MUST BE CALLED BEFORE UHIST).
C
C                -
C     CALL PHIST(N)
C        THE HISTOGRAM N IS PRINTED, TOGETHER WITH MEAN VALUES ETC.
C        FOR N=0 ALL HISTOGRAMS ARE PRINTED.
C
C                -
C     CALL QHIST(N,Q)
C                  -
C
C        WHERE Q( ) = ARRAY OF LENGTH 115 FOR CONTENT OF
C        HISTOGRAM N (SEE BELOW).
C
C        I               Q(I)
C
C        1 . . . 100     CONTENT OF HISTOGRAM BINS
C        101             NR OF ENTRIES (TOTAL)
C        102             LOWEST BIN LEFT EDGE
C        103             BIN SIZE
C        104             NR OF ENTRIES OUTSIDE LOW
C        105             NR OF ENTRIES OUTSIDE HIGH
C        106             MIMIMUM VALUE OF X
C        107             MAXIMUM VALUE OF X
C        108             MEAN VALUE
C        109             MEDIAN (50 PC VALUE)
C        110             STANDARD DEVIATION
C        111                   . . .        FROM QUANTILES
C        112             QUANTILES   16 PC
C        113                . . .    84 PC
C        114                . . .   2.3 PC
C        115                . . .  97.7 PC
C
C     A BANK (HST*,N) OF LENGTH 120(+4) IS USED FOR EACH HISTOGRAM.
C
C
C     B.5  CORRELATION PLOT
C
C                - - -
C     CALL UCORR(N,Y,X)
C        ADD NEW ENTRY Y,X TO CORRELATION PLOT N WITH
C        50 * 100 BINS. BIN SIZE IS ALWAYS CHOOSEN AUTOMATICALLY.
C
C                -
C     CALL PCORR(N)
C        THE CORRELATION PLOT N IS PRINTED ON ONE PAGE TOGETHER
C        WITH PROJECTIONS AND MEAN VALUES.
C        BINS WITH CONTENT .NE. 0 ARE PRINTED AS A X. FOR N=0
C        ALL CORRELATION PLOTS ARE PRINTED.
C
C     A BANK (COR*,N) OF LENGTH 380(+4) IS USED FOR EACH
C     CORRELATION PLOT.
C
C
C
C     B.6  STORE VECTORS
C
C                - -- ----
C     CALL USTOR(N,AR,NDIM)
C        STORE VECTOR AR(1) . . . AR(NDIM) IN STORAGE N. THE
C        ARGUMENT NDIM SHOULD ALWAYS BE THE SAME FOR A GIVEN
C        STORAGE N.
C
C     NOTE. USTOR IS AN ENTRY OF USTOS. IF USTOS IS NOT CALLED,
C     USE A STATEMENT
C        EXTERNAL USTOS
C
C
C
C
C                - -- -- -- --
C     CALL USTOS(N,A1,A2,A3,A4)
C        STORE VECTOR A1, . . . IN STORAGE N. THE NUMBER OF ELEMENTS
C        IN A VECTOR MAY BE BETWEEN 1 AND 4 (VARIABLE NR OF ARGUMENTS
C        ALLOWED), BUT SHOULD ALWAYS BE THE SAME FOR A GIVEN
C        STORAGE N.
C
C     THE NUMBER OF VECTORS STORED IN A STORAGE IS LIMITED TO 100.
C     THIS LIMIT CAN BE CHANGED BY DSTOR.
C
C                ---
C     CALL DSTOR(LIM)
C        THE LIMIT ON THE NR OF VECTORS IS SET TO LIM.
C
C                -
C     CALL PSTOR(N)
C        THE VECTORS STORED IN STORAGE N ARE PRINTED. FOR N=0
C        THE VECTORS OF ALL STORAGES ARE PRINTED.
C
C     A BANK (STO*,N) IS USED FOR EACH STORAGE. THE STORAGE IS USED
C     AS FOLLOWS.
C
C     INDEX OF THE BANK       CONTENT
C            +1               NUMBER OF STORED VECTORS
C            +2               LENGTH OF ONE VECTOR
C            +3               (USED INTERNAL)
C            +4               1. ELEMENT OF 1. VECTOR
C            +5               2. ELEMENT OF 1. VECTOR
C            +6                    ETC
C
C
C     B.7  DETERMINE MEAN VALUES
C
C     THE MEAN VALUE IS DETERMINED FOR ENTRIES X. ENTRIES
C     HAVING A LARGE DEVIATION FROM THE AVERAGE X VALUE ARE
C     NOT USED. INTERNALLY A SMALL HISTOGRRAM IS MADE.
C     THREE DIFFERENT MEASURES FOR THE CENTER OF THE DISTRI-
C     BUTION ARE CALCULATED, THE USUAL MEAN FOR THE ENTRIES
C     INSIDE THE HISTOGRAM, THE TRIMMED MEAN, WHICH DETERMINES
C     THE MEAN FROM THE INNER 54 PERCENT OF THE HISTOGRAM,
C     AND THE MEDIAN (50 PERCENT VALUE OF HISTOGRAM). USUALLY
C     THE TRIMMED MEAN IS THE BEST MEASURE.
C
C                -- -- -
C     CALL UMEAN(N,KA,X)
C
C        ADD NEW ENTRY X TO MEAN VALUES N,KA.
C        THE KA-VALUE MAY BE BETWEEN 0 AND KAMAX,
C        IF SPACE IS RESERVED BY DMEAN(NA,KAMAX)
C
C                -- -----
C     CALL DMEAN(N,KAMAX)
C
C        FOR MEAN VALUES N,0 TO N,KAMAX SPACE IS RESERVED.
C        IF NOT CALLED, KAMAX=0 IS ASSUMED.
C
C
C                --
C     CALL PMEAN(N)
C        MEAN VALUES N,... ARE PRINTED. FOR N=0 ALL
C        MEAN VALUES ARE PRINTED.
C
C                -- --
C     CALL QMEAN(N,KA,Q)
C                      -
C        WHERE Q( ) = ARRAY OF LENGTH 10 FOR MEAN VALUE
C                     INFORMATION
C
C         I       Q(I)
C         1       NR OF ENTRIES TOTAL
C         2       MEAN
C         3       TRIMMED MEAN
C         4       MEDIAN
C         5       SIGMA (AVERAGE)
C         6       SIGMA (LEFT)
C         7       SIGMA (RIGHT)
C         8       NR OF ENTRIES OUTSIDE X-RANGE
C         9       LOWER LIMIT OF X-RANGE
C        10       UPPER LIMIT OF X-RANGE
C
C     A BANK (MEA*,N) IS USED WITH LENGTH 50*(KAMAX+1).
C
C
C
C     B.8  DETERMINE PEAK VALUES        -NOT YET AVAILABLE-
C
C     THE PEAK VALUE IS SEARCHED FOR IN THE DISTRIBUTION OF
C     ENTRIES X. INTERNALLY A HISTOGRRAM IS MADE, WHICH IS
C     ANALYSED USING STATISTICAL METHODS TO FIND THE LARGEST
C     PEAK CONSISTENT WITH A RAW DESCRIPTION.
C
C                -- -- -
C     CALL UPEAK(N,KA,X)
C
C        ADD NEW ENTRY X TO PEAK SEARCH N,KA.
C        THE KA-VALUE MAY BE BETWEEN 0 AND KAMAX,
C        AS GIVEN IN DPEAK.
C
C                - ----- -- -- ----
C     CALL DPEAK(N,KAMAX,XA,XZ,FWHM)
C
C        FOR PEAK SEARCHES N,0 TO N,KAMAX SPACE IS RESERVED.
C        IF NOT CALLED, FOLLOWING CALLS TO UPEAK ARE IGNORED.
C        THE ARGUMENTS GIVE A RAW DESCIPTION OF THE PEAK.
C        XA,XZ  = LOWER AND UPPER POSSIBLE VALUES OF PEAK POSITION
C        FWHM   = EXPECTED FULL WIDTH AT HALF MAXIMUM OF THE PEAK
C
C                -
C     CALL PPEAK(N)
C        RESULTS ON PEAK SEARCHES N,... ARE PRINTED, TOGETHER WITH
C        HISTOGRAMS. FOR N=0 ALL RESULTS ARE PRINTED, BUT WITHOUT
C        HISTOGRAMS.
C
C
C                - --
C     CALL QPEAK(N,KA,Q)
C                     -
C        WHERE Q( ) = ARRAY OF LENGTH 6 FOR PEAK SEARCH RESULTS
C
C         I       Q(I)
C         1       NR OF ENTRIES TOTAL
C         2       PEAK POSITION
C         3       SIGMA
C         4       FWHM
C         5       FRACTION OF ENTRIES WITHIN +- 1 STANDARD DEVIATIONS
C         6       FRACTION OF ENTRIES WITHIN +- 3 STANDARD DEVIATIONS
C
C     A BANK (PEA*,N) IS USED WITH LENGTH UP TO 10+100*(KAMAX+1).
C
C
C
C     B.9  STORE SINGLE VALUES
C
C                - -- -
C     CALL USSTO(N,KA,X)
C        STORE VALUE X IN STORAGE N,KA. KA VALUES ARE ALLOWED
C        BETWEEN 0 AND KAMAX, IF SPACE IS RESERVED BY
C        DSSTO(N,KAMAX).
C
C
C                - ----- ---
C     CALL DSSTO(N,KAMAX,IEN)
C        FOR STORAGE N,0 TO N,KAMAX SPACE IS RESERVED FOR UP TO
C        IEN ENTRIES EACH. IF NOT CALLED, KAMAX=0 AND IEN=100.
C
C                - --
C     CALL QSSTO(N,KA,Q,NQ,NENT)
C                     - -- ----
C
C        WHERE Q( ) = ARRAY OF LENGTH IEN, CONTAINING NQ SINGLE
C                     X-VALUES FROM A TOTAL OF NENT X-VALUES
C
C     A BANK (SST*,N) IS USED WITH LENGTH 1+(IEN+1)*KAMAX.
C
C
C
C
C     B.10  BIN DEFINITION
C
C     THE BIN NUMBER LB OF A VALUE X IN A BIN DEFINITION
C     DEFINED BY A BANK ('$BIN',NC) IS OBTAINED BY
C              -- -
C     LB = LBN(NX,X)
C
C     THE BANK ('$BIN',NX) MAY BE DEFINED BY DATA CARDS, READ BY
C     BREADC, AND MUST BE OF ONE OF THE FOLLOWING FORMS.
C
C     $BIN NX  XL XH                        ( NB=100 ASSUMED)
C     $BIN NX  XL XH NB                     ( NB LESS EQUAL 1000)
C     $BIN NX  X1 X2 X3 X4 . . . XL         ( NB = L-1, L AT LEAST 4)
C
C     XL AND XH ARE THE LOWER AND UPPER LIMITS OF ALL NB BINS.
C     X1, X2, X3 . . . ARE THE LOWER LEFT EDGES OF THE BINS,
C     SORTED IN ASCENDING ORDER.
C
C     FUNCTION LBN(N,X) RETURNS WITH 0, IF NO CORRESPONDING
C     BANK IS STORED. IT RETURNS 0 OR NB+1 FOR X VALUES OUTSIDE
C     THE BIN DEFINITION.
C
C     THE LIMITS XL AND XH OF A GIVEN BIN NR LB FOR BIN DEFINITION NX
C     IS OBTAINED BY
C               -- --
C     CALL VLBN(NX,LB,XL,XH,NB)
C                     -- -- --
C     NB IS THE TOTAL NR OF BINS.
C
C
C     B.11  INTERPOLATION OF TABULATED DATA
C
C     USING THE SPLINE INTERPOLATION PROGRAM CUBSPL THE FUNCTION
C     BFUN GIVES THE INTERPOLATED FUNCTION VALUE (BDER THE FIRST
C     DERIVATIVE) AT A GIVEN X VALUE FOR TABULATED DATA, WHICH ARE
C     STORED IN A BANK ('$FUN',N) AND E.G. READ IN FROM CARDS
C     BY BREADC.
C
C     $FUN N  Y1 X1  Y2 X2  Y3 X3  Y4 X4 . . .
C
C     (X VALUES IN ASCENDING ORDER, AT LEAST 3 Y,X PAIRS)
C
C                 - -
C     YI   = BFUN(N,X)        INTERPOLATED FUNCTION VALUE
C
C                 - -
C     YDER = BDER(N,X)        FIRST DERIVATIVE
C
C
C     AT THE FIRST ENTRY A BANK ('+FUN',N) IS CREATED, WHICH CONTAINS
C     THE SPLINE COEFFICIENTS. ITSLENGTH IS 5*NR OF Y,X PAIRS.
C
C     A PLOT OF THE FUNCTION N IS OBTAINED BY
C
C     CALL PFUN(N)
C
C
C     B.11  DETERMINATION OF A LINEAR DEPENDENCE Y(X)-NOT YET AVAILABLE-
C
C     A LINEAR DEPENDENCE OF Y ON X CAN BE DETERMINED BY THE FOLLOWING
C     CALL FROM PAIRS OF Y,X VALUES. INTERNALLY USSTO IS USED.
C
C                -- ----- --- -- -- -- --
C     CALL DLIND(NA,KAMAX,IEN,YL,YH,XL,XH)
C
C     FOR LINEAR DEPENDENCES N,0 TO N,KAMAX SPACE IS RESERVED FOR UP
C     TO IEN PAIRS. YL,YH AND XL,XH ARE THE LIMITS FOR THE Y AND
C     X VALUES.
C
C
C
C                - -- - -
C     CALL ULIND(N,KA,Y,X)
C
C     ADD NEW Y,X PAIR TO LINEAR DEPENDENCE N,KA, IF Y AND X ARE
C     WITHIN THE LIMITS DEFINED BY DLIND.
C
C                -
C     CALL PLIND(N)
C
C     THE RESULT INCLUDING INTERCEPT AND SLOPE OF THE LINEAR
C     DEPENDENCES NA,0 TO NA,KAMAX ARE PRINTED.
C
C                - --
C     CALL QLIND(N,KA,Q)
C                     -
C
C        WHERE Q( ) = ARRAY OF LENGTH 10 FOR INFORMATION ON
C                     LINEAR DEPENDENCE N,KA
C
C      I      Q(I)
C      1      NR OF ENTRIES STORED
C      2      INTERCEPT
C      3      SLOPE
C      4      ERROR OF SLOPE
C      5      MEAN X
C      6      MEAN Y
C      7      ERROR OF MEAN Y
C      8      MEAN SIGMA OF SINGLE POINT
C      9      NR OF DELETED POINTS
C     10      NR OF TOTAL ENTRIES
C
C     THE METHOD USED FOR THE DETERMINATION OF THE LINEAR
C     DEPENDENCE ALLOWS A BACKGROUND CONTRIBUTION OF ABOUT
C     20 PERCENT OF RANDOMLY DISTRIBUTED Y,X PAIRS. THE FRACTION
C     OF DELETED POINTS BEFORE THE ACTUAL LINEAR FIT IS GIVEN
C     IN Q(9).
C
C     A BANK (LIN*,N) IS USED OF LENGTH 6 WORDS PLUS THE
C     CORRESPONDING BANK (SST*,N)
C
C
C
C     B.13  DETERMINATION OF AN EMPIRICAL FUNCTION
C
C
C     A FUNCTIONAL DEPENDENCE OF Y ON X CAN BE DETREMINED BY THE
C     FOLLOWING CALLS FROM PAIRS OF Y,X VALUES. INTERNALLY UMEAN
C     IS USED, THE RESULT IS STORED A BANK $FUN,N.
C
C                - --
C     CALL DEMPF(N,NX)
C
C     FOR EMPIRICAL FUNCTION N, THE BIN DEFINITION NX IS TO BE
C     USED FOR THE X-VALUES. THE MEAN OF THE Y-VALUES WITHIN
C     EACH X-BIN WILL BE DETERMINED.
C
C
C                - - -
C     CALL UEMPF(N,Y,X)
C
C     ADD NEW Y VALUE INTO THE BIN DEFINED BY THE X VALUE AND THE
C     BIN DEFINITION NX.
C
C     CALL PEMPF(N)
C
C     THE RESULT IS PRINTED, A BANK $FUN,N IS CREATED WITH MEAN
C     Y VALUES AND THE CENTRAL X VALUE FOR EACH BIN.
C
C     THE METHOD ALLOWS A CERTAIN BACKGROUND IN THE DATA.
C
C     A BANK (EMP*,N) IS USED OF LENGTH 2+LENGTH OF $BIN BANK
C     PLUS THE CORRESPONDING BANK (MEA*,N).
C
C
C
C
C
C
C
