hi,

What is the right way to call DMPlexPointLocalRef() from fortran?

I have a test subroutine that I'm basically translating from the CreatePartitionVec() function in the TS ex 33 example problem.

Near the end there's a loop which in C goes:

  ierr = VecGetArray(*partition, &part);CHKERRQ(ierr);
  for (c = cStart; c < cEnd; ++c) {
    PetscScalar *p;
    ierr = DMPlexPointLocalRef(*dmCell, c, part, &p);CHKERRQ(ierr);
    p[0] = rank;
  }
  ierr = VecRestoreArray(*partition, &part);CHKERRQ(ierr);


So in fortran I've done this:

  call VecGetArrayF90(partition, part, ierr); CHKERRQ(ierr)
  do c = cStart, cEnd-1
    call DMPlexPointLocalRef(cell_dm, c, part, p, ierr); CHKERRQ(ierr)
    p(1) = rank
 end do
 call VecRestoreArrayF90(partition, part, ierr); CHKERRQ(ierr)

where I've previously declared

  PetscScalar, pointer :: part(:)
  PetscScalar, pointer:: p(:)

However the compiler complains:

Error: Rank mismatch in argument 'array' at (1) (scalar and rank-1)

It's not liking the 'part' argument, but I'm not sure how it's supposed to be passed in. Any clues?

Cheers, Adrian

--
Dr Adrian Croucher
Department of Engineering Science
University of Auckland
New Zealand
tel 64-9-373-7599 ext 84611

Reply via email to