Assuming you have one source file containing both the program and the subroutine as your message suggests, the easiest solution is to replace the line containing the statement
end
with line containing operator
contains
and writing at the end of the source file a line containing the statement
end program
(Yes, the program keyword is not required, but it is useful.)
The problem your compiler has reported is that since you structured your code, the program knows nothing about the interface for the memory routine, this interface is implicit in Fortran terms. When you want to call a subroutine and either pass or pass a allocated array, the subroutine must have an explicit interface.
There are several ways to provide an explicit interface. One of them, as I showed you, should contain a subroutine inside the program. Another, and more useful way, when your programs get a little big, is to write your routines in modules and use-associate them in a program that wants to use them. Read parts of your Fortran tutorial that describes module and use .
There is at least one more option, but it, especially for beginners, is not attractive, and I will not mention it here.
And while I'm writing, find out and use the intent keyword to indicate whether the argument for the subroutine, written or both, will be considered. This is great help for secure programming, your favorite Fortran resources will be explained in detail.