next up previous contents index
Next: Read and Write Up: Examples Previous: Reading back the

16-bit Input and 32-bit Output

Read a tape on unit 10, with a maximum event size of 1000 words, unpacked as 16-bit words. After some reduction results are stored in array IRECO with a limit of 300 words. These results are then output to unit 20 packed 32-bits/word. The block size for both units is the EP package default (1800 16-bit words). Note the mandatory call to EPCLOS for the output unit at the end.

      PROGRAM EPEXA7
      DIMENSION IBUF(900),IBUFO(900),IRECI(1000),IRECO(300)
      CALL EPINIT
 C--   SET INPUT STATUS WORDS \ SETTING WORD 2 PREVENTS PROGRAM
 C--   OVERWRITING SHOULD YOU HAVE BAD DATA
      CALL EPSETW(10,2,1000,IERR)
      IF(IERR.NE.0)STOP 1
 C        THE FOLLOWING CALL IS OPTIONAL; USEFUL TO VERIFY OPTIONS
      CALL EPSTAT
 C--   READ A RECORD, UNPACK AS 16-BIT WORDS
  50  CALL EPREAD(10,2,NW,IRECI,IBUF,IERR)
      IF(IERR.NE.0)GOTO 500
      PRINT*,NW
 C--   DATA REDUCTION PART \ NWO WORDS OF DATA ARE STORED IN IRECO
 C--   NWO CAN VARY BUT THE MAXIMUM IS 300, DEFINED BY EPSETW CALL
 C--    NWO WORDS
 C--
      CALL USER(NWO,IRECO)
 C--    THE OUTPUT IS PACKED 32-BITS PER WORD
      CALL EPOUTS(20,3,NWO,IRECO,IBUFO,IERR)
      IF(IERR.NE.0)GOTO 600
      GOTO 50
 C--   READ ERRORS
 C--     PARITY AND OTHER
  500 IF(IERR.NE.1)GOTO 50
 C--     EOF
      CALL EPCLOS(20,IBUFO,IERR)
      CALL EPEND(20,IBUFO,IERR)
      STOP
 C--   WRITE ERRORS
  600 STOP 600
      END


Janne Saarela
Tue May 16 09:44:28 METDST 1995