<div dir="ltr">The last two arguments, other than the error code, to <a href="https://petsc.org/main/docs/manualpages/Vec/VecGetValues/">https://petsc.org/main/docs/manualpages/Vec/VecGetValues/</a> are arrays not scalars.<div>PETSc started emabling type checking after 3.8.</div><div><br></div><div><a href="https://petsc.org/main/src/vec/vec/tutorials/ex2f.F.html">https://petsc.org/main/src/vec/vec/tutorials/ex2f.F.html</a> does this.<br></div><div>This is a terrible example of code. It should be removed.</div><div>Why does this example work? </div><div>It has '<span style="color:rgb(0,0,0)">implicit none</span>'</div><div>You might add that to see if that fixes this problem, but this is a terrible "tutorial".</div><div><br></div><div>Mark</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, May 22, 2022 at 12:17 AM wang yuqi <<a href="mailto:yu1299885905@outlook.com">yu1299885905@outlook.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="ZH-CN" style="overflow-wrap: break-word;">
<div class="gmail-m_1767518809806911314WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:12pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal">从<span lang="EN-US"> Windows </span>版<span lang="EN-US"><a href="https://go.microsoft.com/fwlink/?LinkId=550986" target="_blank"><span lang="EN-US"><span lang="EN-US">邮件</span></span></a></span>发送</p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12pt;font-family:SimSun">Hi, Dear developer:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:rgb(51,51,51);background:rgb(247,248,250)">I had compilation problems when using VecGetValues. My procedure is as follows:<u></u><u></u></span></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" align="left" style="text-align:left;line-height:14.25pt;background:rgb(30,30,30)">
<span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">program</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> main<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(86,156,214)">#</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">include</span><span lang="EN-US" style="font-family:Consolas;color:rgb(86,156,214)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(206,145,120)"><petsc/finclude/petscvec.h></span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">use</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> petscvec<u></u><u></u></span></p>
</div>
</div>
</div>
<p class="MsoNormal" align="left" style="text-align:left;line-height:14.25pt;background:rgb(30,30,30)">
<span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> Vec x<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> PetscInt N,i,ione<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> PetscErrorCode ierr<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> PetscMPIInt rank<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> PetscScalar one<u></u><u></u></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">call</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> PetscInitialize(PETSC_NULL_CHARACTER,ierr)<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">if</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> (ierr .ne.
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(181,206,168)">0</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">)
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">then</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">print</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">*,</span><span lang="EN-US" style="font-family:Consolas;color:rgb(206,145,120)">'PetscInitialize failed'</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">stop</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">endif</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> one =
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(181,206,168)">1.0</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">call</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)<u></u><u></u></span></p>
</div>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal" align="left" style="text-align:left;line-height:14.25pt;background:rgb(30,30,30)">
<span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> N = rank + </span>
<span lang="EN-US" style="font-family:Consolas;color:rgb(181,206,168)">1</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">call</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> VecCreateMPI(PETSC_COMM_WORLD,N,PETSC_DECIDE,x,ierr)<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">call</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> VecGetSize(x,N,ierr)<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">call</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> VecSet(x,one,ierr)<u></u><u></u></span></p>
</div>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal" align="left" style="text-align:left;line-height:14.25pt;background:rgb(30,30,30)">
<span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> ione = </span>
<span lang="EN-US" style="font-family:Consolas;color:rgb(181,206,168)">1</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">do</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(181,206,168)">100</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> i=</span><span lang="EN-US" style="font-family:Consolas;color:rgb(181,206,168)">0</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">,N-rank</span><span lang="EN-US" style="font-family:Consolas;color:rgb(181,206,168)">-1</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> </span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">call</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
VecSetValues(x,ione,i,one,ADD_VALUES,ierr)<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> </span><span lang="EN-US" style="font-family:Consolas;color:rgb(181,206,168)">100</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">continue</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u><u></u></span></p>
</div>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal" align="left" style="text-align:left;line-height:14.25pt;background:rgb(30,30,30)">
<span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">call</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> VecAssemblyBegin(x,ierr)<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">call</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> VecAssemblyEnd(x,ierr)<u></u><u></u></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">if</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> (rank .eq.
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(181,206,168)">0</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">)
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">then</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> ione =
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(181,206,168)">0</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">call</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> VecGetValues(x,ione,i,one,ierr)<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">endif</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">call</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> VecView(x,PETSC_VIEWER_STDOUT_WORLD,ierr)<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">call</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> VecDestroy(x,ierr)<u></u><u></u></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)">
</span><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">call</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> PetscFinalize(ierr)<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:rgb(30,30,30)"><span lang="EN-US" style="font-family:Consolas;color:rgb(197,134,192)">end PROGRAM</span><span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"> main<u></u><u></u></span></p>
</div>
</div>
</div>
<p class="MsoNormal" align="left" style="text-align:left;line-height:14.25pt;background:rgb(30,30,30)">
<span lang="EN-US" style="font-family:Consolas;color:rgb(212,212,212)"><u></u> <u></u></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:rgb(51,51,51);background:rgb(247,248,250)">The compilation error is as follows:
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:red;background:rgb(247,248,250)">mpif90 -I/root/soft/petsc/3.8.0/include -o ex2f.o ex2f.F90<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:red;background:rgb(247,248,250)">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]<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:red;background:rgb(247,248,250)"> call VecGetValues(x,ione,i,one,ierr)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:red;background:rgb(247,248,250)">-------------^<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:red;background:rgb(247,248,250)">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]<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:red;background:rgb(247,248,250)"> call VecGetValues(x,ione,i,one,ierr)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:red;background:rgb(247,248,250)">-------------^<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:red;background:rgb(247,248,250)">compilation aborted for ex2f.F90 (code 1)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:rgb(51,51,51);background:rgb(247,248,250)">And this error only appears when the Petsc version is higher than 3.8.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:rgb(51,51,51);background:rgb(247,248,250)">I look forward to hearing from you.
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:rgb(51,51,51);background:rgb(247,248,250)">Thanks!<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:rgb(51,51,51);background:rgb(247,248,250)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:Tahoma,sans-serif;color:rgb(51,51,51);background:rgb(247,248,250)"><u></u> <u></u></span></p>
</div>
</div>
</blockquote></div>