Research Article

High-Performance Design Patterns for Modern Fortran

Listing 15

if (num_images() == 1 .or.  &
num_images() == 2) then
  sync all
else
  if (this_image() == 1) then
sync images([, num_images()])
  elseif (this_image() == num_images()) then
sync images([, this_image() −  ])
  else
sync images([this_image() − 1, &
      this_image() + 1])
  endif
endif