Designing Subroutines

Syntax

A Function receives some input via its formal arguments from outside world and computes and returns one value, the function value, with the function name. In some cases, you do not want to return any value or you may want to return more than one values. Then, Fortran's subroutines are what you need. Functions and subroutines are referred to as subprograms. The syntax of a Fortran subroutine is:
SUBROUTINE  subroutine-name (arg1, arg2, ..., argn)
   IMPLICIT  NONE
   [specification part]
   [execution part]
   [subprogram part]
END SUBROUTINE  subroutine-name

Here are some elaborations of the above syntax:

If a subroutine does not need any formal argument, it can be written as
SUBROUTINE  subroutine-name ()
   IMPLICIT  NONE
   [specification part]
   [execution part]
   [subprogram part]
END SUBROUTINE  subroutine-name
where arg1, arg2, ..., argn are left out.

Unlike functions, the pair of parenthesis can be removed:

SUBROUTINE  subroutine-name
   IMPLICIT  NONE
   [specification part]
   [execution part]
   [subprogram part]
END SUBROUTINE  subroutine-name

Semantics

The meaning of a subroutine is very simple: