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

Improve the performance in nearest_index #1445

Merged
merged 3 commits into from
Jan 22, 2024

Conversation

uramirez8707
Copy link
Contributor

@uramirez8707 uramirez8707 commented Jan 18, 2024

Description
Improves performance of nearest_index

Fixes #1444

How Has This Been Tested?
CI

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

rem1776
rem1776 previously approved these changes Jan 18, 2024
axis_utils/include/axis_utils2.inc Show resolved Hide resolved
NEAREST_INDEX_ = 1
return
elseif (rval > array(ia)) then
elseif (rval .gt. array(ia)) then
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment with > going to .gt. as above.

Comment on lines 342 to 347
DO i = 1, ia
if (rval .le. array(i)) then
NEAREST_INDEX_ = i
if (array(i) -rval .gt. rval - array(i-1)) NEAREST_INDEX_ = i - 1
return
endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to make a similar change in the decreasing block?

@uramirez8707
Copy link
Contributor Author

@bensonr I think i addressed your comments. Let me know if the logic doesn't seem correct.

Copy link
Contributor

@bensonr bensonr left a comment

Choose a reason for hiding this comment

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

Make sure the unit tests checks an array and rvals less than zero and data with a mix of positive and negative elements.

@rem1776 rem1776 merged commit a08691b into NOAA-GFDL:main Jan 22, 2024
19 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.

Peformance degradation between 2023.04 and current main
3 participants