Co-array Fortran

from Wikipedia, the free encyclopedia
Coarray Fortran
Paradigms : procedural , imperative , structured , object-oriented , parallel
Publishing year: 1990s
Developer: Robert Numrich and John Reid
Current  version : Fortran 2008 (ISO / IEC 1539-1: 2010)   ()
Important implementations : Cray, g95 , gfortran , ifort
Influenced by: Fortran

Co-array Fortran (CAF), formerly F-- , is an extension of the Fortran 95/2003 programming language for parallel data processing , which was developed by Robert Numrich and John Reid in the 1990s. The Fortran standard supports coarrays (now without the hyphen) since Fortran 2008 (ISO / IEC 1539-1: 2010), as decided at the May 2005 meeting of the ISO Fortran committee; the syntax in the Fortran 2008 standard differs slightly from the original CAF proposal.

A Coarray Fortran program is interpreted as if it were replicated n times and all copies were executed asynchronously. Each copy has its own data objects and is called an "image". The field syntax of Fortran is extended by square brackets, which contain the picture index, with which one can access the data of another picture (process).

The Co-array Fortran extension has been around since the 1990s and is supported in some Fortran compilers such as that of Cray (from version 3.1). Since coarrays became part of Fortran in 2008, the number of implementations has increased; the first open source - compiler , which supports Coarrays 2008 standard Fortran according to that is G95 .

example

program Hallo_Welt
  implicit none
  integer :: i ! Lokale Variable
  character(len=20) :: name[*] ! skalares Coarray
  ! Hinweis: "name" ist die lokale Variable wohingegen "name[<index>]"
  ! auf die Variable eines anderen Prozesses (Image) zugreift

  ! Kommuniziere mit dem Nutzer auf Image 1
  if (this_image() == 1) then
    write(*,'(a)',advance='no') 'Geben Sie Ihren Namen ein: '
    read(*,'(a)') name

    ! Verteile die Information an die anderen Prozesse
    do i = 2, num_images()
      name[i] = name
    end do
  end if

  sync all ! Barriere damit die Daten wirklich da sind

  ! Ein-/Ausgabe von allen Prozessen
  write(*,'(3a,i0)') 'Hallo ',trim(name),' von Image ', this_image()
end program Hallo_Welt

See also

Web links