Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type comparison #3244

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

makeclean
Copy link
Contributor

There is a type inconsistency in an if statement where the variables coming from the settings namespace are of type int but are compared to a type int32_t and thus the comparison fails, i.e. int(9) > int32_t(9), either the following code changes are needed, or max_realisations should be changed to be int.

Copy link
Contributor

@paulromano paulromano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On almost all architectures, int is int32_t. Furthermore, arithmetic and comparisons between different integer types should work fine as long as you don't exceed the range of either type because the compiler will promote the lower-width integer to a higher width. So, I'm not seeing how the line of code in question could be problematic. Are you actually observing a problem with this?

@makeclean
Copy link
Contributor Author

Yes, spotted running around in the wild. GCC 14.2.1, maybe needs a new compiler flag then? I was scratching my head as to why print statement was never executed, both variables ended up resolving to 10, but int32_t is smaller than int.

@paulromano
Copy link
Contributor

Can you share a minimal working example model for which you're seeing this behavior?

@makeclean
Copy link
Contributor Author

Sure, any problem where VR is on with this block included

  <survival_biasing>true</survival_biasing>
  <mesh id="1">
    <dimension>500 250 160</dimension>
    <lower_left>-5100 -2100 0</lower_left>
    <upper_right>1600 1300 2260</upper_right>
  </mesh>
  <weight_window_generators>
    <weight_windows_generator>
      <mesh>1</mesh>
      <particle_type>neutron</particle_type>
      <max_realizations>10</max_realizations>
      <update_interval>1</update_interval>
      <on_the_fly>true</on_the_fly>
      <method>magic</method>
    </weight_windows_generator>
  </weight_window_generators>

I was getting the error message from the print statement wwhen max_realizations was 10, and my active batches was 10, with inactive at zero.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants