No, actually in your example you haven't declared it a real function
inside the program, but it's an external function to the program. If you defined your function inside the program, as follows, or put it in a module
and use
d it, you wouldn't have to specify it's a real function
twice.
program functiontest
implicit none
real :: x
print *, "Enter a number to square"
read (*,*) x
print *, square(x)
contains
real function square(x)
real :: x
square = x * x
end function square
end program functiontest
As for why it also works the way you wrote it, it is for backwards compatibility with Fortran 77.