-
Notifications
You must be signed in to change notification settings - Fork 137
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
Conversation
axis_utils/include/axis_utils2.inc
Outdated
NEAREST_INDEX_ = 1 | ||
return | ||
elseif (rval > array(ia)) then | ||
elseif (rval .gt. array(ia)) then |
There was a problem hiding this comment.
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.
axis_utils/include/axis_utils2.inc
Outdated
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 |
There was a problem hiding this comment.
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?
@bensonr I think i addressed your comments. Let me know if the logic doesn't seem correct. |
There was a problem hiding this 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.
Description
Improves performance of
nearest_index
Fixes #1444
How Has This Been Tested?
CI
Checklist:
make distcheck
passes