Skip to content

Instantly share code, notes, and snippets.

@krystophny
Last active May 27, 2025 10:42
Show Gist options
  • Save krystophny/71e7757096553492ca272425886e7182 to your computer and use it in GitHub Desktop.
Save krystophny/71e7757096553492ca272425886e7182 to your computer and use it in GitHub Desktop.
GFortran 15 bug
module odeint_allroutines_sub
implicit none
abstract interface
subroutine compute_derivative(x, y, dydx)
real(8), intent(in) :: x
real(8), intent(in) :: y(:)
real(8), intent(out) :: dydx(:)
end subroutine compute_derivative
end interface
contains
subroutine odeint(y, nvar, x1, x2, derivs)
integer, intent(in) :: nvar
real(8), intent(inout) :: y(nvar)
real(8), intent(in) :: x1, x2
procedure(compute_derivative) :: derivs
real(8) :: dydx(nvar)
call derivs(0d0, y, dydx)
call rkqs(derivs)
end subroutine odeint
subroutine rkqs(derivs)
procedure(compute_derivative) :: derivs
end subroutine rkqs
end module odeint_allroutines_sub
@krystophny
Copy link
Author

krystophny commented May 27, 2025

GCC GFortran 15.1.1 20250425 on Arch Linux.

gfortran -Wexternal-argument-mismatch -c issue_interface.f90

fails with

issue_interface.f90:24:18:

   24 |         call rkqs(derivs)
      |                  1
Error: Interface mismatch in dummy procedure ‘derivs’ at (1): Shape mismatch in argument 'y'

The error disappears when the warning flag is not passed, and is also triggered by -Wall in this version. Expected behavior would be warnings (if even applicable, I think the code is fine), not errors appearing. Version 14.2.1 20250207 that doesn't support -Wexternal-argument-mismatch yet works fine also with -Wall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment