SuperDARN / rst

Radar Software Toolkit (RST)
https://superdarn.github.io/rst/
GNU General Public License v3.0
22 stars 18 forks source link

Modifying IDL MAX_RANGE to match C / DLM code #520

Closed egthomas closed 2 years ago

egthomas commented 2 years ago

This pull request fixes an error when trying to initialize a fit structure within IDL using the FitMakeFitData routine while also reading a record from a fitacf-format file. The problem is that the native IDL code initializes the size of the arrays in the fit structure to 300 while the C / DLM code initializes the arrays to 800 elements. Using something like the following code will cause a free(): corrupted unsorted chunks core dump:

FitMakeFitData, fit                  ; this initializes a fit structure in IDL with a MAX_RANGE of 300 gates

inp = FitOpen(fitacf_name, /read)    ; open a FITACF-format file
ret = FitRead(inp, prm, fit)         ; read from the FITACF-format file, trying to return a fit structure with a MAX_RANGE of 800 gates

If you try reading a fit structure from a fitacf-format file first (using the DLMs) and then creating a fit structure with FitMakeFitData, I believe that causes a Conflicting data structures: <FLOAT Array[300]>,FITDATA. error instead. On this branch, all of these errors should be fixed.

ecbland commented 2 years ago

I was able to reproduce the bug on develop, and this PR fixes it. Merging now!