ナビゲーション:
前へ 上へ 次へ
8.1
Fortran 95プログラム構造
このセクションにはFortran 95プログラムの構造に関する簡単な参照ガイドが
含まれています。
数式については次のセクションに記述されています。
-
構文要素の定義は‘::=’によって表されます。
-
イタリック体の名前(例えば‘expr’ )は構文要素名です。
-
‘[ ]’中の項目は省略可能です。
-
省略符号‘...’は直前の項目の省略可能な繰返しを意味します。
-
‘{’と‘}’はグルーピングにのみ使用されます。
-
‘|’で区分された項目はその中のどれか一つという選択を表します。
-
‘-stmt’で終わる文はセクション
“Fortran 95ステートメント”に記述されています。
INCLUDE行
INCLUDE行は次の形式を取ります:
INCLUDE char-literal-constant
char-literal-constant はアクセス可能なパス名でなくてはならず、
kind-param を取ることはできません。相対パス名の場合には現行のワーキング
ディレクトリ、及び
-I オプションで指定されたすべてのディレク
トリに対してサーチが行われます。
INCLUDE行は実効的に指定されたファイルの内容によって置き換えられます。
プログラム単位の構造
| program-unit ::= | main-program | module | procedure | block-data-subprogram |
| main-program ::= | [ program-stmt ] |
| | body |
| | end-program-stmt |
| body ::= | declaration-section |
| | [ executable-section ] |
| | [ contains-section ] |
注:contains-section は内部手続き中では使用できません(内部手続き
とは別の手続きのcontains-section 中に配置される手続きのことを言い
ます)。
| 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 |
注:do-stmt が終端ラベルを指定している場合、do-ending はそのラベ
ルを持った文であり、goto-stmt, return-stmt, stop-stmt,
exit-stmt, cycle-stmt, arithmetic-if-stmt やEND文で
あってはなりません。
do-stmtが終端ラベルを指定していない場合には、do-ending は
enddo-stmt でなくてはなりません。