https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88124
--- Comment #2 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> --- See https://gcc.gnu.org/ml/fortran/2018-11/msg00101.html For further explanation of problem. I found that when I placed the content of sub.F into main.f with the contains, that it gave the correct results.