This section contains a quick reference guide to the structure of a Fortran 95 program.
Expressions are described in the next section.
INCLUDE line has the form:
INCLUDE char-literal-constant
INCLUDE line is effectively replaced by the contents of the named
file.
| program-unit ::= | main-program | module | procedure | block-data-subprogram |
| main-program ::= | [ program-stmt ] |
| body | |
| end-program-stmt |
| body ::= | declaration-section |
| [ executable-section ] | |
| [ contains-section ] |
Note: A contains-section cannot appear in an internal procedure (an internal procedure is a procedure in the contains-section of another procedure).
| contains-section ::= | contains-stmt |
| procedure... |
| module ::= | module-stmt |
| [ declaration-section ] | |
| [ contains-section ] | |
| end-module-stmt |
| procedure ::= | function-subprogram | subroutine-subprogram |
| function-subprogram ::= | function-stmt |
| body | |
| end-function-stmt |
| subroutine-subprogram ::= | subroutine-stmt |
| body | |
| end-subroutine-stmt |
| block-data-subprogram ::= | block-data-stmt |
| declaration-section | |
| end-block-data-stmt |
| declaration-section ::= | [ use-stmt... ] |
| [ implicit-part... ] | |
| [ declaration... ] |
| implicit-part ::= | implicit-stmt | parameter-stmt | format-stmt | entry-stmt |
| declaration ::= | derived-type-definition | interface-block | declarative | |
| format-stmt | entry-stmt |
| declarative ::= | allocatable-stmt | common-stmt | data-stmt | dimension-stmt | |
| equivalence-stmt | external-stmt | intent-stmt | intrinsic-stmt | namelist-stmt | | |
| optional-stmt | parameter-stmt | pointer-stmt | private-stmt | public-stmt | | |
| save-stmt | statement-function-stmt | target-stmt | type-declaration-stmt |
| derived-type-definition ::= | type-stmt |
| component-def-stmt... | |
| end-type-stmt |
| interface-block ::= | interface-stmt |
| { interface-body | module-procedure-stmt } ... | |
| end-interface-stmt |
| interface-body ::= | function-stmt declaration-section end-function-stmt | |
| subroutine-stmt declaration-section end-subroutine-stmt |
| executable-section ::= [ executable | executable-construct | data-stmt ]... |
| executable ::= | allocate-stmt | arithmetic-if-stmt | assignment-stmt | backspace-stmt | call-stmt | |
| close-stmt | computed-goto-stmt | continue-stmt | cycle-stmt | deallocate-stmt | |
| | endfile-stmt | exit-stmt | forall-stmt | goto-stmt | if-stmt | inquire-stmt | | |
| nullify-stmt | open-stmt | pause-stmt | pointer-assignment-stmt | print-stmt | | |
| read-stmt | return-stmt | rewind-stmt | stop-stmt | where-stmt | write-stmt |
| executable-construct ::= | select-case-construct | do-loop | forall-construct | if-construct | |
| where-construct |
| select-case-construct ::= | select-stmt |
| [ case-stmt executable-section ] ... | |
| end-select-stmt |
| if-construct ::= | if-then-stmt |
| [ executable-section ] | |
| [ elseif-stmt executable-section ] ... | |
| [ else-stmt executable-section ] | |
| endif-stmt |
| where-construct ::= | where-construct-stmt |
| where-body | |
| [ elsewhere-stmt where-body ] | |
| endwhere-stmt |
| where-body ::= | [ where-assignment-stmt | where-stmt | where-construct | |
| elsewhere-mask-stmt ] ... |
| forall-construct ::= | forall-construct-stmt |
| forall-body | |
| end-forall-stmt |
| forall-body ::= | [ forall-assignment-stmt | where-stmt | where-construct | forall-stmt | |
| forall-construct ] ... |
| do-loop ::= | do-stmt |
| executable-section | |
| do-ending |
| do-ending ::= enddo-stmt | executable |
Note:
If the do-stmt specifies a terminating label, the do-ending is
the statement with that label and shall not be a goto-stmt,
return-stmt, stop-stmt, exit-stmt, cycle-stmt,
arithmetic-if-stmt or any form of END statement.
If the do-stmt does not specify a terminating label, the do-ending
shall be an enddo-stmt.