next up previous contents
Next: Comments Up: Language Elements Previous: Significant Blanks

 

Names

The Fortran language defines a number of names, or keywords, such as PRINT, INTEGER, MAX, etc. The spelling of these names is defined by the language. There are a number of entities that must be named by the programmer, such as variables, procedures, etc. These names must be chosen to obey a few simple rules. A name can consist of up to 31 alphanumeric characters (letters or digits) plus underscore. The first character in any name must be a letter. In names, upper and lower case letters are equivalent. The following are valid Fortran names,

   A, aAa, INCOME, Num1, N12O5, under_score

The following declarations are incorrect statements due to invalid names,

INTEGER :: 1A      ! does not begin with a letter
INTEGER :: A_name_made_up_of_more_than_31_letters ! too long, 38 characters 
INTEGER :: Depth:0 ! contains an illegal character ":" 
INTEGER :: A-3     ! would be interpreted as subtract 3 from A

The underscore should be used to separate words in long names

CHARACTER(LEN=12) :: user_name ! valid name
CHARACTER(LEN=12) :: username  ! different valid name

With this and the new long names facility in Fortran 90 symbolic names should be readable, significant and descriptive. It is worth spending a minute or so choosing a good name which other programmers will be able to understand.

Return to corresponding overview page gif


next up previous contents
Next: Comments Up: Language Elements Previous: Significant Blanks

©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997
Not for commercial use.