Skip to content

Instantly share code, notes, and snippets.

@alanbriolat
Created February 8, 2012 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanbriolat/1763237 to your computer and use it in GitHub Desktop.
Save alanbriolat/1763237 to your computer and use it in GitHub Desktop.
gfortran matrix multiplication result size bug
program foo
real, parameter :: A(2, 3) = reshape((/ 0, 0, 0, 0, 0, 0 /), (/ 2, 3 /))
real, parameter :: B(2) = (/ 0, 0 /)
real, parameter :: C(3) = matmul(B, A)
! 1
!Error: Different shape for array assignment at (1) on dimension 1 (3 and 2)
!f951: internal compiler error: in gfc_simplify_reshape, at fortran/simplify.c:5104
! This works in some versions of gfortran:
real, parameter :: D(3) = reshape(matmul(B, A), (/ 3 /))
! Others give:
!f951: internal compiler error: in gfc_simplify_reshape, at fortran/simplify.c:5104
! This outputs 3 values:
print *, matmul(B, A)
end program foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment