NUM_IMAGES (The GNU Fortran Compiler)

### 8.219 `NUM_IMAGES` — Function that returns the number of images ¶

Synopsis:

  `RESULT = NUM_IMAGES([TEAM])`
  `RESULT = NUM_IMAGES(TEAM_NUMBER)`

Description:

  Returns the number of images in the current team or the given team.

Class:

  Transformational function

Arguments:

  TEAM | (optional, intent(in)) If present, return the number of images in the given team; if absent, return the number of images in the current team.
  TEAM_NUMBER | (intent(in)) The number as given in the `FORM TEAM` statement.

Return value:

  Scalar default-kind integer. Can be called without any arguments or a team type argument or a team_number argument.

Example:

      use, intrinsic :: iso_fortran_env
      INTEGER :: value[*]
      INTEGER :: i
      type(team_type) :: t

      ! When running with 4 images
      print *, num_images() ! 4

      form team (mod(this_image(), 2), t)
      print *, num_images(t) ! 2
      print *, num_images(-1) ! 4

Standard:

  Fortran 2008 and later. With TEAM or TEAM_NUMBER argument, Fortran 2018 and later.

See also:

  `THIS_IMAGE` — Function that returns the cosubscript index of this image,
  `IMAGE_INDEX` — Function that converts a cosubscript to an image index