Clicky

Fortran Wiki
procedure (Rev #2, changes)

Skip the Navigation Links | Home Page | All Pages | Recently Revised | Authors | Feeds | Export |

Showing changes from revision #1 to #2: (追記) Added (追記ここまで) | (削除) Removed (削除ここまで) | (削除) Chan (削除ここまで)(追記) ged (追記ここまで)

Procedures

Fortran offers two different procedures: function and subroutine.

(追記) (追記ここまで)(追記)

Subroutine

(追記ここまで)
(追記) (追記ここまで)(追記)

A subroutine looks similar to a program except that it also takes input parameters. It is invoked by a oneline command call.

(追記ここまで)
(追記) (追記ここまで)(追記)

Outline

(追記ここまで)
(追記) (追記ここまで)(追記)
<keywords> subroutine <name> (<parameters>)
 <statements> 
end subroutine <name>
(追記ここまで)
(追記) (追記ここまで)(追記)

Invocation

(追記ここまで)
(追記) (追記ここまで)(追記)
...
 call <subroutine_name>(<parameters>)
...
(追記ここまで)
(追記) (追記ここまで)(追記)

Parameter intents

(追記ここまで)
(追記) (追記ここまで)(追記)

Each parameter must have its intent declared. The intent shows what the subroutine can do with each parameter. Possible intents are: in, out, inout.

(追記ここまで)
(追記) (追記ここまで)(追記)
  • in: The parameter will have an initial value and its value is not allowed to change.
  • out: The parameter will not have an initial value and one can set its value. The parameter retains the final value even after the procedure has ended.
  • inout (can also we written as in out): An initial value is set and one can change its value. The parameter retains the final value even after the procedure has ended.
(追記ここまで)
(追記) (追記ここまで)(追記)

Additionally, one can set the value attribute. This allows the parameter to be changed inside of the procedure but the after its end the parameter will change back to its original value. This is useful for describing C functions.

(追記ここまで)
(追記) (追記ここまで)(追記)

Keywords

(追記ここまで)
(追記) (追記ここまで)(追記)

Recursive

(追記ここまで)
(追記) (追記ここまで)(追記)

Only procedures with the keyword recursive are permitted to call themselves.

(追記ここまで)
(追記) (追記ここまで)(追記)

Elemental

(追記ここまで)
(追記) (追記ここまで)(追記)

For easy vectorization use the keyword elemental. See also elemental.

(追記ここまで)
(追記) (追記ここまで)(追記)

Pure

(追記ここまで)
(追記) (追記ここまで)(追記)

The pure keyword indicates that the procedure has no side effects, e.g. does not alter gloabl variables, or prints messages.

(追記ここまで)
Revision from July 3, 2018 14:56:15 by Mr Blue?
Forward in time (to current) | Back in time (1 more) | See current | Hide changes | History | Rollback | View: Source | Linked from: Keywords

AltStyle によって変換されたページ (->オリジナル) /