https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61928
--- Comment #6 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> --- My thinking, right or wrong, is that the code is invalid because idamax is defined as an integer which conflicts with the subroutine name. Ifort gives the exact same error. (Ifort also insists that the end statements for the function and subroutine state "end function" and "end subroutine" but that is a separate issue.)