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

[asr->fortran] implement visit_{FileOpen, FileClose, FileRead} #2686

Merged
merged 8 commits into from
Oct 27, 2023

Conversation

khushi-411
Copy link
Contributor

@khushi-411 khushi-411 commented Oct 20, 2023

TODO

  • enable remaining valid tests

Copy link
Member

@Thirumalai-Shaktivel Thirumalai-Shaktivel left a comment

Choose a reason for hiding this comment

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

It looks good so far!
If you feel you have finished the PR, please mark it as "Ready for Review".

src/libasr/codegen/asr_to_fortran.cpp Outdated Show resolved Hide resolved
src/libasr/codegen/asr_to_fortran.cpp Outdated Show resolved Hide resolved
src/libasr/codegen/asr_to_fortran.cpp Show resolved Hide resolved
@khushi-411
Copy link
Contributor Author

Addressed all your reviews! Thanks, @Thirumalai-Shaktivel!

If you feel you have finished the PR, please mark it as "Ready for Review".

I think we can also enable some other tests too. For example: file_04.f90, these tests pass along with the NOFAST flag but not without it. This is the generated code for it:

generated code

program load_model_program
implicit none
integer(4) :: int_data1
integer(4) :: int_data2
real(4) :: real_data1
real(4) :: real_data2
integer(4), save :: u = 11
open(u, file="file_04_data.dat", form="unformatted")
read(u, *) int_data1, real_data1, int_data2, real_data2
print *, "Data: ", int_data1, real_data1, int_data2, real_data2
if (int_data1 /= 345239) then
    error stop
end if
if (abs(real_data1 - 52.910000) > 0.000001) then
    error stop
end if
if (int_data2 /= (-345239)) then
    error stop
end if
if (abs(real_data2 - (-52.910000)) > 0.000001) then
    error stop
end if
end program load_model_program

test code

program load_model_program
    implicit none

    integer :: int_data1, int_data2
    real :: real_data1, real_data2
    integer :: u = 11

    open(u, file="file_04_data.dat", form="unformatted", access="stream")
    read(u) int_data1, real_data1, int_data2, real_data2

    print *, "Data: ", int_data1, real_data1, int_data2, real_data2
    if (int_data1 /= 345239) error stop
    if (abs(real_data1 - (52.91)) > 1e-6) error stop
    if (int_data2 /= -345239) error stop
    if (abs(real_data2 - (-52.91)) > 1e-6) error stop
end program

What do you think?

@khushi-411 khushi-411 marked this pull request as ready for review October 26, 2023 17:07
Copy link
Member

@Thirumalai-Shaktivel Thirumalai-Shaktivel left a comment

Choose a reason for hiding this comment

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

LGTM, Thank you!

src/libasr/codegen/asr_to_fortran.cpp Outdated Show resolved Hide resolved
@Thirumalai-Shaktivel
Copy link
Member

Thank you!

@Thirumalai-Shaktivel
Copy link
Member

@Shaikh-Ubaid, can you review and merge this PR?

Copy link
Member

@Shaikh-Ubaid Shaikh-Ubaid left a comment

Choose a reason for hiding this comment

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

I shared a minor comment. This looks good to me! Very valuable contributions! Thanks for this!

@khushi-411
Copy link
Contributor Author

Thanks for all your helpful reviews in the PR, @Thirumalai-Shaktivel & @Shaikh-Ubaid!

Have addressed all of your reviews!

@Thirumalai-Shaktivel Thirumalai-Shaktivel merged commit dc46c59 into lfortran:main Oct 27, 2023
20 checks passed
@khushi-411 khushi-411 deleted the add_file_v branch October 27, 2023 13:13
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.

None yet

4 participants