Fortran Program units and file layout External procedures

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

Example

An external procedure is one which is defined outside another program unit, or by a means other than Fortran.

The function contained in a file like

integer function f()
  implicit none
end function f

is an external function.

For external procedures, their existence may be declared by using an interface block (to given an explicit interface)

program prog
  implicit none
  interface
    integer function f()
  end interface
end program prog

or by a declaration statement to give an implicit interface

program prog
  implicit none
  integer, external :: f
end program prog

or even

program prog
  implicit none
  integer f
  external f
end program prog

The external attribute is not necessary:

program prog
  implicit none
  integer i
  integer f
  i = f()   ! f is now an external function
end program prog


Got any Fortran Question?