Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Co-arrays #89

Open
ZedThree opened this issue Jul 25, 2023 · 0 comments
Open

Co-arrays #89

ZedThree opened this issue Jul 25, 2023 · 0 comments

Comments

@ZedThree
Copy link
Collaborator

Example from wikipedia:

program Hello_World
  implicit none
  integer :: i  ! Local variable
  character(len=20) :: name[*] ! scalar coarray, one "name" for each image.
  ! Note: "name" is the local variable while "name[<index>]" accesses the
  ! variable in a specific image; "name[this_image()]" is the same as "name".

  ! Interact with the user on Image 1; execution for all others pass by.
  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 have arrived.

  ! I/O from all images, executing in any order, but each record written is intact. 
  write(*,'(3a,i0)') 'Hello ',trim(name),' from image ', this_image()
end program Hello_world

I think it's basically just the coarray index syntax (name[*]) and the new keyword statements (sync all)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant