next up previous
Next: Factorial Example Up: CS101 Lecture 10 Previous: Why Functions?

Fortran Function Syntax

type FUNCTION function-name (arg1, arg2, ..., argn)
! type above is of the value returned
  IMPLICIT NONE  !! must put this
  [specification part] !! declare all vars (including arg1, ..., argn)
                ! Local vars can be used inside function
  [execution part]   !! do whatever calculatoins you need.
! last statement is typically  
!  function-name = return-value
END FUNCTION function-name



G. Sivakumar 2000-08-23