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: Update real function to provide correct kind #5797

Merged
merged 17 commits into from
Dec 27, 2024

Conversation

HarshilShah1804
Copy link
Contributor

Fix #4629
The real function is updated so that if a kind is specified, the output is of that kind, otherwise the same kind as the input.

For

program main
    complex(8) :: arr2(3) = [(5._8, 7._8), (8.2_8, 7.12_8), (1.2_8, 3.4_8)]
    print *, kind(real(arr2))
end program 

Output

$ lfortran a.f90
8

@certik
Copy link
Contributor

certik commented Dec 23, 2024

Also add a test for this.

@certik
Copy link
Contributor

certik commented Dec 25, 2024

Per #5797 (comment), see if you can modify the generator script to insert the modification for complex correctly, using the existing mechanism. That way we don't need to duplicate / manually maintain the two functions.

@HarshitaKalani
Copy link
Contributor

@HarshilShah1804 just a heads up. If you check aimag intrinsic, it already follows what we're trying to do here:

program main
    complex(8) :: arr2(3) = [(5._8, 7._8), (8.2_8, 7.12_8), (1.2_8, 3.4_8)]
    print *, kind(real(arr2))
end program 
$ lfortran a.f90
8
$ gfortran a.f90 && ./a.out
           8

You can follow its implementation and it'll be a simple fix.

Copy link
Contributor

@HarshitaKalani HarshitaKalani left a comment

Choose a reason for hiding this comment

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

I've left some comments. Can you please address them?
This looks good otherwise. Thanks for fixing it!

integration_tests/intrinsics_334.f90 Outdated Show resolved Hide resolved
integration_tests/intrinsics_334.f90 Outdated Show resolved Hide resolved
src/libasr/intrinsic_func_registry_util_gen.py Outdated Show resolved Hide resolved
Copy link
Contributor

@HarshitaKalani HarshitaKalani left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks!

@HarshitaKalani HarshitaKalani merged commit e3d9508 into lfortran:main Dec 27, 2024
27 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.

real does not give the correct kind for output
3 participants