Almost every Fortran compiler since the 1960s has added to the language, and a great deal of real source code uses the additions. Most of the old ones came from IBM, Cray and above all DEC (VAX FORTRAN, later Compaq and Intel Fortran).
The standards adopted some of them (the bit procedures, DO WHILE, END DO, INCLUDE, IMPLICIT NONE, NAMELIST) and left others out. This page lists them, with the GNU Fortran option that controls each where there is one.
Old-style sizes and initial values
integer*4 i, j
real*8 x(100)
complex*16 z
logical*1 flag
character*20 name
integer i /0/, j /1/ ! initial values between slashes
byte b
type*n gives the size in bytes (a kind number in most compilers): integer*2, integer*4, integer*8, real*4, real*8, real*16, complex*8, complex*16, complex*32, logical*1, logical*4. character*n is the one standard form
(obsolescent). A slash list after a name in a declaration is an initial value, like data. byte is a one-byte integer. The viewer colours the type word as a type and the size as a number.
VAX and DEC Fortran
- Structures:
structure /name/ … end structuredefines a record layout;record /name/ vardeclares one;unionandmapoverlay fields;var.fieldselects a field (GNU Fortran with-fdec-structure) - Tab format and D lines: see Fixed source form
%VAL,%REF,%LOC,%DESCRin an argument list: pass by value, by reference, the address, or by descriptor. The viewer colours them as functions- statements:
accept,type(asprint),encode,decode,rewrite,delete,find,virtual,automatic,static,options,implicit undefined,parameter name = valuewith no parentheses - operators and constants:
.xor., logical operators on integers (bitwise),'FF'X,'777'Osuffix constants,$in names,1.0Q0quad exponent,NAMELISTwith$group … $end - integer intrinsic variants:
biand,iiand,jiand,kiandand the like for each integer size, andizext,jzext - directives:
!DEC$ ATTRIBUTES,!DEC$ FREEFORM,!DEC$ IF DEFINED - I/O:
carriagecontrol=,readonly,shared,defaultfile=,dispose=and indexed and relative files
GNU Fortran collects these under -fdec, with the parts -fdec-structure, -fdec-intrinsic-ints, -fdec-static, -fdec-include, -fdec-char-conversions, -fdec-format-defaults, -fdec-blank-format-item and -fd-lines-as-code / -fd-lines-as-comments.
Cray pointers
real :: work(100)
pointer (ptr, pte) ! pte is a variable located at the address in ptr
real :: pte(100)
ptr = loc(work)
pte(5) = 1.0 ! changes work(5)
A Cray pointer holds an address and a pointee is the variable placed at it. They are the pre-Fortran 90 way to dynamic memory (together with malloc). GNU Fortran needs -fcray-pointer. The viewer colours the statement as a pointer statement, with the names plain.
Hollerith
Hollerith constants (4HABCD) are described under Lexical structure. Compilers still accept them in data statements, as actual arguments and as values assigned to numeric variables
(the integer or real then holds the character codes, left-justified and padded), which is how FORTRAN 66 and 77 programs handled text.
The extensions GNU Fortran lists
The GNU Fortran manual has a chapter “Extensions implemented in GNU Fortran” with these sections. All are accepted by default (-std=gnu) and refused or warned about under -std=f2018 and similar:
| Extension | What it allows |
|---|---|
| Old-style kind specifications | integer*4 and friends, above |
| Old-style variable initialization | initial values in slashes after a name |
| Extensions to namelist | additional input forms and $ group delimiters |
| X format descriptor without count field | X alone means 1X |
| Commas in FORMAT specifications | commas where the standard forbids them |
| Missing period in FORMAT specifications | F10 for F10.0 and similar |
| Default widths for F, G and I format descriptors | F, G, I with no width (-fdec-format-defaults) |
| I/O item lists | some forms of items the standard does not accept |
| Q exponent-letter | 1.5q0 for quad precision |
| BOZ literal constants | suffix forms ('FF'X), X as a letter, and BOZ constants in more places |
| Real array indices | a real expression as a subscript, truncated |
| Unary operators | a sign after another operator: a * -b |
| Implicitly convert LOGICAL and INTEGER values | a logical where an integer is wanted, and the reverse |
| Hollerith constants support | 4HABCD |
| Character conversion | a character literal assigned to a numeric variable (-fdec-char-conversions) |
| Cray pointers | pointer (ptr, pointee) |
| CONVERT specifier | convert= in open for the byte order of unformatted files |
| OpenMP, OpenACC | directives; see Directives and preprocessor |
| Argument list functions %VAL, %REF and %LOC | how an argument is passed |
| Read/Write after EOF marker | continuing after the end of a file |
| STRUCTURE and RECORD, UNION and MAP | DEC records |
| Type variants for integer intrinsics | biand, iiand … |
| AUTOMATIC and STATIC attributes | storage class |
| Form feed as whitespace | Ctrl-L between tokens |
| TYPE as an alias for PRINT | type *, x |
| %LOC as an rvalue | the address used as a value |
| .XOR. operator | exclusive or |
| Bitwise logical operators | .and., .or., .not., .xor. on integers |
| Extended I/O specifiers | carriagecontrol=, readonly, shared and others |
| Legacy PARAMETER statements | parameter x = 1 |
| Default exponents | a form of exponent that leaves out parts the standard requires |
| Unsigned integers | an experiment (-funsigned); not in the standard |
The table gives the headings of the manual’s chapter; the explanations are the writer’s summaries and a few are short where the manual page could not be opened (I/O item lists, Default exponents). The manual (gcc.gnu.org) is the reference.
Switching to a standard
GNU Fortran’s -std= takes f95, f2003, f2008, f2018, f2023, gnu (the default, which allows the extensions) and legacy (which also allows old code with errors the standard forbids). -std=f202y turns on proposals for the next
revision. -fall-intrinsics, -fallow-argument-mismatch, -fallow-invalid-boz, -fbackslash, -fdollar-ok, -fimplicit-none, -fdefault-real-8 and -fmax-identifier-length=n adjust single rules. Intel Fortran has -stand f18 (and f15, f08, f03, f95, f90)
to warn about non-standard code.
What the viewer does with extensions
integer*4 i,real*8 x,byte,double complex: typesstructure,end structure,record,union,mapand their ends: keywords%val,%ref,%loc,%descras arguments: functions'FF'X,'777'O,'101'B,x'1f': numbers, when the digits fit the base1.0q0: number;.xor.and any other.word.: keyword operatorsaccept,encode,decode,automatic,static,virtual: keywords at the start of a statement!DEC$,!DIR$,!GCC$,CDIR$,@PROCESSand the OpenMP sentinels: directives- the field separator
.of DEC records is left plain, and a statement such asa.b = 1is read as an assignment