Fortran Data Types Declaration and attributes


Throughout the topics and examples here we'll see many declarations of variables, functions and so on.

As well as their name, data objects may have attributes. Covered in this topic are declaration statements like

integer, parameter :: single_kind = kind(1.)

which gives the object single_kind the parameter attribute (making it a named constant).

There are many other attributes, like

  • target
  • pointer
  • optional
  • save

Attributes may be specified with so-called attribute specification statements

integer i    ! i is an integer (of default kind)...
pointer i    ! ... with the POINTER attribute...
optional i   ! ... and the OPTIONAL attribute

However, it is generally regarded to be better to avoid using these attribute specification statements. For clarity the attributes may be specified as part of a single declaration

integer, pointer, optional :: i

This also reduces the temptation to use implicit typing.

In most cases in this Fortran documentation this single declaration statement is preferred.