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
assign linspaced values to an array slice throws an error in fortran #1212
Comments
your code give me an error in python :
different shapes |
i have added The problem is we always correct the last element of the generated array to match the end value, in fortran when we try to correct the last element using this python function :
translated to this fortran function:
this case is not handled in |
Duplicate of #1218 |
This PR is not quite a duplicate. On the devel branch the following code is generated: module issue_1212
use, intrinsic :: ISO_C_Binding, only : i64 => C_INT64_T , f64 => &
C_DOUBLE
implicit none
contains
!........................................
subroutine func(n, arr)
implicit none
real(f64), allocatable, intent(out) :: arr(:)
integer(i64), value :: n
integer(i64) :: p
integer(i64) :: linspace_index
p = FLOOR(n/3.0_f64,i64)
allocate(arr(0:n - 1_i64))
arr = 0.0_f64
arr(p - 1_i64:n - p - 1_i64) = [((0_i64 + linspace_index*Real((1_i64 &
- 0_i64), f64) / Real((p - 1_i64), f64)), linspace_index = &
0_i64,p - 1_i64)]
arr(p - 1_i64, p - 1_i64:n - p - 1_i64) = 1.0_f64
return
end subroutine func
!........................................
end module issue_1212 which generates the compiler error:
This code is wrong as it corresponds to |
Describe the bug
assigning linspaced values to an array is working fine, but to a slice of an array throws an error in Fortran.
To Reproduce
but this succeeds:
The error message:
A clear and concise description of what you expected to happen.
Language
Fortran
The text was updated successfully, but these errors were encountered: