CCTK_InterpGridArrays should give an error if an input variable index is -1

Issue #1455 wontfix
Ian Hinder created an issue

CCTK_InterpGridArrays takes as input a list of indices of Cactus variables to interpolate. If one of these indices is -1, no error is given, and meaningless data is returned for this variable (probably from another gridfunction). This can happen easily if you get the variable index using CCTK_VarIndex and make a spelling mistake in the variable name, and don't check the return value.

Keyword:

Comments (4)

  1. Erik Schnetter
    • removed comment

    This is a documented feature, to make it simpler to avoid interpolating grid functions that may not exist. The respective values remain uninitialized.

    To be clear: the feature is that you can pass "-1" as variable index to skip the respective interpolation. The feature is not that you can pass error codes from CCTK_VarIndex to have these errors ignored.

  2. Ian Hinder reporter
    • changed status to resolved
    • removed comment

    I guess it was a mistake to use the same integer (-1) both as a return error code, and a code to mean "no variable" in the interpolator interface. Is there anything we can do to avoid people getting caught by this? Obviously the return value of CCTK_VarIndex should have been checked, but people don't always do this. If this is part of the documented API of both functions, and we don't want to change that, I guess we're stuck. Maybe in future we design a C++ API which has a more friendly error-reporting method than return values, such as exceptions.

  3. Erik Schnetter
    • changed status to open
    • removed comment

    Let us turn this into a feature request. The magic value to ignore a grid variable should be a preprocessor constant that we can then set to a unique value. We already make sure that all the magic values are unique in Cactus.

  4. Roland Haas
    • edited description
    • changed status to wontfix

    The observed behaviour is the documented and intended behaviour. This has been a feature request for 7 years and no one spoke up for it. Closing as wontfix.

  5. Log in to comment