Fortran Identifiers
A Fortran identifier must satisfy the following rules:
- It has no more than 31 characters
- The first character must be a
letter,
- The remaining characters, if any, may be
letters, digits, or
underscores,
- Fortran identifiers are case insensitive. That is,
Smith, smith, sMiTh, SMiTH,
smitH are all identical identifiers.
- Correct Examples:
- MTU, MI, John, Count
- I, X
- I1025, a1b2C3, X9900g
- R2_D2, R2D2_, A__
- Incorrect Examples:
- M.T.U.: only letters, digits, and underscores
can be used
- R2-D2: same as above
- 6feet: the first character must be a letter
- _System: same as above
- Use meaningful names
- Good names: Total,
Rate,
length
- Not so good names:
ThisIsALongFORTRANname,
X321,
A_B_012cm,
OPQ
- Fortran has many keywords such as INTEGER,
REAL,
PARAMETER,
PROGRAM,
END,
IF,
THEN,
ELSE,
DO,
just name a few; however,
Fortran does not have any reserved words. More precisely,
a programmer can use these keywords as identifiers. Therefore,
END,
PROGRAM,
DO are perfectly legal Fortran
identifiers. However, this is definitely not a good
practice.
Except for
strings, Fortran 90 is
case sensitive. Therefore, identifier Name is identical to
name, nAmE, NAme, NamE and namE.
Similarly, PROGRAM is identical to program, PROgram,
and progRAM. In this course, all keywords such as
PROGRAM,
READ,
WRITE and
END are in upper case and other
identifiers use mixed cases.