MODAPS PCR 07-018

PCR Number 07-018
Date 2008-03-06
Initiator James Kuyper
Abstract Fix bug where, on rare occasions, invalid packet lengths are adjusted to values that differ from the size of the output packet as written.
Problem Statement The L0 Splitter (MOD_PR00, the only process in PGE00):
1) Sometimes adjusts invalid packet lengths to values that differ from the size of the output packet as actually written.
2) Declares an array of length 0, but uses it as if it had a length 1.
3) Performs bitwise operations on values of signed type.
4) Defines output files as containing 300 seconds of data.
5) If an input file starts with a data gap of 5 minutes or longer, it does not write the first packet to any of the output files.
Description of Change 1) Change to leave packet lengths unmodified, and therefore matching the actual length of the packet as written. Leave handling of invalid packet lengths to PGE01.
2) Replace the zero-length array with a simple variable, or in some cases with direct use of numeric literals.
3) Change to use an unsigned type.
4) Change to define the output file length in minutes, allowing for the possibility that some minutes can be 61 seconds long.
5) Correct to make sure that the first packet is written to the appropriate output file.
Products Affected M[O|Y]00F
Software Affected PGE00
Processing String to Receive the Change Terra Forward, Aqua Forward
Downstream Product Effects Literally every MODIS PGE is downstream of PGE00, and the packets inappropriately lost by the first bug described above could, in principle, affect any and all of them. Only the fact that this bug is very difficult to trigger has prevented it from causing serious problems.
Data Granules to be Used for Science Testing Granules where problems were reported which were probably attributable to the 1st bug: Terra 2007-041 18:00, Terra 2002-179 02:00, Aqua 2007-145 14:00, Terra 2006-116 18:00, Terra 2007-214 02:00, Terra 2006-264 16:00, Aqua 2007-140 22:00. This implies that the 1st bug happens at least a few times each year, but probably not much more often than that.

We did a 7-day continuous run, to set an upper limit on how common this bug is: Terra and Aqua, 2008-055/061.
Justification 1) Packet lengths which don't match the actual size of the packet cause many of the following packets in the same file to be read incorrectly. This is sometimes fatal, and always bad, for PGE01.
2) The declaration of an array of length 0 is a constraint violation according to the C standard. Using it as if it had a length of 1 renders the behavior of the entire program undefined. In practice, it works under IRIX when the -xansi option is chosen, but is a violation of EOSDIS coding standard 3.2.1.
3) Such code is an unportable violation of MODIS Software Development standard 6.5.1, but it happens to work on the IRIX compiler.
4) When a leap second occurs, as has happened exactly once so far in the life of both MODIS instruments, data from that leap second would not be assigned to any output granule. This will only matter if MODIS handles the next leap second correctly, rather than several seconds late, as was done with the last one.
5) There's no good reason for dropping that packet.
Effective Date for Implementation of Change  
Status