I actually attached the wrong test program last time- I've attached the right one here, which is much simpler. It test global indices 0, 1, ... 9.

If I run on 2 processes, the local indices it returns are:

rank 0: 0, 1, 2, 3, 4, 0, 0, 0, -253701943, 0
rank 1: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1

The results I expected are:

rank 0: 0, 1, 2, 3, 4, -1, -1, -1, -1, -1
rank 1: -1, -1, -1, -1, -1, 0, 1, 2, 3, 4

So the results for global indices 0, 1,... 4 are what I expected, on both ranks. But the results for global indices 5, 6, ... 9 are not.

I tried increasing the blocksize to 3 or 4, and the results were exactly the same.

It only gives the results I expected if I change the blocksize to 1.

- Adrian

--
Dr Adrian Croucher
Senior Research Fellow
Department of Engineering Science
University of Auckland, New Zealand
email: [email protected]
tel: +64 (0)9 923 4611

program testl2g

  ! Test PETSc local-to-global mapping

#include <petsc/finclude/petsc.h>

  use petsc

  implicit none
  PetscInt, parameter :: blocksize = 1
  PetscInt, parameter :: n = 5, nin = 10
  PetscMPIInt :: rank
  PetscInt :: i
  PetscInt, allocatable :: indices(:)
  ISLocalToGlobalMapping :: l2g
  PetscInt :: global(nin), local(nin), nout
  PetscErrorCode :: ierr

  call PetscInitialize(PETSC_NULL_CHARACTER, ierr); CHKERRQ(ierr)
  call MPI_comm_rank(PETSC_COMM_WORLD, rank, ierr)

  select case (rank)
  case (0)
     indices = [(i, i = 0, 4)]
  case (1)
     indices = [(i, i = 5, 9)]
  end select

  call ISLocalToGlobalMappingCreate(PETSC_COMM_WORLD, blocksize, n, indices, &
       PETSC_COPY_VALUES, l2g, ierr); CHKERRQ(ierr)
  call ISLocalToGlobalMappingView(l2g, PETSC_VIEWER_STDOUT_WORLD, ierr); CHKERRQ(ierr)

  global = [(i, i = 0, 9)]
  call ISGlobalToLocalMappingApplyBlock(l2g, IS_GTOLM_MASK, nin, &
       global, nout, local, ierr); CHKERRQ(ierr)
  write(*,*) 'rank:', rank, 'global:', global, 'local:', local, 'nout:', nout
  
  call ISLocalToGlobalMappingDestroy(l2g, ierr); CHKERRQ(ierr)
  call PetscFinalize(ierr); CHKERRQ(ierr)

end program testl2g

Reply via email to