/[PAMELA software]/DarthVader/TrackerLevel2/src/F77/filladc.f
ViewVC logotype

Diff of /DarthVader/TrackerLevel2/src/F77/filladc.f

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by pam-fi, Thu Sep 28 14:04:40 2006 UTC revision 1.10 by pam-fi, Mon Aug 20 16:07:16 2007 UTC
# Line 9  Line 9 
9    
10        include 'common_reduction.f'        include 'common_reduction.f'
11    
   
12        external nvk        external nvk
13        external nst        external nst
14    
# Line 44  C     or the data buffer is empty Line 43  C     or the data buffer is empty
43  C     jump to next view  C     jump to next view
44  C     ---------------------------  C     ---------------------------
45    
46             nword_DSP = 0
47           if(DSPn.eq.0           if(DSPn.eq.0
48         $        .or.DSPn.gt.nviews
49       $        .or.datalength(iv).eq.0)goto 333       $        .or.datalength(iv).eq.0)goto 333
50            
51  C++++++++++++++++++++++++++++++++++++++++++++++++++++++  C++++++++++++++++++++++++++++++++++++++++++++++++++++++
52           if(  iand(DAQmode(iv),z'0003').eq.z'0002'.or.           if(  iand(DAQmode(iv),z'0003').eq.z'0002'.or.
53       $        iand(DAQmode(iv),z'0003').eq.z'0003'.or.       $        iand(DAQmode(iv),z'0003').eq.z'0003'.or.
# Line 54  C+++++++++++++++++++++++++++++++++++++++ Line 55  C+++++++++++++++++++++++++++++++++++++++
55       $        .false.) then       $        .false.) then
56  C++++++++++++++++++++++++++++++++++++++++++++++++++++++  C++++++++++++++++++++++++++++++++++++++++++++++++++++++
57  C--------------------------------------compressed mode  C--------------------------------------compressed mode
58                if(debug.eq.1)print*,'DSP #',DSPn,' --> compressed '
59              is = 0              is = 0
60              il = 0              il = 0
61              prec_ind = 0              prec_ind = 0
62   222        continue   222        continue
63              idata = idata+1              idata = idata+1
64              word=datatracker(idata)              if( idata.gt.NWORDMAX )goto 335 !end to end
65                nword_DSP = nword_DSP +1
66                if(  nword_DSP.gt.datalength(iv) )then
67                   if( debug.eq.1 )
68         $              print*,'filladc --> missing end-of-ladder',
69         $              ' in COMPRESSED mode - DSP ',DSPn
70                   if(debug.eq.1)
71         $              print*,'datalength = ',datalength(iv)
72                   iflag=1
73    c               GOOD1(DSPn) = 10
74    c               GOOD1(DSPn) = GOOD1(DSPn) + 2**4
75                   GOOD1(DSPn) = ior(GOOD1(DSPn),2**4)
76                   goto 334         !next view
77                endif
78                word = datatracker(idata)
79  C------------------------------------------------------  C------------------------------------------------------
80  C     call routine to uncompress data  C     call routine to uncompress data
81  C------------------------------------------------------  C------------------------------------------------------
82              call compdecode(word,flag,tipo,info,errflag)              call compdecode(word,flag,tipo,info,errflag)
83                            
84              if(errflag.ne.0.) then              if(errflag.ne.0.) then
85                 if(debug)print*,'filladc --> ERROR on compdecode'                 if(debug.eq.1)print*,'filladc --> ERROR on compdecode'
86                 iflag=1                 iflag=1
87                 GOOD1(DSPn) = 10  c               GOOD1(DSPn) = 10
88    c               GOOD1(DSPn) = GOOD1(DSPn) + 2**4
89                   GOOD1(DSPn) = ior(GOOD1(DSPn),2**4)
90  c               return  c               return
91                 goto 221                 goto 221
92              endif              endif
# Line 76  c               return Line 94  c               return
94              if(flag.eq.1) then  !   flag: fine messaggio (ladder)              if(flag.eq.1) then  !   flag: fine messaggio (ladder)
95                                
96                 if(info.ne.1.and.info.ne.2.and.info.ne.3) then                 if(info.ne.1.and.info.ne.2.and.info.ne.3) then
97                    if(debug)print*,                    if(debug.eq.1)print*,
98       $                 'filladc --> wrong end-of-ladder '       $                 'filladc --> wrong end-of-ladder '
99       $                 //'in COMPRESSED mode'       $                 //'in COMPRESSED mode'
100                    if(debug)print*,                    if(debug.eq.1)print*,
101       $                 '            info(=ladder) ',info,'  type ',tipo       $                 '            info(=ladder) ',info,'  type ',tipo
102                    iflag=1                    iflag=1
103                    GOOD1(DSPn) = 10  c                  GOOD1(DSPn) = 10
104    c               GOOD1(DSPn) = GOOD1(DSPn) + 2**4
105                   GOOD1(DSPn) = ior(GOOD1(DSPn),2**4)
106  c                  return  c                  return
107                    goto 221                    goto 221
108                 endif                 endif
# Line 90  c                  return Line 110  c                  return
110                 il = info                 il = info
111                 do js=is+1,1024*il                 do js=is+1,1024*il
112                                        
113                    if(       DSPn.le.nviews                    if( DSPn.le.nviews
114         $                 .and.nvk(js).gt.0
115       $                 .and.nvk(js).le.nva1_view       $                 .and.nvk(js).le.nva1_view
116         $                 .and.nst(js).gt.0
117       $                 .and.nst(js).le.nstrips_va1       $                 .and.nst(js).le.nstrips_va1
      $                 .and.nvk(is).le.nva1_view  
      $                 .and.nst(is).le.nstrips_va1  
118       $                 )then       $                 )then
119    
120                       newVAL=oldVAL-pedestal_t(DSPn,nvk(is),nst(is))                       newVAL = 0
121       $                    +pedestal_t(DSPn,nvk(js),nst(js))                       if(  
122                       newVAL=max(0,newVAL)       $                    nvk(is).gt.0.and.
123                       newVAL=min(4095,newVAL)       $                    nvk(is).le.nva1_view.and.
124         $                    nst(is).gt.0.and.
125         $                    nst(is).le.nstrips_va1.and.
126         $                    .true.)then
127                            newVAL=oldVAL-pedestal_t(DSPn,nvk(is),nst(is))
128         $                       +pedestal_t(DSPn,nvk(js),nst(js))
129                            newVAL=max(0,newVAL)
130                            newVAL=min(4095,newVAL)
131                         endif
132                       adc(DSPn,nvk(js),nst(js))=newVAL                       adc(DSPn,nvk(js),nst(js))=newVAL
133                    else                    else                    
134                       print*,'filladc -->'                       print*,'filladc -->'
135       $                    ,' attempt to access array elements (1)'       $                    ,' attempt to access array element (1)'
136       $                    ,'(',DSPn,nvk(is),nst(is),')'  c     $                    ,'(',DSPn,nvk(is),nst(is),')'
137       $                    ,'(',DSPn,nvk(js),nst(js),')'       $                    ,'pedestal_t(',DSPn,nvk(js),nst(js),')'
138                    endif                    endif
139  c$$$  print*,DSPn,nvk(js),nst(js)  c$$$  print*,DSPn,nvk(js),nst(js)
140  c$$$  $             ,pedestal_t(DSPn,nvk(js),nst(js)),newval  c$$$  $             ,pedestal_t(DSPn,nvk(js),nst(js)),newval
# Line 123  c$$$  $             ,pedestal(DSPn,nvk(j Line 151  c$$$  $             ,pedestal(DSPn,nvk(j
151                 if(tipo.eq.1) then ! tipo: indirizzo                 if(tipo.eq.1) then ! tipo: indirizzo
152                    iaddr = info + il*1024                    iaddr = info + il*1024
153                    if(iaddr.ge.is+1.and.iaddr.le.3072) then                    if(iaddr.ge.is+1.and.iaddr.le.3072) then
154                        
155                         if(is.eq.0.or.is.eq.1024.or.is.eq.2048)then
156                            if(debug.eq.1)print*,'filladc -->'
157         $                       ,' previous transmitted strip ',is
158         $                       ,' - missing first ADC value'
159                            iflag=1
160    c                        GOOD1(DSPn) = 10
161    c                        GOOD1(DSPn) = GOOD1(DSPn) + 2**4
162                            GOOD1(DSPn) = ior(GOOD1(DSPn),2**4)
163                         endif
164                       do js = is+1,iaddr-1                       do js = is+1,iaddr-1
165    
166                          if(       DSPn.le.nviews                          if( DSPn.le.nviews
167         $                       .and.nvk(js).gt.0
168       $                       .and.nvk(js).le.nva1_view       $                       .and.nvk(js).le.nva1_view
169         $                       .and.nst(js).gt.0
170       $                       .and.nst(js).le.nstrips_va1       $                       .and.nst(js).le.nstrips_va1
      $                       .and.nvk(is).le.nva1_view  
      $                       .and.nst(is).le.nstrips_va1  
171       $                       )then       $                       )then
172                              
173                             newVAL=oldVAL                             newVAL = 0
174       $                          -pedestal_t(DSPn,nvk(is),nst(is))                             if(
175       $                          +pedestal_t(DSPn,nvk(js),nst(js))       $                          nvk(is).gt.0.and.
176                             newVAL=max(0,newVAL)       $                          nvk(is).le.nva1_view.and.
177                             newVAL=min(4095,newVAL)       $                          nst(is).gt.0.and.
178         $                          nst(is).le.nstrips_va1.and.
179         $                          .true.)then
180                                  newVAL=oldVAL
181         $                             -pedestal_t(DSPn,nvk(is),nst(is))
182         $                             +pedestal_t(DSPn,nvk(js),nst(js))
183                                  newVAL=max(0,newVAL)
184                                  newVAL=min(4095,newVAL)
185                               endif
186                             adc(DSPn,nvk(js),nst(js))=newVAL                             adc(DSPn,nvk(js),nst(js))=newVAL
187                          else                          else
188                             print*,'filladc -->'                             print*,'filladc -->'
189       $                          ,' attempt to access array elements (2)'       $                          ,' attempt to access array element (2) '
190       $                          ,'(',DSPn,nvk(is),nst(is),')'  c     $                          ,'(',DSPn,nvk(is),nst(is),')'
191       $                          ,'(',DSPn,nvk(js),nst(js),')'       $                          ,'pedestal_t(',DSPn,nvk(js),nst(js),')'
192    c                           iflag=1
193    c                           if(DSPn.le.nviews)GOOD1(DSPn) = 10
194                          endif                          endif
195  c     print*,DSPn,nvk(js),nst(js),newval  c     print*,DSPn,nvk(js),nst(js),newval
196                                                    
# Line 151  c     print*,DSPn,nvk(js),nst(js),newval Line 199  c     print*,DSPn,nvk(js),nst(js),newval
199                       is = iaddr                       is = iaddr
200                       prec_ind = 1                       prec_ind = 1
201                    else                    else
202                       if(debug)print*,'filladc --> address '//                       if(debug.eq.1)print*,'filladc --> address '//
203       $                    'out of range - iaddr,is',iaddr,is       $                    'out of range - iaddr,is',iaddr,is
204                       iflag=1                       iflag=1
205                       GOOD1(DSPn) = 10  c                     GOOD1(DSPn) = 10
206    c                     GOOD1(DSPn) = GOOD1(DSPn) + 2**4
207                         GOOD1(DSPn) = ior(GOOD1(DSPn),2**4)
208  c                     return  c                     return
209                       goto 221                       goto 221
210                    endif                    endif
# Line 163  c                     return Line 213  c                     return
213                    if(prec_ind.eq.0) is=is+1                    if(prec_ind.eq.0) is=is+1
214                    if(info.ge.0.and.info.le.4095) then                    if(info.ge.0.and.info.le.4095) then
215                       if(is.gt.3072)then                       if(is.gt.3072)then
216                          if(debug)print*,                          if(debug.eq.1)print*,
217       $                       'filladc --> strip out of range - DSPn,is'       $                       'filladc --> strip out of range - DSPn,is'
218       $                       ,DSPn,is       $                       ,DSPn,is
219                          iflag=1                          iflag=1
220                          GOOD1(DSPn) = 10  c                        GOOD1(DSPn) = 10
221    c                        GOOD1(DSPn) = GOOD1(DSPn) + 2**4
222                            GOOD1(DSPn) = ior(GOOD1(DSPn),2**4)
223  c                        return  c                        return
224                          goto 221                          goto 221
225    
# Line 186  ccc   print*,DSPn,nvk(is),nst(is),newval Line 238  ccc   print*,DSPn,nvk(is),nst(is),newval
238                                            
239                       oldVAL=newVAL                       oldVAL=newVAL
240                    else                    else
241                       if(debug)                       if(debug.eq.1)
242       $                    print*,'filladc --> datum out of range - info'       $                    print*,'filladc --> datum out of range - info'
243       $                    ,info       $                    ,info
244                       iflag=1                       iflag=1
245                       GOOD1(DSPn) = 10  c                     GOOD1(DSPn) = 10
246    c                     GOOD1(DSPn) = GOOD1(DSPn) + 2**4
247                         GOOD1(DSPn) = ior(GOOD1(DSPn),2**4)
248  c                     return  c                     return
249                       goto 221                       goto 221
250                    endif                    endif
# Line 214  c     if(iand(DAQmode(iv),z'0001').eq.z' Line 268  c     if(iand(DAQmode(iv),z'0001').eq.z'
268  C++++++++++++++++++++++++++++++++++++++++++++++++++++++  C++++++++++++++++++++++++++++++++++++++++++++++++++++++
269  C--------------------------------------------full mode  C--------------------------------------------full mode
270                            
271                if(debug.eq.1)print*,'DSP #',DSPn,' --> full '
272    
273              do i=1,3            !loop over ladder              do i=1,3            !loop over ladder
274                 do j=1,1024      !loop over strips                 do j=1,1024      !loop over strips
275                    idata = idata+1                    idata = idata+1
276                      if( idata.gt.NWORDMAX )goto 335 !go to end
277                      nword_DSP = nword_DSP +1
278                      if(  nword_DSP.gt.datalength(iv) )then
279                         if( debug.eq.1 )
280         $                    print*,'filladc --> missing end-of-ladder',
281         $                    ' in FULL mode - DSP ',DSPn
282                         if(debug.eq.1)print*,'datalength = ',datalength
283                         goto 334   !next view
284                      endif
285                    is=j+1024*(i-1)                    is=j+1024*(i-1)
286  c     adcadc=adc(DSPn,nvk(is),nst(is))  c     adcadc=adc(DSPn,nvk(is),nst(is))
287                    if(       DSPn.le.nviews                    if(       DSPn.le.nviews
# Line 237  c     $                    ' ---- ',adc( Line 301  c     $                    ' ---- ',adc(
301  c     endif  c     endif
302                 enddo            !loop over strips                 enddo            !loop over strips
303                 idata = idata+1                 idata = idata+1
304                   if( idata.gt.NWORDMAX )goto 335 !go to end
305                   nword_DSP = nword_DSP +1
306                   if(  nword_DSP.gt.datalength(iv) )then
307                      if( debug.eq.1 )
308         $                 print*,'filladc --> missing end-of-ladder',
309         $                 ' in FULL mode - DSP ',DSPn
310                      if(debug.eq.1)print*,'datalength = ',datalength
311                      goto 334      !next view
312                   endif
313                 if(datatracker(idata).ne.ior(z'1800',i+3)) then                 if(datatracker(idata).ne.ior(z'1800',i+3)) then
314                    if(debug)                    if(debug.eq.1)
315       $                 print*,'filladc --> ',       $                 print*,'filladc --> ',
316       $                 'wrong end-of-ladder in FULL mode'       $                 'wrong end-of-ladder in FULL mode'
317                    if(debug)                    if(debug.eq.1)
318       $                 print*,'            word ',datatracker(idata)       $                 print*,'            word ',datatracker(idata)
319                    if(debug)                    if(debug.eq.1)
320       $                 print*,'            should be ',ior(z'1800',i+3)       $                 print*,'            should be ',ior(z'1800',i+3)
321                    iflag=1                    iflag=1
322                    GOOD1(DSPn) = 10  c                  GOOD1(DSPn) = 10
323    c                  GOOD1(DSPn) = GOOD1(DSPn) + 2**4
324                      GOOD1(DSPn) = ior(GOOD1(DSPn),2**4)
325  c                  return                    c                  return                  
326                 endif                 endif
327              enddo!endl loop over ladder              enddo!endl loop over ladder
328           endif           endif
329           goto 334           goto 334
330   333  continue   333     continue
331        if(debug)print*,'filladc --> ',iv           if(debug.eq.1)print*,'filladc --> ',iv
332       $     ,'^ DSP packet missing or corrupted: '       $        ,'^ DSP packet missing or corrupted: '
333       $     ,'DSPn, datalength(iv) => '       $        ,'DSPn, datalength(iv) => '
334       $     ,DSPn,datalength(iv)       $        ,DSPn,datalength(iv)
335   334  continue   334     continue
336        enddo        enddo
337                goto 336
338     335  continue
339          if(debug.eq.1)print*,'filladc --> reached end of buffer:',
340         $     ' datatracker(',NWORDMAX,')'
341    
342     336  continue
343        return        return
344        end        end
345    
# Line 285  C--------------------------------------- Line 365  C---------------------------------------
365    
366        if(flag.ne.0.and.flag.ne.1) then        if(flag.ne.0.and.flag.ne.1) then
367  c        print*,'compdecode --> error on uncompression: flag=',flag  c        print*,'compdecode --> error on uncompression: flag=',flag
368          errflag=1.           errflag=1.
369        endif        endif
370        if(flag.eq.0) then        ! valore ADC        if(flag.eq.0) then        ! valore ADC
371          tipo=0           tipo=0
372          info=iand(word,z'0fff')           info=iand(word,z'0fff')
373        endif        endif
374        if(flag.eq.1) then        ! indirizzo OR fine vista        if(flag.eq.1) then        ! indirizzo OR fine vista
375          info=iand(word,z'03ff')          info=iand(word,z'03ff')

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.23