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 printing of literals in fortran modes #584

Merged
merged 2 commits into from
Mar 7, 2025

Conversation

jodavies
Copy link
Collaborator

This supposed to be a "minimal" fix of #546 , in that it fixes the printing of literals > 2^31-1 in fortran modes by adding the float suffix. It does not change the C mode, nor introduce any user-configurable parameter to choose a value.

There are two more differences w.r.t master, so in some sense it is not an entirely "minimal" fix. Maybe someone has some comments:

  • In fortran90 mode, the master branch adds a "." unconditionally, also to integers < 2^31-1. This PR doesn't do this, it prints them in the same way as fortran mode.
  • The (undocumented) pfortran mode does not work properly in the master branch: it doesn't print the ((one*integer)/integer) format in all cases ("test32" in the test case, for eg).

Additionally, note that in 32bit FORM, the master branch starts adding floating suffixes at 2^15-1 (and this PR at 2^16-1).

@coveralls
Copy link

coveralls commented Nov 19, 2024

Coverage Status

coverage: 50.899% (+0.09%) from 50.809%
when pulling 5db6ff7 on jodavies:issue-546
into 71ec8b4 on vermaseren:master.

@jodavies jodavies added this to the v4.3.2 milestone Nov 20, 2024
@tueda tueda linked an issue Jan 24, 2025 that may be closed by this pull request
@jodavies jodavies requested a review from tueda February 25, 2025 14:34
Copy link
Collaborator

@tueda tueda left a comment

Choose a reason for hiding this comment

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

I never fully understood what the old code did, but the new code is understandable!

For now, I think the code looks fine as a minimal fix (except for the comment). But if we want to make sure PFortran mode works correctly in future, 4294967296/4294967297 should be output like (one*2*2147483647+2)/(one*2*2147483647+3) instead of the broken ((one*4294967296.D0)/4294967297.D0) (though it doesn't matter for this example).

jodavies added 2 commits March 3, 2025 09:17
In Fortran modes, use the floating suffix for literal integrals
larger than 2^31-1. See vermaseren#546
@jodavies
Copy link
Collaborator Author

jodavies commented Mar 3, 2025

Rebased and comment improved.

@jodavies jodavies merged commit 638f84b into vermaseren:master Mar 7, 2025
70 checks passed
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.

Add .D0 to integers > i32 in Fortran optimization output
3 participants