KIM_API_get_rank and KIM_API_get_size

Hi all,

I may be hitting a corner case in the KIM api when I am trying to read the free parameters of a mode. If the parameter is a scalar, then KIM_API_get_rank returns 0 as expected. I would also expect KIM_API_get_size to return 1, as that is the size of a scalar. Instead, it looks like it sometimes returns garbage (I just got the value 4607182418800017409). Is it possible that this API function multiplies the dimensions of the shape, but returns an uninitialized value when there are no dimensions to multiply? I guess that would be OK if documented in the API, although returning 1 would be more natural.

Best regards

Jakob

Hi Jakob,

I believe it is returning a pointer to an array of length one. Do you get 1 if you try dereferencing the value?

Ryan

Hi Jakob,

I believe it is returning a pointer to an array of length one. Do you get 1 if you try dereferencing the value?

Sometimes I get 1, sometimes I get 4607182418800017409. It looks like the pointer points to uninitialized data. I have altered my code to not call KIM_API_get_size if KIM_API_get_rank returns 0. That avoids the problem, but I think there is a bug in the API.

Best regards

Jakob

Ah, I see. Sorry, I misread the original.

Yeah, that is probably undocumented "expected behavior". Thanks for the report. I'll add a discussion to the documentation.

Thanks,

Ryan