Skip to content

Static non-trivial WHEN statements should not be evaulated in TRACE #2590

Description

@g5t

The Union test instrument Test_inhomogenous_process.instr has a string valued Instrument parameter sample which is used to control the possible interactions of a neutron ray in the simulation runtime.
The sample Instrument parameter is static during the lifetime of the simulation, so the result of the following check is static as well

) WHEN (!str_comp((const char*)"thin", (const char*)sample))

Since the WHEN expression is evaluated in TRACE, this same expression is run as many times as there are rays, e.g., mcncount.
A compiler may be clever enough to recognize that the result of this expression is constant, but we can help it by moving such statements to the INITIALIZE block of the instrument file.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions