Open
Description
From F95 standard (this can be inside of a main program or a subprogram):
R210 internal-subprogram-part is contains-stmt
internal-subprogram
[internal-subprogram] ...
Also see Intel Developer Zone example. Basically, you can specify a nested procedure inside another procedure or main program using CONTAINS
. A toy example:
$ cat internal.f90
subroutine s(x)
integer x
call s2(x)
contains
subroutine s2(y)
integer y
end subroutine
end subroutine
$ gfortran -fsyntax-only internal.f90
$ fort -fsyntax-only internal.f90
internal.f90:4:11: error: expected '='
contains
^
internal.f90:5:16: error: expected '='
subroutine s2(y)
^
internal.f90:6:15: error: expected '='
integer y
^
internal.f90:8:1: error: expected 'end program'
end subroutine
^
<unknown>:0: note: to match this 'program'
$