Developer Guide and Reference

ID 767251
Date 10/31/2024
Public
Document Table of Contents

Names

Names identify entities within a Fortran program unit (such as variables, function results, common blocks, named constants, procedures, program units, namelist groups, and dummy arguments). In FORTRAN 77, names were called "symbolic names".

A name can contain letters, digits, underscores ( _ ), and the dollar sign ($) special character. The first character must be a letter or a dollar sign.

In Fortran 2008 and later, a name can contain up to 63 characters.

The length of a module name (in MODULE and USE statements) may be restricted by your file system.

NOTE:

Be careful when defining names that contain dollar signs. A dollar sign can be a symbol for command or symbol substitution in various shell and utility commands.

In an executable program, the names of the following entities are global and must be unique in the entire program:

  • Program units

  • External procedures

  • Common blocks

  • Modules

Examples

The following examples demonstrate valid and invalid names:

Valid Names

NUMBER

FIND_IT

X

Invalid Names

5Q

Begins with a numeral.

B.4

Contains a special character other than _ or $.

_WRONG

Begins with an underscore.

The following are all valid examples of using names:

 
 INTEGER (SHORT) K       ! K names an integer variable, 
                         !    SHORT is a named constant
 SUBROUTINE EXAMPLE      ! EXAMPLE names the subroutine
 LABEL: DO I = 1,N       ! LABEL names the DO block