C   21/11/78 C9071601   MEMBER NAME  ZBOS01   (S)           FORTRAN
      SUBROUTINE BSCOM
C     -----------------------------------------------------------------100000200
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
      RETURN
      END
