C------------------------------------------------ SUBROUTINE calpedestal(vect,ERROR,CAL_PED,CAL_GOOD,CAL_THR, & CAL_RMS,CAL_BASE,CAL_VAR) C------------------------------------------------ IMPLICIT NONE EXTERNAL CRC C C Normal variables definition C INTEGER ERROR C INTEGER i, j, ival C INTEGER*2 VECT(20000) C integer*2 check, crc C INTEGER ic, k INTEGER status INTEGER inf, sup INTEGER*2 length, length2 INTEGER*2 st1, st2 REAL CAL_PED(4,11,96), CAL_GOOD(4,11,96), CAL_THR(4,11,6) REAL CAL_RMS(4,11,96), CAL_BASE(4,11,6), CAL_VAR(4,11,6) C C Begin ! C ERROR = 0 ival = 0 C ic = 0 c length = ic do k = 1,4 C C Check consistency of status word. C ic = length + 1 st1 = IAND(vect(ic),'00FF'x) if (st1.ne.0) then write (*,10) k,vect(ic) endif st2 = IAND(vect(ic),'FF00'x) status = ISHFT(st2,-8) if (k.eq.1.and.status.ne.170) then write (*,11) k,vect(ic) ERROR = 1 goto 50 endif if (k.eq.2.and.status.ne.182) then write (*,11) k,vect(ic) ERROR = 1 goto 50 endif if (k.eq.3.and.status.ne.177) then write (*,11) k,vect(ic) ERROR = 1 goto 50 endif if (k.eq.4.and.status.ne.173) then write (*,11) k,vect(ic) ERROR = 1 goto 50 endif 10 FORMAT(2X,'Error for view:',2X,I1,2X,'Status word:',2X,Z4) 11 FORMAT(2X,'View or command not recorgnized for view:',2X,I1,2X, & 'Status word:',2X,Z4) C ic = ic + 1 length = length + (vect(ic) + 2) length2 = vect(ic) C C Check validity of length. C if (vect(ic).ne.4629) then print *,'problems with view',k ERROR = 1 goto 50 endif C C Check consistency of CRC. C check = 0. inf = (length-length2-2)+1 sup = length - 1 do i = inf,sup check=CRC(check,vect(i)) enddo if (check.ne.vect(length)) then print *,'Problems with CRC of view:',k ERROR = 1 goto 50 endif C C Process data. C do i = 1,11 do j = 1,96 ic = ic + 1 cal_ped(k,i,j) = vect(ic) cal_good(k,i,j) = vect(ic+1) ic = ic + 1 enddo enddo C ic = ic + 4 do i = 1,11 do j = 1,6 ic = ic + 1 cal_thr(k,i,j) = vect(ic) ic = ic + 1 enddo enddo c ic = ic + 4 do i = 1,11 do j = 1,96 ic = ic + 1 cal_rms(k,i,j) = vect(ic) ic = ic + 1 enddo enddo c do i = 1,11 do j = 1,6 ic = ic + 1 cal_base(k,i,j) = vect(ic) ic = ic + 1 ic = ic + 1 cal_var(k,i,j) = vect(ic) ic = ic + 1 enddo enddo c 50 continue c enddo C RETURN END