--- DarthVader/TrackerLevel2/src/F77/filladc.f 2007/08/20 16:07:16 1.10 +++ DarthVader/TrackerLevel2/src/F77/filladc.f 2014/01/17 12:56:50 1.12 @@ -75,7 +75,9 @@ GOOD1(DSPn) = ior(GOOD1(DSPn),2**4) goto 334 !next view endif - word = datatracker(idata) +c word = datatracker(idata) + word = INT(IBITS(datatracker(idata),0,16),2) ! EM GCC4.2, I checked that this line works +c print *,word,' datatracker(idata) ',datatracker(idata) ! EM C------------------------------------------------------ C call routine to uncompress data C------------------------------------------------------ @@ -124,10 +126,11 @@ $ nst(is).gt.0.and. $ nst(is).le.nstrips_va1.and. $ .true.)then - newVAL=oldVAL-pedestal_t(DSPn,nvk(is),nst(is)) - $ +pedestal_t(DSPn,nvk(js),nst(js)) - newVAL=max(0,newVAL) - newVAL=min(4095,newVAL) + newVAL=oldVAL+nint( + $ -pedestal_t(DSPn,nvk(is),nst(is)) ! EM GCC4.7 + $ +pedestal_t(DSPn,nvk(js),nst(js)),2) ! EM GCC4.7 + newVAL=max(int(0,2),newVAL) ! EM GCC4.7 + newVAL=min(int(4095,2),newVAL) endif adc(DSPn,nvk(js),nst(js))=newVAL else @@ -177,11 +180,11 @@ $ nst(is).gt.0.and. $ nst(is).le.nstrips_va1.and. $ .true.)then - newVAL=oldVAL + newVAL=oldVAL+nint( ! EM GCC4.7 $ -pedestal_t(DSPn,nvk(is),nst(is)) - $ +pedestal_t(DSPn,nvk(js),nst(js)) - newVAL=max(0,newVAL) - newVAL=min(4095,newVAL) + $ +pedestal_t(DSPn,nvk(js),nst(js)),2)! EM GCC4.7 + newVAL=max(int(0,2),newVAL)! EM GCC4.7 + newVAL=min(int(4095,2),newVAL)! EM GCC4.7 endif adc(DSPn,nvk(js),nst(js))=newVAL else @@ -349,6 +352,7 @@ SUBROUTINE COMPDECODE(word,flag,tipo,info,errflag) INTEGER*2 word,flag,tipo,info + INTEGER*2 hexmask !EM GCC4.7 C------------------------------------------------------- C Decode tracker words: C @@ -360,7 +364,19 @@ C 1 1(end of ladder 3) 3 or 6 C------------------------------------------------------- errflag=0. - flag=iand(word,z'f000') +C EM: by default z'XXXX' returns a INTEGER*8, we want to have just a INTEGER*2 so we need a trick +C Bitwise is like this: +C WORD = 16 bit +C 1111111111111111 FFFF 32767 + sign +C +C flag=iand(word,z'f000') + hexmask=z'7000' + hexmask=IBSET(hexmask,15) ! it is not possible to set the sign bit with F000, we must set the sign bit with ibset +c print *,' hexmask ',hexmask +c write(*,22)hexmask +c 22 FORMAT(2X,'hexmask: ',2X,Z8) + flag=iand(word,hexmask) +C END EM flag=ishft(flag,-12) if(flag.ne.0.and.flag.ne.1) then @@ -369,19 +385,26 @@ endif if(flag.eq.0) then ! valore ADC tipo=0 - info=iand(word,z'0fff') + hexmask=z'0FFF' !EM GCC4.7 + info=iand(word,hexmask) !EM GCC4.7 +c info=iand(word,z'0fff') !EM GCC4.7 endif if(flag.eq.1) then ! indirizzo OR fine vista - info=iand(word,z'03ff') - tipo=iand(word,z'0c00') - if(tipo.ne.0.and.tipo.ne.z'0800') then + hexmask=z'03FF' !EM GCC4.7 + info=iand(word,hexmask) !EM GCC4.7 +c info=iand(word,z'03ff') !EM GCC4.7 + hexmask=z'0C00' !EM GCC4.7 + tipo=iand(word,hexmask)!EM GCC4.7 +c tipo=iand(word,z'0c00') !EM GCC4.7 + hexmask=z'0800' !EM GCC4.7 + if(tipo.ne.0.and.tipo.ne.hexmask) then !EM GCC4.7 c print*,'compdecode --> error on decompression: tipo=',tipo errflag=1. endif if(tipo.eq.0) then ! indirizzo flag=0 tipo=1 - info=info+1 + info=info+INT(1,2) !EM GCC4.7 endif if(tipo.eq.z'0800') then ! fine vista flag=1