stats_2d_add_entry() doesn't include only_grow=.true. in the calls to ensure_real_array_2d_size() and ensure_integer_array_2d_size() (like is done for the 1D versions of these calls). This cases issues with the copying of old data to the new array due to the wrong size.
Note that these functions say in the comments that:
!> Whether to only increase the array size (default .true.).logical, intent(in), optional :: only_grow
But this doesn't appear to be the actual behavior in testing.
Example: Passing an array of dimension size (1,3) and wanting to add an element to (2,1) should expand the array to size (2,3) and copy all the old data (3 elements) and add the element to (2,1). However it will make the new array size (2,1) and copy the (1,1) element of the old array to the new array.
This is solved by adding only_grow=.true. but as this is listed as the default in the comments and it doesn't appear to be so shouldn't we be able to omit this optional argument?
stats_2d_add_entry()
doesn't includeonly_grow=.true.
in the calls toensure_real_array_2d_size()
andensure_integer_array_2d_size()
(like is done for the 1D versions of these calls). This cases issues with the copying of old data to the new array due to the wrong size.Note that these functions say in the comments that:
!> Whether to only increase the array size (default .true.).
logical, intent(in), optional :: only_grow
But this doesn't appear to be the actual behavior in testing.
Example: Passing an array of dimension size (1,3) and wanting to add an element to (2,1) should expand the array to size (2,3) and copy all the old data (3 elements) and add the element to (2,1). However it will make the new array size (2,1) and copy the (1,1) element of the old array to the new array.
This is solved by adding
only_grow=.true.
but as this is listed as the default in the comments and it doesn't appear to be so shouldn't we be able to omit this optional argument?