The END statement signals the end of a program unit.
SyntaxEND [class [name]]Where:
class is eitherPROGRAM, FUNCTION, SUBROUTINE, MODULE, or BLOCK DATA
name is the name of the program unit.
Executing an END statement within a function or subroutine is equivalent to executing a RETURN statement.
Executing an END statement within a main program unit terminates execution of the program.
Each program unit, module subprogram, or internal subprogram must have exactly one END statement.
If the program unit is a module procedure or an internal subprogram, class is required.
name can be used only if a name was given to the program unit in a PROGRAM, FUNCTION, SUBROUTINE, MODULE, or BLOCK DATA statement.
If name is present, it must be identical to the name specified in the PROGRAM, FUNCTION, SUBROUTINE, MODULE or BLOCK DATA statement.
The END PROGRAM, END FUNCTION, and END SUBROUTINE statements are executable and can be branch target statements.
The END MODULE, and END BLOCK DATA statements are non-executable.
Examplemodule mod1 contains subroutine modsub() end subroutine ! program class is required on module proc end module ! "module" is optional program endtest use mod1 call sub1() call modsub() call intsub() contains subroutine intsub() end subroutine ! "subroutine" for internal procedure end program endtest ! "program" and "endtest" are optional subroutine sub1() end