"end program hello" vs "end program"

See the following code snippet:

program hello
    implicit none

    print *, "Hello World!"
end program hello

About the last line used above, it seems that both of the following usages are valid:

end program hello

and

end program

Which one is preferable?

Regards,
HZ

I think it’s purely a matter of taste. The program name presumably says something about what the program does. Are you willing to type a few characters at the end to remind the reader what program it is? I am.

For functions and subroutines there is a stronger case for end function name and
end subroutine name, since a file could contain many procedure definitions, and providing the name clarifies what procedure is being terminated. Some people provide the procedure name at the end only when the procedure becomes long.

3 Likes

Got it. Thank you for your explanation.