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

Replace nonstandard isnan() call with value input checks instead #2061

Merged
merged 4 commits into from
Sep 13, 2024

Conversation

islas
Copy link
Collaborator

@islas islas commented Jun 7, 2024

TYPE: bug fix

KEYWORDS: compilation, nonstandard

SOURCE: internal

DESCRIPTION OF CHANGES:
Problem:
PR #1944 introduced a nonstandard function call isnan() which breaks compilation for compilers which don't support this extension.

Solution:
A potential alternative is to use the ieee_is_nan() call from ieee_arithmetic. As there is conditional compilation of this module which requires Fortran 2003 standard, an easier alternative is just to check the input values before calling acos()

@islas islas requested a review from a team as a code owner June 7, 2024 19:15
@weiwangncar
Copy link
Collaborator

The regression test results:

Test Type              | Expected  | Received |  Failed
= = = = = = = = = = = = = = = = = = = = = = = =  = = = =
Number of Tests        : 23           24
Number of Builds       : 60           57
Number of Simulations  : 158           150        0
Number of Comparisons  : 95           86        0

Failed Simulations are: 
None
Which comparisons are not bit-for-bit: 
None

weiwangncar
weiwangncar previously approved these changes Aug 7, 2024
@mgduda mgduda self-requested a review September 11, 2024 21:04
Copy link
Collaborator

@mgduda mgduda left a comment

Choose a reason for hiding this comment

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

As a final comment, I wonder whether the original code is correct? Would setting angle = pi be better when tmp1 / tmp2 is less than -1?

phys/module_wind_mav.F Outdated Show resolved Hide resolved
phys/module_wind_mav.F Outdated Show resolved Hide resolved
phys/module_wind_mav.F Outdated Show resolved Hide resolved
@islas
Copy link
Collaborator Author

islas commented Sep 12, 2024

As a final comment, I wonder whether the original code is correct? Would setting angle = pi be better when tmp1 / tmp2 is less than -1?

I'm unsure. That does make sense, but I was hesitant to modify the logic in a way that deviates from the original. Since the final result is a logical, there are probably more implications [than I understand] based on what a close-to or actual out of bounds evaluation should be.

@mgduda
Copy link
Collaborator

mgduda commented Sep 13, 2024

Agreed that we shouldn't try to "correct" the computation, as we may be missing some important details.

As a final comment, I'd suggest trying to match the whitespace convention used in the rest of the find_turb: four spaces of indentation, and no space between the parentheses in conditional statements.

@islas
Copy link
Collaborator Author

islas commented Sep 13, 2024

trying to match the whitespace convention used in the rest of the find_turb: four spaces of indentation, and no space between the parentheses in conditional statements.

Fixed, though I do wish we had a format checker, as a significant portion of the file's code (and the original logic that this PR replaces) don't follow this.

@mgduda mgduda self-requested a review September 13, 2024 00:39
@islas islas merged commit 59d1ab1 into wrf-model:release-v4.6.1 Sep 13, 2024
1 of 2 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.

3 participants