Fortran Program units and file layout Internal subprograms

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9

Example

A program unit which is not an internal subprogram may contain other program units, called internal subprograms.

program prog
  implicit none
contains
  function f()
  end function f
  subroutine g()
  end subroutine g
end program

Such an internal subprogram has a number of features:

  • there is host association between entities in the subprogram and the outer program
  • implicit typing rules are inherited (implicit none is in effect in f above)
  • internal subprograms have an explicit interface available in the host

Module subprograms and external subprograms may have internal subprograms, such as

module mod
  implicit none
contains
  function f()
  contains
    subroutine s()
    end subroutine s
  end function f
end module mod


Got any Fortran Question?