Coarray Examples

Small Coarray examples.

Some random collection of examples can be found at "Examples/test files" at http://users.physik.fu-berlin.de/~tburnus/coarray/README.txt

Examples from the testsuite

To check the correctness of the compiler, some coarray tests have been added. The main purpose is to check the diagnostics of the compiler (for invalid code) and the compile and run-time correctness. As such, the programs might be invalid (e.g. missing initialization for compile-time only tests) or incomplete. On the other hand, they might illustrate the use for some more special functions. They are located in the gfortran.dg/coarray/ directory and in files starting with coarray_ in the gcc/testsuite/gfortran.dg/ directory.

Hello World

A small program, which illustrates how to use coarrays

! Created by Tobias Burnus 2010.

program Hello_World
  implicit none
  integer :: i  ! Local variable
  character(len=20) :: name[*] ! scalar coarray
  ! Note: "name" is the local variable while "name[<index>]"
  ! accesses the variable on a remote image
 
  ! Interact with the user on Image 1
  if (this_image() == 1) then
    write(*,'(a)',advance='no') 'Enter your name: '
    read(*,'(a)') name
 
    ! Distribute information to other images
    do i = 2, num_images()
      name[i] = name
    end do
  end if
 
  sync all ! Barrier to make sure the data has arrived
 
  ! I/O from all nodes
  write(*,'(3a,i0)') 'Hello ',trim(name),' from image ', this_image()
end program Hello_world

None: CoarrayExample (last edited 2011-05-03 16:35:20 by TobiasBurnus)