C   14/10/82            MEMBER NAME  BSCOM10  (S)           FORTRAN77
      SUBROUTINE BSCOM
C     -----------------------------------------------------------------900000200
C     9.  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     THE RECORD CONSISTS OF NTOT + 1 WORDS, WHERE
C     FIRST WORD IN RECORD   = NTOT
C     NEXT WORD              = NAME
C     NEXT WORD              = NUMBER OF FIRST BANK
C     NEXT WORD              = POINTER
C     NEXT WORD              = NR.OF WORDS OF THE FIRST BANK
C     ETC.
C
C
C
C     10.1 STANDARD OUTPUT AND INPUT
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     OUTPUT OF ONE EVENT
C        CALL BSLT               OR  CALL BMLT(N,LIST OF NAMES)
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     INPUT OF ONE EVENT
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     10.2 OUTPUT MODES AND RECORD TYPES
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    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 ALLWAYS 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).
C
C        CALL BWR0(IUNIT,NRECL,MODE)
C
C     IF NOT CALLED, MODE = 0 IS ASSUMED WIRH NRECL TAKEN FROM THE
C     BOS INITIALIZATION PROGRAM BINT (SEE CH. 1).
C
C
C     MODES OF OUTPUT
C
C     MODE = 0     S-RECORDS ARE WRITTEN. THE EVENT IS NOT WRITTEN, IF
C                  THE LENGHT OF THE EVENT EXCEEDS NRECL WORDS.
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     MODE = 2     M-RECORDS ARE WRITTEN.
C
C     THE RECORD LENGTH WILL NEVER EXCEED NRECL WORDS. IT IS POSIBLE
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     10.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 FORTRAN DIRECT ACCESS STATEMENTS. FOR OUTPUT
C     THE STATEMENT CALL BWRITE(IUN) HAS TO BE REPLACED BY THE
C     FOLLOWING 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     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.
C
C     10.4   BUFFER BANKS
C
C     FOR EACH INPUT/OUTPUT UNIT IUN A BANK ('$BUF',IUN) IS USED
C     WITH BWTWEEN 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
C
C     10.5    STANDARD EVENT READING/WRITING
C
C     FOR THE STANDARD REPEATED CHAIN
C
C             INPUT OF ONE EVENT
C             PROCESS EVENT
C             OUTPUT OF EVENT
C             DELETEIN BANKS AND GARBAGE COLLECTION
C
C     THERE IS THE PROGRAM BSEQ.


C
