Skip to content

Parse non-scientific reals using exponents rather than factors#3067

Merged
timothy-nunn merged 2 commits intoukaea:mainfrom
timothy-nunn:1827-parsing-of-scientific-notation-in-in-file
Feb 27, 2024
Merged

Parse non-scientific reals using exponents rather than factors#3067
timothy-nunn merged 2 commits intoukaea:mainfrom
timothy-nunn:1827-parsing-of-scientific-notation-in-in-file

Conversation

@timothy-nunn
Copy link
Copy Markdown
Collaborator

@timothy-nunn timothy-nunn commented Feb 21, 2024

Description

Correct a difference in parsing decimal vs scientific notations in IN.DATs. By parsing decimals (e.g. 0.08) using exponents we mitigate a slight numerical inaccuracy that occured when sequentially multiplying by 0.1 (which Fortran cannot exactly represent).

Checklist

I confirm that I have completed the following checks:

  • I have justified any large differences in the regression tests caused by this pull request in the comments.
  • I have added new tests where appropriate for the changes I have made.
  • If I have had to change any existing unit or integration tests, I have justified this change in the pull request comments.
  • If I have made documentation changes, I have checked they render correctly.
  • I have added documentation for my change, if appropriate.

@timothy-nunn
Copy link
Copy Markdown
Collaborator Author

timothy-nunn commented Feb 21, 2024

Tests for 0.008 etc created using the following program

program test
    use, intrinsic :: iso_fortran_env, only: dp=>real64

    implicit none

    real(dp) :: a

    a = 8.0D-3

    print *, "a ", a
end program test
>  a    8.0000000000000002E-003

@timothy-nunn
Copy link
Copy Markdown
Collaborator Author

tests/unit/test_input.py has been added to show this fix actually works. On main, 1 failed and 29 passed. On this branch, all 30 pass.

@timothy-nunn timothy-nunn self-assigned this Feb 21, 2024
@timothy-nunn timothy-nunn linked an issue Feb 21, 2024 that may be closed by this pull request
@timothy-nunn timothy-nunn requested a review from clmould February 27, 2024 09:21
@timothy-nunn timothy-nunn merged commit 2958d5e into ukaea:main Feb 27, 2024
@timothy-nunn timothy-nunn deleted the 1827-parsing-of-scientific-notation-in-in-file branch February 27, 2024 10:16
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.

Parsing of scientific notation in IN file

2 participants