-
Notifications
You must be signed in to change notification settings - Fork 19
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
Lean on compiler #215
Lean on compiler #215
Conversation
@@ -23,7 +23,6 @@ program example | |||
real(wp), dimension(:,:), pointer :: out_data | |||
real(wp), dimension(n,m) :: expected | |||
integer :: tensor_layout(2) = [1, 2] | |||
integer :: i, j |
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.
Unused variables.
do i = 1, ndims | ||
if (i == 1) then | ||
strides(layout(i)) = 1 | ||
else | ||
strides(layout(i)) = strides(layout(i - 1)) * tensor_shape(layout(i - 1)) | ||
end if |
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.
The original version is a zero loop if ndims = 1.
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.
Good spot!
I suppose it did what was intended, but the rewrite is much more explicit and doesn't leave us open to unexpected intentions in future.
@@ -38,7 +38,7 @@ subroutine main() | |||
integer, parameter :: out_layout(out_dims) = [1, 2] | |||
|
|||
! Path to input data | |||
character(len=100) :: data_dir |
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.
Number of characters was inconsistent with number of characters for command line input.
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.
Thanks @jwallwork23 all looks sensible to me and some good catches.
Slightly worrying that the C precision was working in the old version...?
Happy for you to merge.
do i = 1, ndims | ||
if (i == 1) then | ||
strides(layout(i)) = 1 | ||
else | ||
strides(layout(i)) = strides(layout(i - 1)) * tensor_shape(layout(i - 1)) | ||
end if |
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.
Good spot!
I suppose it did what was intended, but the rewrite is much more explicit and doesn't leave us open to unexpected intentions in future.
Agreed. |
Building in debug mode with gfortran 11.4.0 on Ubuntu 22.04, I came across several warnings, most of which are fixed in this PR. They are mostly minor but the ones to do with overloaded operators are an oversight of mine from #139.