parcels icon indicating copy to clipboard operation
parcels copied to clipboard

Confusing compilation error message when variable in Kernel has same name as FieldSet constant

Open erikvansebille opened this issue 1 year ago • 1 comments

When a user writes a Kernel with a variable that has the same name as a FieldSet contestant, that throws an unclear error. E.g.

fieldset.add_constant('vertical_speed', 0.1)

 def ArgoVerticalMovement(particle, fieldset, time):
    vertical_speed = fieldset.vertical_speed

Throws an output like

/var/folders/1n/500ln6w97859_nqq86vwpl000000gr/T/parcels-504/982d2e61fa4f6033c50aae39bf44d63b_0.c:73:18: warning: explicitly assigning value of variable of type 'float' to itself [-Wself-assign]
  vertical_speed = vertical_speed;
  ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~

This could be caught in the codeconverter.py with a more elegant and understandable error

erikvansebille avatar Feb 19 '24 07:02 erikvansebille

I had the same issues, and have written some functions to test/assess if this is the case. I am happy to share these, but I do not know where to put this. Since it is an interplay between Kernels and Fieldset, or sometime only the Kernel itself. Hence any input on this @erikvansebille ?

dicaearchus avatar Feb 20 '24 08:02 dicaearchus