Using FATMEN to make copies of datasets

FATMEN can make copies of a dataset with automatic update of the catalogue. This is available both through the shell and the FORTRAN interface. The shell version provides an interface to the file transfer routines of CSPACK (the same as those used by ZFTP) and hence permits the network transfer of files. The files are transferred from disk to disk. If the local file resides on tape, it is first staged to disk. For reasons of program size this facility is not yet enabled on VM or MVS machines, but just for VMS and Unix systems. An interface to remote tapes is not yet provided.

Both the shell COPY command and the FORTRAN routine FMCOPY permit conversion of data representation and record format during copy. That is, one may copy an input Zebra FZ binary exchange file to an output Zebra FZ native file, or an input file with VBS format to an output file with record format U. The following example shows the use of FMCOPY. This example was written for DELPHI, but similar programs are in use by CPLEAR, L3 and OPAL.

                 Example of copy data with  FMCOPY
                                  

***********************************************************************
* PROGRAM DELRCOPY                                                    *
* ================                                                    *
* Make copies of all files corresponding to generic names on unit 10  *
* into the robot (SMCF) allocating volumes from pool XX_RAWD          *
***********************************************************************
      PARAMETER (LURCOR=100000)
      COMMON/CRZT/IXSTOR,IXDIV,IFENCE(2),LEV,LEVIN,BLVECT(LURCOR)
      DIMENSION    LQ(999),IQ(999),Q(999)
      EQUIVALENCE (IQ(1),Q(1),LQ(9)),(LQ(1),LEV)
      COMMON /USRLNK/LUSRK1,LUSRBK,LUSRLS
      COMMON /QUEST/IQUEST(100)
*
* Start of FATMEN sequence FATPARA
*
** ***     Data set bank mnemonics
*
*          Keys
      PARAMETER ( MKSRFA= 1, MKFNFA= 2, MKCLFA=7, MKMTFA=8
     1           ,MKLCFA= 9, MKNBFA=10, NKDSFA=10 )
*
** ***     Bank offsets
*
      PARAMETER ( MFQNFA=  1, MHSNFA= 65, MCPLFA= 67, MMTPFA= 68
     1           ,MLOCFA= 69, MHSTFA= 70, MHOSFA= 74
     2           ,MVSNFA= 77, MVIDFA= 79, MVIPFA= 81, MDENFA= 82
     3           ,MVSQFA= 83, MFSQFA= 84, MSRDFA= 85, MERDFA= 86
     4           ,MSBLFA= 87, MEBLFA= 88, MRFMFA= 89, MRLNFA= 90
     5           ,MBLNFA= 91, MFLFFA= 92, MFUTFA= 93, MCRTFA= 94
     6           ,MCTTFA= 95, MLATFA= 96, MCURFA= 97, MCIDFA= 99
     7           ,MCNIFA=101, MCJIFA=103, MFPRFA=105, MSYWFA=106
     8           ,MUSWFA=116, MUCMFA=126, NWDSFA=145
     9           ,MFSZFA=MSYWFA,MUSCFA=MSYWFA+1)
* End of FATMEN sequence FATPARA
      CHARACTER*6  DENS
      CHARACTER*8  LIB
      CHARACTER*4  LABTYP
      CHARACTER*1  MNTTYP
      CHARACTER*8  MODEL
      CHARACTER*7  ROBMAN(2)
      DATA         ROBMAN(1)/'-Robot '/,ROBMAN(2)/'-Manual'/
      PARAMETER (LKEYFA=10)
      PARAMETER (MAXFIL=1000)
      DIMENSION KEYS(LKEYFA,MAXFIL)
      DIMENSION JSORT(MAXFIL)
      DIMENSION KEYSIN(LKEYFA),KEYSOU(LKEYFA,MAXFIL)
      CHARACTER*255 FILES(MAXFIL)
      CHARACTER     THRONG*8, DSN*8, VSN*6, VID*6
      CHARACTER*80  TOPDIR,GENAME
      CHARACTER*26  CHOPT
*
*     Initialise ZEBRA
*
      CALL MZEBRA(-3)
      CALL MZSTOR(IXSTOR,'/CRZT/','Q',IFENCE,LEV,BLVECT(1),BLVECT(1),
     +            BLVECT(5000),BLVECT(LURCOR))
      CALL MZLOGL(IXSTOR,-3)
