[petsc-users] Alternative to VecGetArrayF90

Gaetan Kenway kenway at utias.utoronto.ca
Sun May 27 15:45:51 CDT 2012


I was wondering are there any effective alternatives to VecGetArrayF90. In
the code I'm working on, I need to reorder variables from a field based
order in the application to a packed variable ordering that I use with
PETSc. The code I'm running is as follows which converts the blocked based
petsc ordering to the application field based order. There is an equilivent
routine that converts the field based residual back to petsc block ordering.

 call VecGetArrayF90(wVec,wvec_pointer,ierr)
  call EChk(ierr,__FILE__,__LINE__)

  ii = 1
  do nn=1,nDom
     do sps=1,nTimeIntervalsSpectral
        call setPointersAdj(nn,1_intType,sps)

        do k=2,kl
           do j=2,jl
              do i=2,il
                 do l=1,nw
                    w(i,j,k,l) = wvec_pointer(ii)
                    ii = ii + 1
                 end do
              end do
           end do
        end do
     end do
  end do

  call VecRestoreArrayF90(wVec,wvec_pointer,ierr)
  call EChk(ierr,__FILE__,__LINE__)

 The issue is that the VecGetArrayF90 command it highly finicky and often
prevents the code from compiling on various architectures.

My understanding is that the preferred way to of doing this is:

use petscvec
Vec wVe
PetscScalar, pointer :: wvec_pointer

call VecGetArrayF90(wVec,wvec_pointer,ierr)

However, many times the code will refuse to compile as there
are incompatibilities between petscvec module that was compiled with petsc
and the current compilation.

Another approach I tried is to eliminate the petscvec module and just use
an integer fro the petsc vector:

PetscInt :: wVec
PetscScalar, pointer :: wvec_pointer

call VecGetArrayF90(wVec,wvec_pointer,ierr)

This will compile, but it throws an error code 68, invalid pointer
argument. Again, this is only on some architectures with certain compilers.
(Ubuntu 12.04, gfortran 64bit will give this error, Ubuntu 10.10 ifort
32bit will work with either form)

My question is if you use the F77 form:  VecGetArray(x,x_array,i_x,ierr) is
there a performance penalty? Is it an actual pointer or is the data copied?
Do you think it would be more robust than using the F90 pointer form?

Also, would this be a suitable place to use the application ordering in


Gaetan Kenway
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120527/3307b5d5/attachment.html>

More information about the petsc-users mailing list