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