In the routine opsinputs_fill_fillelementtype2dfromsimulatedvariable_records, there is a short piece of code that sets flags for any unused levels in a record to failed:
However, in certain circumstances (e.g. a prescribed number of model levels, which occurs for averaged sonde data), this can lead to an out-of-bounds error if numLevels + 1 is greater than the length of the second dimension of El2. In most cases nothing obvious happens (although memory corruption could occur behind the scenes), but occasionally there is a segfault.
To fix this the code has been modified to compare numLevels against size(El2, 2) and only fill in the flags if there are actually superfluous levels in El2.
In the routine
opsinputs_fill_fillelementtype2dfromsimulatedvariable_records
, there is a short piece of code that sets flags for any unused levels in a record to failed:However, in certain circumstances (e.g. a prescribed number of model levels, which occurs for averaged sonde data), this can lead to an out-of-bounds error if
numLevels + 1
is greater than the length of the second dimension ofEl2
. In most cases nothing obvious happens (although memory corruption could occur behind the scenes), but occasionally there is a segfault.To fix this the code has been modified to compare
numLevels
againstsize(El2, 2)
and only fill in the flags if there are actually superfluous levels inEl2
.Fixes #124