Clicky

Fortran Wiki
elemental (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 (追記ここまで)

Elemental Procedures

Elemental functions are defined as scalar operators, with a single scalar dummy argument and a scalar return value, but they may be invoked with arrays as actual arguments in which case the function will be applied element-wise, with a conforming array return value. Such functions must also be pure functions, with no side effects, and can be indicated with the elemental prefix. Since it is implied that an elemental function is also pure,(削除) so (削除ここまで) thepure prefix is not necessary.

Elemental subroutines may be defined in a similar way, however, side effects are permitted for intent(out) or intent(inout) arguments.

The main benefit of elemental procedures is that advance knowledge that a function is elemental simplifies parallel execution.

Example

module test_mod
 implicit none
contains
 elemental real function square(x)
 real, intent(in) :: x
 square = x*x
 end function
end module
program test_prog
 use test_mod
 implicit none
 real, dimension(3) :: x = (/ 1.0, 2.0, 3.0 /)
 print *, square(x)
end program
Revised on September 25, 2012 11:03:01 by Anonymous Coward (134.134.139.74) (1203 characters / 0.0 pages)
Edit | Back in time (1 revision) | Hide changes | History | Views: Print | TeX | Source | Linked from: Keywords, procedure

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