SUBROUTINE getnum(octant, plane, number) INTEGER octant ! octant for which we want the # of hits INTEGER plane ! plane for which we want the # of hits INTEGER number ! number of hits in this octant/plane $$INCLUDE 'C$INC:BCS.INC' $$INCLUDE 'YBOS$LIBRARY:ERRCOD.INC' INTEGER blocat ! YBOS named bank finder INTEGER status ! error return status INTEGER octoff ! offset to octant's data INTEGER nexoff ! offset to next octant's data INTEGER plaoff ! offset to plane's data INTEGER planex ! offset to next plane's data C................................. number = 0 ! safety default status = blocat(iw,'FMUE',1,ind,indmuo) IF(status .NE. yesucc) RETURN octoff = iw(indmuo+1+octant) nexoff = iw(indmuo+2+octant) IF(nexoff .LE. octoff) RETURN ! no data octoff = indmuo + octoff ! DON'T FORGET THE BANK OFFSET! plaoff = iw(octoff + 1 + plane) planex = iw(octoff + 2 + plane) IF(planex .LT. plaoff) RETURN number = planex - plaoff - 1 RETURN END
It is easy to lose track of offsets plus offsets. In the above the offset to the bank was omitted, and only the internal offset used. As a result, the routine would have read some words from the beginning of the YBOS header, some of which are very large, and returned garbage.