Clicky

Fortran Wiki
count (Rev #3, changes)

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

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

Description

count(mask [, dim [, kind]]) counts the number of .true. elements of mask along the dimension of dim. If dim is omitted(削除) it (削除ここまで)(追記) then (追記ここまで)(追記) the (追記ここまで)(追記) number (追記ここまで)(追記) of (追記ここまで)(追記) ‘.true.’ (追記ここまで) is(削除) taken (削除ここまで)(追記) counted (追記ここまで)(削除) to (削除ここまで)(追記) over (追記ここまで)(削除) be (削除ここまで)(追記) the (追記ここまで)(追記) entire (追記ここまで)(追記) array. (追記ここまで)(削除) 1 (削除ここまで)(削除) . (削除ここまで)dim is a scaler of type integer in the range of 1 \\leq \\text{DIM} \\leq n) where n1 \\n is the rank of mask.

Standard

Fortran 95 and later, with kind argument Fortran 2003 and later

Class

Transformational function

Syntax

result = count(mask [, dim [, kind]])

Arguments

  • mask - The type shall be logical.
  • dim - (Optional) The type shall be integer.
  • kind - (Optional) An integer initialization expression indicating the kind parameter of the result.

Return value

The return value is of type integer and of kind kind. If kind is absent, the return value is of default integer kind. The result has a rank equal to that of mask.

Example

program test_count
 integer, dimension(2,3) :: a, b
 logical, dimension(2,3) :: mask
 a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /))
 b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /))
 print '(3i3)', a(1,:)
 print '(3i3)', a(2,:)
 print *
 print '(3i3)', b(1,:)
 print '(3i3)', b(2,:)
 print *
 mask = a.ne.b
 print '(3l3)', mask(1,:)
 print '(3l3)', mask(2,:)
 print *
 print '(3i3)', count(mask)
 print *
 print '(3i3)', count(mask, 1)
 print *
 print '(3i3)', count(mask, 2)
end program test_count

category: intrinsics

Revision from May 3, 2014 18:41:35 by True Believer?
Forward in time (to current) | Back in time (2 more) | See current | Hide changes | History | Rollback | View: Source | Linked from: Intrinsic procedures

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