*
* *** Define user division and link area like:
*
      CALL MZDIV  (IXSTOR, IXDIV, 'USERS', 50000, LURCOR, 'L')
      CALL MZLINK (IXSTOR, '/USRLNK/', LUSRK1, LUSRLS, LUSRK1)
*
*     Units for FATMEN RZ/FZ files
*
      LUNRZ = 1
      LUNFZ = 2
*
*     Initialise FATMEN
*
      CALL FMINIT(IXSTOR,LUNRZ,LUNFZ,'//CERN/DELPHI',IRC)
      CALL FMLOGL(1)
      IDEBFA = 2
      NPROC  = 0
10    CONTINUE
      CALL TIMEL(T)
      IF(T.LT.100) THEN
         PRINT *,'Stopping due to time limit'
         GOTO 99
      ENDIF
      READ(10,9001,END=99) GENAME
9001  FORMAT(A80)
*     GENAME = FILES(JSORT(I))
      LGN = LENOCC(GENAME)
      PRINT *,'Processing ',GENAME(1:LGN)
      IROBOT = 0
*
*     First, check that a robot copy does not already exist
*
      CALL VBLANK(KEYSIN(2),5)
      LFN = INDEXB(GENAME(1:LGN),'/') + 1
*
*     Don't compare copy level or location code
*
      KEYSIN(MKCLFA) = -1
      KEYSIN(MKLCFA) = -1
*
*     Restrict search to 3480s
*
      KEYSIN(MKMTFA) = 2
      CALL FMSELK(GENAME(1:LGN),KEYSIN,KEYSOU,NMATCH,MAXFIL,IRC)
      IF(IRC.NE.0) THEN
         PRINT *,'Return code ',IRC,' from FMSELK'
         PRINT *,'Skipping ',GENAME(1:LGN)
         GOTO 10
      ENDIF
      IF(IDEBFA.GE.2)
     +PRINT *,'Found ',nmatch,' matches for media type 2'
      DO 30 J=1,NMATCH
      CALL FMQVOL(GENAME(1:LGN),LBANKR,KEYSOU(1,J),
     +            LIB,MODEL,DENS,MNTTYP,LABTYP,IC)
      IF(INDEX(LIB,'*Unknown') .NE.0) THEN
         IF(IDEBFA.GE.0) PRINT *,'Cannot determine mount type'
      ENDIF
      IF(MNTTYP.EQ.'R') THEN
         IF(IDEBFA.GE.0) PRINT *,'Robot copy already exists'
         IROBOT = 1
      ENDIF
30    CONTINUE
      IF(IROBOT.EQ.0) THEN
         PRINT *,'Robot copy does not exist for ',GENAME(1:LGN)
*
*     Now make a robot copy
*     First, allocate a new tape
*
         CALL FMALLO('3480','38K',' ','SMCF_1','XX_RAWD',
     +               LBANKR,' ',VSN,VID,IRC)
         IF(IRC.NE.0) THEN
            PRINT *,'Cannot allocate new tape - STOP!'
            GOTO 99
         ENDIF
*
*     Display the bank
*
         CALL FMSHOW(GENAME(1:LGN),LBANKR,KEYSOU(1,J),'A',IRC)
         LZERO = 0
         CALL VZERO(KEYSIN,10)
*
*     and make the copy
*
         CALL FMLOGL(3)
         CALL FMCOPY(GENAME(1:LGN),LZERO,KEYSIN,
     +               GENAME(1:LGN),LBANKR,KEYSOU(1,J),' ',IRC)
         IF(IRC.NE.0) THEN
            PRINT *,'Error from FMCOPY - STOP!'
            GOTO 99
         ENDIF
         CALL MZDROP(IXSTOR,LBANKR,' ')
         CALL MZDROP(IXSTOR,LZERO,' ')
         NPROC = NPROC + 1
      ENDIF
      GOTO 10
99    CONTINUE
      PRINT *,'Made ',NPROC,' copies, ',T,' seconds left'
*
*     Terminate cleanly
*
      CALL FMEND(IRC)
      END