[petsc-users] A compilation error about VecGetValues

wang yuqi yu1299885905 at outlook.com
Sat May 21 08:23:20 CDT 2022



从 Windows 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>发送
Hi, Dear developer:
I had compilation problems when using VecGetValues. My procedure is as follows:
program main
#include <petsc/finclude/petscvec.h>
use petscvec
      Vec     x
      PetscInt N,i,ione
      PetscErrorCode ierr
      PetscMPIInt rank
      PetscScalar  one

      call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
      if (ierr .ne. 0) then
        print*,'PetscInitialize failed'
        stop
      endif
      one   = 1.0
      call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)
      N = rank + 1
      call VecCreateMPI(PETSC_COMM_WORLD,N,PETSC_DECIDE,x,ierr)
      call VecGetSize(x,N,ierr)
      call VecSet(x,one,ierr)
      ione = 1
      do 100 i=0,N-rank-1
         call VecSetValues(x,ione,i,one,ADD_VALUES,ierr)
 100  continue
call VecAssemblyBegin(x,ierr)
      call VecAssemblyEnd(x,ierr)

      if (rank .eq. 0) then
        ione = 0
        call VecGetValues(x,ione,i,one,ierr)
      endif
      call VecView(x,PETSC_VIEWER_STDOUT_WORLD,ierr)
      call VecDestroy(x,ierr)

      call PetscFinalize(ierr)
end PROGRAM main

The compilation error is as follows:
mpif90  -I/root/soft/petsc/3.8.0/include  -o ex2f.o ex2f.F90
ex2f.F90(62): error #8284: If the actual argument is scalar, the dummy argument shall be scalar unless the actual argument is of type character or is an element of an array that is not assumed shape, pointer, or polymorphic.   [C]
        call VecGetValues(x,ione,i,one,ierr)
-------------^
ex2f.F90(62): error #8284: If the actual argument is scalar, the dummy argument shall be scalar unless the actual argument is of type character or is an element of an array that is not assumed shape, pointer, or polymorphic.   [D]
        call VecGetValues(x,ione,i,one,ierr)
-------------^
compilation aborted for ex2f.F90 (code 1)
And this error only appears when the Petsc version is higher than 3.8.
I look forward to hearing from you.
Thanks!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220521/6b5b04ee/attachment-0001.html>


More information about the petsc-users mailing list