Modern Fortran has many ways to declare variables. Elements declared simply will exist throughout the life of the object. Thus, "real, dimension (N) :: array" declared in the procedure will automatically disappear when this procedure returns. Naturally, variables declared in the main program or module variables or general (obsolete) will be stored throughout the program.
Variables can be dynamically allocated using "allocate" (for this they must be declared using the allocatable attribute). Because Fortran 95 distributed variables that are local to the procedure are automatically freed when the procedure returns! They will not leak memory! (Some programmers may find it good practice to explicitly free variables anyway, even if this is not strictly necessary.) (Of course, you can waste memory in the sense that you do not explicitly free a variable that you know needs more.)
Possible memory leak by pointers. You can allocate memory with a pointer, and then assign a pointer to another variable, losing the previous link. If you do not free memory, you have a leak. There is less need for pointers in Fortran than in some other languages ... much can be done with distributed variables that are safer - there are no memory leaks.
Related questions: Fortran> resource retention time and ALLOCATABLE arrays or POINTER arrays?
source share