Fortran Wiki


Returns the number of images.


Fortran 2008 and later. With distance or failed argument, TS 18508 or later


Transformational function


result = num_images(distance, failed)


  • distance - (optional, intent(in)) Nonnegative scalar integer
  • failed - (optional, intent(in)) Scalar logical expression

Return value

Scalar default-kind integer. If distance is not present or has value 0, the number of images in the current team is returned. For values smaller or equal distance to the initial team, it returns the number of images index on the ancestor team which has a distance of distance from the invoking team. If distance is larger than the distance to the initial team, the number of images of the initial team is returned. If failed is not present the total number of images is returned; if it has the value .true., the number of failed images is returned, otherwise, the number of images which do have not the failed status.


integer :: value[*]
integer :: i
value = this_image()
sync all
if (this_image() == 1) then
  do i = 1, num_images()
    write(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
  end do
end if

See also

this_image, image_index

category: intrinsics