Fortran Program units and file layout External procedures

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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?