<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
text-align:justify;
text-justify:inter-ideograph;
font-size:10.5pt;
font-family:DengXian;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:DengXian;}
/* Page Definitions */
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1421216623;
mso-list-template-ids:-1;}
@list l0:level1
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:72.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:"Courier New";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:108.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:144.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:180.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:216.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:252.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:288.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:324.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style>
</head>
<body lang="ZH-CN" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal">´Ó<span lang="EN-US"> Windows </span>°æ<span lang="EN-US"><a href="https://go.microsoft.com/fwlink/?LinkId=550986"><span lang="EN-US"><span lang="EN-US">Óʼþ</span></span></a></span>·¢ËÍ</p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;font-family:SimSun">Hi, Dear developer:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:#333333;background:#F7F8FA">I had compilation problems when using VecGetValues. My procedure is as follows:<o:p></o:p></span></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" align="left" style="text-align:left;line-height:14.25pt;background:#1E1E1E">
<span lang="EN-US" style="font-family:Consolas;color:#C586C0">program</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> main<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#569CD6">#</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">include</span><span lang="EN-US" style="font-family:Consolas;color:#569CD6">
</span><span lang="EN-US" style="font-family:Consolas;color:#CE9178"><petsc/finclude/petscvec.h></span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#C586C0">use</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> petscvec<o:p></o:p></span></p>
</div>
</div>
</div>
<p class="MsoNormal" align="left" style="text-align:left;line-height:14.25pt;background:#1E1E1E">
<span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> Vec x<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> PetscInt N,i,ione<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> PetscErrorCode ierr<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> PetscMPIInt rank<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> PetscScalar one<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">call</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> PetscInitialize(PETSC_NULL_CHARACTER,ierr)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">if</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> (ierr .ne.
</span><span lang="EN-US" style="font-family:Consolas;color:#B5CEA8">0</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">)
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">then</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">print</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">*,</span><span lang="EN-US" style="font-family:Consolas;color:#CE9178">'PetscInitialize failed'</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">stop</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">endif</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> one =
</span><span lang="EN-US" style="font-family:Consolas;color:#B5CEA8">1.0</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">call</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)<o:p></o:p></span></p>
</div>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal" align="left" style="text-align:left;line-height:14.25pt;background:#1E1E1E">
<span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> N = rank + </span>
<span lang="EN-US" style="font-family:Consolas;color:#B5CEA8">1</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">call</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> VecCreateMPI(PETSC_COMM_WORLD,N,PETSC_DECIDE,x,ierr)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">call</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> VecGetSize(x,N,ierr)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">call</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> VecSet(x,one,ierr)<o:p></o:p></span></p>
</div>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal" align="left" style="text-align:left;line-height:14.25pt;background:#1E1E1E">
<span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> ione = </span>
<span lang="EN-US" style="font-family:Consolas;color:#B5CEA8">1</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">do</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#B5CEA8">100</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> i=</span><span lang="EN-US" style="font-family:Consolas;color:#B5CEA8">0</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">,N-rank</span><span lang="EN-US" style="font-family:Consolas;color:#B5CEA8">-1</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> </span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">call</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
VecSetValues(x,ione,i,one,ADD_VALUES,ierr)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> </span><span lang="EN-US" style="font-family:Consolas;color:#B5CEA8">100</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">continue</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
</div>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal" align="left" style="text-align:left;line-height:14.25pt;background:#1E1E1E">
<span lang="EN-US" style="font-family:Consolas;color:#C586C0">call</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> VecAssemblyBegin(x,ierr)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">call</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> VecAssemblyEnd(x,ierr)<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">if</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> (rank .eq.
</span><span lang="EN-US" style="font-family:Consolas;color:#B5CEA8">0</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">)
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">then</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> ione =
</span><span lang="EN-US" style="font-family:Consolas;color:#B5CEA8">0</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">call</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> VecGetValues(x,ione,i,one,ierr)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">endif</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">call</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> VecView(x,PETSC_VIEWER_STDOUT_WORLD,ierr)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">call</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> VecDestroy(x,ierr)<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4">
</span><span lang="EN-US" style="font-family:Consolas;color:#C586C0">call</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> PetscFinalize(ierr)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span lang="EN-US" style="font-family:Consolas;color:#C586C0">end PROGRAM</span><span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"> main<o:p></o:p></span></p>
</div>
</div>
</div>
<p class="MsoNormal" align="left" style="text-align:left;line-height:14.25pt;background:#1E1E1E">
<span lang="EN-US" style="font-family:Consolas;color:#D4D4D4"><o:p> </o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:#333333;background:#F7F8FA">The compilation error is as follows:
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:red;background:#F7F8FA">mpif90 -I/root/soft/petsc/3.8.0/include -o ex2f.o ex2f.F90<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:red;background:#F7F8FA">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]<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:red;background:#F7F8FA"> call VecGetValues(x,ione,i,one,ierr)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:red;background:#F7F8FA">-------------^<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:red;background:#F7F8FA">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]<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:red;background:#F7F8FA"> call VecGetValues(x,ione,i,one,ierr)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:red;background:#F7F8FA">-------------^<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:red;background:#F7F8FA">compilation aborted for ex2f.F90 (code 1)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:#333333;background:#F7F8FA">And this error only appears when the Petsc version is higher than 3.8.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:#333333;background:#F7F8FA">I look forward to hearing from you.
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:#333333;background:#F7F8FA">Thanks!<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:#333333;background:#F7F8FA"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:"Tahoma",sans-serif;color:#333333;background:#F7F8FA"><o:p> </o:p></span></p>
</div>
</body>
</html>