Modify

Opened 5 years ago

Last modified 5 years ago

#1455 reopened defect

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

Reported by: Ian Hinder Owned by:
Priority: minor Milestone:
Component: Cactus Version: development version
Keywords: Cc:

Description

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.

Attachments (0)

Change History (3)

comment:1 Changed 5 years ago by Erik Schnetter

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.

comment:2 Changed 5 years ago by Ian Hinder

Resolution: invalid
Status: newclosed

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.

comment:3 Changed 5 years ago by Erik Schnetter

Resolution: invalid
Status: closedreopened

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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as reopened The ticket will remain with no owner.
Next status will be 'review'.
as The resolution will be set.
to The owner will be changed from (none) to the specified user.
The owner will be changed from (none) to anonymous.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.