New diagnostics assumption of maximum five dimensions violated

Issue #138 resolved
David Dickinson created an issue

In diagnostics_create_and_write some routines appear to assume that we will always pass in a dimension string array of length 5 (e.g. see https://bitbucket.org/gyrokinetics/gs2/src/b5e529c1c9c5410606747fbf02f60a09bc11f76c/src/diagnostics/diagnostics_create_and_write.f90#lines-1582) however some diagnostics (such as https://bitbucket.org/gyrokinetics/gs2/src/b5e529c1c9c5410606747fbf02f60a09bc11f76c/src/diagnostics/diagnostics_moments.f90#lines-179) actually use six variables. These leads to out of bounds access which can cause all manner of issues.

Looking at the create and write code the handling of the dimension_names variable looks a bit suspicious. Currently it creates an array of fixed size five with element type characters of length the number of dimensions. It seems to only ever store length one characters so I think instead of

character(len=len(dimension_list)), dimension(5) :: dimension_names

we might want

character(len=1), dimension(len(dimension_list)) :: dimension_names

Comments (1)

  1. Log in to comment