***************************************************************
*
*     common for readraw
*
*
*     10/9/2005 modified by david fedele to include general variables
*     23/6/2006 modified by elena to fix a bug
*
**************************************************************

      
      parameter (MAXBUFFLEN=z'172c8')
      integer YODAflag
      integer*4 length_buffer
      integer*1 buffer(MAXBUFFLEN)
      integer curpos            !current position in buffer
      integer startcrc
      integer stopcrc
c      common/yoda_buffer/YODAflag,length_buffer,buffer,curpos,startcrc,stopcrc

      integer*2 header(16)      !header: 16 2-byte words
      integer*2 trailer(3)      !trailer: 3 2-byte words
      integer checkheader       !header control flag: 
                                ! =1 if some error occurred
                                ! =2 if Acquisition header, 
                                ! =3 if Calibration header 
      common/pkt_structure/header,checkheader,trailer


      integer DAQmode_cal       !
      integer DSPnumber_cal     !view number
      integer dataword
      integer calibrationnumber
      integer nused_event
      integer ped_1,ped_2,ped_3
      integer sig_1,sig_2,sig_3
      integer nbad_1,nbad_2,nbad_3
      integer ff
      integer checksum_cal
      integer DSPbad_o(nviews,nstrips_view) !online bad strips
      real DSPped_o(nviews,nstrips_view) !online pedestal
      real DSPsig_o(nviews,nstrips_view) !online sigma
      integer crc_calib(3)      !crc control per ladder
      integer crc_hcalib        !crc control per header

      common/calibration_pkt/DAQmode_cal,DSPnumber_cal
     $     ,dataword,calibrationnumber,
     $     nused_event,
     $     ped_1,ped_2,ped_3,
     $     sig_1,sig_2,sig_3,
     $     nbad_1,nbad_2,nbad_3,
     $     ff,checksum_cal
     $     ,DSPped_o,DSPsig_o,DSPbad_o,crc_calib,crc_hcalib   

*
*		common for data packet
*
      parameter (MAXBTRALEN=200000)
      integer DAQmode_dat       !9  = full acquisition mode
                                !10 = compressed acquisition mode
                                !11 = compressed+full acquisition mode
      integer DSPnumber_dat     !view number
      integer DATAlength_dat    !data buffer length
      integer eventn_dat        !DSP event number
      integer nclust_dat!nclust*2+1 = number of strips to be 
      integer cutc_dat          !cut to include strips in a cluster
      integer cutcl_dat         !cut to search for clusters
      integer addrcluster_dat(3) !address of the greatest cluster(view,ladder)
      integer signcluster_dat(3) !signal of the greatest cluster(view,ladder)
      integer fc_dat            !compression flag
      integer compressiontime_dat !DSP program compression time
      integer fl5_dat           !flag
      integer fl4_dat           !flag
      integer fl3_dat           !flag
      integer fl2_dat           !flag
      integer fl1_dat           !flag
      integer fl6_dat           !flag
      integer checksum_dat       !DSP header checksum
      integer l_tra
      integer*2 b_tra(MAXBTRALEN)    !DATA BUFFER
      integer pnum_dat,cmdnum_dat,bid_dat,alarm_dat,aswr_dat
      integer crc_dat
      
      common/data_pkt/DAQmode_dat,DSPnumber_dat
     $     ,eventn_dat,nclust_dat
     $     ,cutc_dat,cutcl_dat
     $     ,addrcluster_dat,signcluster_dat
     $     ,fc_dat,compressiontime_dat
     $     ,fl5_dat,fl4_dat,fl3_dat,fl2_dat,fl1_dat,fl6_dat
     $     ,checksum_dat,datalength_dat,l_tra,b_tra
     $     ,pnum_dat,cmdnum_dat,bid_dat
     &     ,alarm_dat,aswr_dat
     &     ,crc_dat

