<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Feb 4, 2017 at 7:30 PM, Manuel Valera <span dir="ltr"><<a href="mailto:mvalera@mail.sdsu.edu" target="_blank">mvalera@mail.sdsu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks, that helped a lot,<div><br></div><div>Now im a little confused with my next error, in my serial code i have several arrays with dimensions declared as:</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px;padding:0px;font-family:consolas,menlo,"liberation mono",courier,monospace;font-size:12px;line-height:1.4;color:rgb(51,51,51)"><span class="m_-2273039022440570921gmail-n">u0</span><span class="m_-2273039022440570921gmail-p">(</span><span class="m_-2273039022440570921gmail-o" style="font-weight:700">-</span><span class="m_-2273039022440570921gmail-mi" style="color:rgb(0,153,153)">1</span><span class="m_-2273039022440570921gmail-p">:</span><span class="m_-2273039022440570921gmail-n">IMax</span><span class="m_-2273039022440570921gmail-o" style="font-weight:700">+</span><span class="m_-2273039022440570921gmail-mi" style="color:rgb(0,153,153)">2</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-o" style="font-weight:700">-</span><span class="m_-2273039022440570921gmail-mi" style="color:rgb(0,153,153)">1</span><span class="m_-2273039022440570921gmail-p">:</span><span class="m_-2273039022440570921gmail-n">JMax</span><span class="m_-2273039022440570921gmail-o" style="font-weight:700">+</span><span class="m_-2273039022440570921gmail-mi" style="color:rgb(0,153,153)">1</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-o" style="font-weight:700">-</span><span class="m_-2273039022440570921gmail-mi" style="color:rgb(0,153,153)">1</span><span class="m_-2273039022440570921gmail-p">:</span><span class="m_-2273039022440570921gmail-n">KMax</span><span class="m_-2273039022440570921gmail-o" style="font-weight:700"><wbr>+</span><span class="m_-2273039022440570921gmail-mi" style="color:rgb(0,153,153)">1</span><span class="m_-2273039022440570921gmail-p">)</span></pre><pre style="margin-top:0px;margin-bottom:0px;padding:0px;font-family:consolas,menlo,"liberation mono",courier,monospace;font-size:12px;line-height:1.4;color:rgb(51,51,51)"><span class="m_-2273039022440570921gmail-p"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4;color:rgb(51,51,51)"><span class="m_-2273039022440570921gmail-p"><font face="arial, helvetica, sans-serif">and i create my DMDA for this array as:</font></span></pre><pre style="margin-top:0px;margin-bottom:0px;padding:0px;font-family:consolas,menlo,"liberation mono",courier,monospace;font-size:12px;line-height:1.4;color:rgb(51,51,51)"><span class="m_-2273039022440570921gmail-p"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4"><span class="m_-2273039022440570921gmail-p"><pre style="font-size:12px;font-family:consolas,menlo,"liberation mono",courier,monospace;margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4"><span class="m_-2273039022440570921gmail-k" style="color:rgb(51,51,51);font-weight:700">call </span><span class="m_-2273039022440570921gmail-n" style="color:rgb(51,51,51)">CDA3</span><span class="m_-2273039022440570921gmail-p" style="color:rgb(51,51,51)">(</span><span class="m_-2273039022440570921gmail-n" style="color:rgb(51,51,51)">daub</span><span class="m_-2273039022440570921gmail-p" style="color:rgb(51,51,51)">,</span><span class="m_-2273039022440570921gmail-n" style="color:rgb(51,51,51)">IMax</span><span class="m_-2273039022440570921gmail-o" style="font-weight:700"><font color="#333333">+</font><font color="#009999">4</font></span><span class="m_-2273039022440570921gmail-p" style="color:rgb(51,51,51)">,J</span><span class="m_-2273039022440570921gmail-n" style="color:rgb(51,51,51)">Max</span><span class="m_-2273039022440570921gmail-o" style="color:rgb(51,51,51);font-weight:700">+</span><span class="m_-2273039022440570921gmail-o" style="font-weight:700"><font color="#009999">3</font></span><span class="m_-2273039022440570921gmail-p" style="color:rgb(51,51,51)">,K</span><span class="m_-2273039022440570921gmail-n" style="color:rgb(51,51,51)">Max</span><span class="m_-2273039022440570921gmail-o" style="color:rgb(51,51,51);font-weight:700">+</span><span class="m_-2273039022440570921gmail-o" style="font-weight:700"><font color="#009999">3</font></span><span class="m_-2273039022440570921gmail-p" style="color:rgb(51,51,51)"><wbr>)</span><font color="#333333">
</font><span class="m_-2273039022440570921gmail-k" style="color:rgb(51,51,51);font-weight:700">call </span><span class="m_-2273039022440570921gmail-n" style="color:rgb(51,51,51)">DAs</span><span class="m_-2273039022440570921gmail-p" style="color:rgb(51,51,51)">(</span><span class="m_-2273039022440570921gmail-n" style="color:rgb(51,51,51)">daub</span><span class="m_-2273039022440570921gmail-p" style="color:rgb(51,51,51)">,</span><span class="m_-2273039022440570921gmail-n" style="color:rgb(51,51,51)">u0p</span><span class="m_-2273039022440570921gmail-p" style="color:rgb(51,51,51)">,</span><span class="m_-2273039022440570921gmail-n" style="color:rgb(51,51,51)">u0pl</span><span class="m_-2273039022440570921gmail-p" style="color:rgb(51,51,51)">,</span><span class="m_-2273039022440570921gmail-n" style="color:rgb(51,51,51)">u0</span><span class="m_-2273039022440570921gmail-p" style="color:rgb(51,51,51)">)</span><font color="#333333"> </font></pre><pre style="font-size:12px;font-family:consolas,menlo,"liberation mono",courier,monospace;margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4"><font color="#333333"><br></font></pre><pre style="margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4"><font color="#333333" face="arial, helvetica, sans-serif">With the subroutines as:</font></pre><pre style="font-size:12px;font-family:consolas,menlo,"liberation mono",courier,monospace;margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4"><font color="#333333"><br></font></pre><pre style="margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4"><pre style="font-family:consolas,menlo,"liberation mono",courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4;color:rgb(51,51,51)"> <span class="m_-2273039022440570921gmail-k" style="font-weight:700">SUBROUTINE </span><span class="m_-2273039022440570921gmail-n">CDA3</span><span class="m_-2273039022440570921gmail-p">(</span><span class="m_-2273039022440570921gmail-n">da3d</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">dim3dx</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">dim3dy</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">dim3dz</span><span class="m_-2273039022440570921gmail-p"><wbr>)</span>
<a name="m_-2273039022440570921_PetscObjs.f90-377" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-378" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-379" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-n">DM</span><span class="m_-2273039022440570921gmail-p">,</span> <span class="m_-2273039022440570921gmail-k" style="font-weight:700">intent</span><span class="m_-2273039022440570921gmail-p">(</span><span class="m_-2273039022440570921gmail-n">inout</span><span class="m_-2273039022440570921gmail-p">)</span> <span class="m_-2273039022440570921gmail-kd" style="font-weight:700">::</span> <span class="m_-2273039022440570921gmail-n">da3d</span>
<a name="m_-2273039022440570921_PetscObjs.f90-380" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-n">PetscInt</span><span class="m_-2273039022440570921gmail-p">,</span> <span class="m_-2273039022440570921gmail-k" style="font-weight:700">intent</span><span class="m_-2273039022440570921gmail-p">(</span><span class="m_-2273039022440570921gmail-n">in</span><span class="m_-2273039022440570921gmail-p">)</span> <span class="m_-2273039022440570921gmail-kd" style="font-weight:700">::</span> <span class="m_-2273039022440570921gmail-n">dim3dx</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">dim3dy</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">dim3dz</span>
<a name="m_-2273039022440570921_PetscObjs.f90-381" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-n">DMBoundaryType</span> <span class="m_-2273039022440570921gmail-kd" style="font-weight:700">::</span> <span class="m_-2273039022440570921gmail-n">bx</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">by</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">bz</span>
<a name="m_-2273039022440570921_PetscObjs.f90-382" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-383" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-384" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-n">bx</span> <span class="m_-2273039022440570921gmail-o" style="font-weight:700">=</span> <span class="m_-2273039022440570921gmail-n">DM_BOUNDARY_NONE</span>
<a name="m_-2273039022440570921_PetscObjs.f90-385" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-n">by</span> <span class="m_-2273039022440570921gmail-o" style="font-weight:700">=</span> <span class="m_-2273039022440570921gmail-n">DM_BOUNDARY_NONE</span>
<a name="m_-2273039022440570921_PetscObjs.f90-386" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-n">bz</span> <span class="m_-2273039022440570921gmail-o" style="font-weight:700">=</span> <span class="m_-2273039022440570921gmail-n">DM_BOUNDARY_NONE</span>
<a name="m_-2273039022440570921_PetscObjs.f90-387" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-388" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-k" style="font-weight:700">call </span><span class="m_-2273039022440570921gmail-n">DMDACreate3d</span><span class="m_-2273039022440570921gmail-p">(</span><span class="m_-2273039022440570921gmail-n">PETSC_COMM_WORLD</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n"><wbr>bx</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">by</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">bz</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">DMDA_STENCIL_BOX</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">dim3<wbr>dx</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">dim3dy</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">dim3dz</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">PETSC_DECIDE</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n"><wbr>PETSC_DECIDE</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">PETSC_DECIDE</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-mi" style="color:rgb(0,153,153)">1</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-mi" style="color:rgb(0,153,153)">1</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n"><wbr>PETSC_NULL_INTEGER</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">PETSC_NULL_<wbr>INTEGER</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">PETSC_NULL_INTEGER</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">da3<wbr>d</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">ierr</span><span class="m_-2273039022440570921gmail-p">)</span>
<a name="m_-2273039022440570921_PetscObjs.f90-389" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-390" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-k" style="font-weight:700">call </span><span class="m_-2273039022440570921gmail-n">DMSetFromOptions</span><span class="m_-2273039022440570921gmail-p">(</span><span class="m_-2273039022440570921gmail-n">da3d</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">ierr</span><span class="m_-2273039022440570921gmail-p">)</span>
<a name="m_-2273039022440570921_PetscObjs.f90-391" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-k" style="font-weight:700">call </span><span class="m_-2273039022440570921gmail-n">DMSetUp</span><span class="m_-2273039022440570921gmail-p">(</span><span class="m_-2273039022440570921gmail-n">da3d</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">ierr</span><span class="m_-2273039022440570921gmail-p">)</span>
<a name="m_-2273039022440570921_PetscObjs.f90-392" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-393" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-k" style="font-weight:700">END SUBROUTINE </span><span class="m_-2273039022440570921gmail-n">CDA3</span>
<a name="m_-2273039022440570921_PetscObjs.f90-394" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-395" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-k" style="font-weight:700">SUBROUTINE </span><span class="m_-2273039022440570921gmail-n">DAs</span><span class="m_-2273039022440570921gmail-p">(</span><span class="m_-2273039022440570921gmail-n">da</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">globalv</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">localv</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-k" style="font-weight:700">array</span><span class="m_-2273039022440570921gmail-p">)</span>
<a name="m_-2273039022440570921_PetscObjs.f90-396" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-397" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-c" style="font-style:italic;color:rgb(153,153,136)">! use PetscObjects, only :: ierr</span>
<a name="m_-2273039022440570921_PetscObjs.f90-398" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-399" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-400" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-c" style="font-style:italic;color:rgb(153,153,136)">! Umbrella program to update and communicate the arrays in a</span>
<a name="m_-2273039022440570921_PetscObjs.f90-401" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-c" style="font-style:italic;color:rgb(153,153,136)">! distributed fashion using the DMDA objects from PETSc.</span>
<a name="m_-2273039022440570921_PetscObjs.f90-402" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-c" style="font-style:italic;color:rgb(153,153,136)">! Manuel Valera 1/20/17</span>
<a name="m_-2273039022440570921_PetscObjs.f90-403" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-404" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-c" style="font-style:italic;color:rgb(153,153,136)">! Arguments:</span>
<a name="m_-2273039022440570921_PetscObjs.f90-405" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-c" style="font-style:italic;color:rgb(153,153,136)">! da = DMDA array either 1d,2d or 3d, already created and setup</span>
<a name="m_-2273039022440570921_PetscObjs.f90-406" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-c" style="font-style:italic;color:rgb(153,153,136)">! globalv = global vector to be operated into</span>
<a name="m_-2273039022440570921_PetscObjs.f90-407" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-c" style="font-style:italic;color:rgb(153,153,136)">! localv = local chunk each processor works in.</span>
<a name="m_-2273039022440570921_PetscObjs.f90-408" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-c" style="font-style:italic;color:rgb(153,153,136)">! array = the array to be petscified. ONLY 3D ARRAYS rn.</span>
<a name="m_-2273039022440570921_PetscObjs.f90-409" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-c" style="font-style:italic;color:rgb(153,153,136)">! just in case.</span>
<a name="m_-2273039022440570921_PetscObjs.f90-410" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-411" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-n">Vec</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-k" style="font-weight:700">intent</span><span class="m_-2273039022440570921gmail-p">(</span><span class="m_-2273039022440570921gmail-n">inout</span><span class="m_-2273039022440570921gmail-p">)</span> <span class="m_-2273039022440570921gmail-kd" style="font-weight:700">::</span> <span class="m_-2273039022440570921gmail-n">globalv</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">localv</span>
<a name="m_-2273039022440570921_PetscObjs.f90-412" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-n">PetscScalar</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-k" style="font-weight:700">dimension</span><span class="m_-2273039022440570921gmail-p">(:,:,:)</span> <span class="m_-2273039022440570921gmail-kd" style="font-weight:700">::</span> <span class="m_-2273039022440570921gmail-k" style="font-weight:700">array</span>
<a name="m_-2273039022440570921_PetscObjs.f90-413" style="color:rgb(53,114,176)"></a><span class="m_-2273039022440570921gmail-k" style="font-weight:700"> </span><span class="m_-2273039022440570921gmail-n">DM</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-k" style="font-weight:700">intent</span><span class="m_-2273039022440570921gmail-p">(</span><span class="m_-2273039022440570921gmail-n">inout</span><span class="m_-2273039022440570921gmail-p">)</span> <span class="m_-2273039022440570921gmail-kd" style="font-weight:700">::</span> <span class="m_-2273039022440570921gmail-n">da</span>
<a name="m_-2273039022440570921_PetscObjs.f90-414" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-415" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-416" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-k" style="font-weight:700">call </span><span class="m_-2273039022440570921gmail-n">DMCreateGlobalVector</span><span class="m_-2273039022440570921gmail-p">(</span><span class="m_-2273039022440570921gmail-n">da</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">global<wbr>v</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">ierr</span><span class="m_-2273039022440570921gmail-p">)</span>
<a name="m_-2273039022440570921_PetscObjs.f90-417" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-k" style="font-weight:700">call </span><span class="m_-2273039022440570921gmail-n">DMCreateLocalVector</span><span class="m_-2273039022440570921gmail-p">(</span><span class="m_-2273039022440570921gmail-n">da</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">localv</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n"><wbr>ierr</span><span class="m_-2273039022440570921gmail-p">)</span>
<a name="m_-2273039022440570921_PetscObjs.f90-418" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-419" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-k" style="font-weight:700">call </span><span class="m_-2273039022440570921gmail-n">DMGlobalToLocalBegin</span><span class="m_-2273039022440570921gmail-p">(</span><span class="m_-2273039022440570921gmail-n">da</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">global<wbr>v</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">INSERT_VALUES</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">localv</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">ierr</span><span class="m_-2273039022440570921gmail-p">)</span>
<a name="m_-2273039022440570921_PetscObjs.f90-420" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-k" style="font-weight:700">call </span><span class="m_-2273039022440570921gmail-n">DMGlobalToLocalEnd</span><span class="m_-2273039022440570921gmail-p">(</span><span class="m_-2273039022440570921gmail-n">da</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">globalv</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n"><wbr>INSERT_VALUES</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">localv</span><span class="m_-2273039022440570921gmail-p">,</span><span class="m_-2273039022440570921gmail-n">ierr</span><span class="m_-2273039022440570921gmail-p">)</span>
<a name="m_-2273039022440570921_PetscObjs.f90-421" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-422" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-423" style="color:rgb(53,114,176)"></a>
<a name="m_-2273039022440570921_PetscObjs.f90-424" style="color:rgb(53,114,176)"></a> <span class="m_-2273039022440570921gmail-k" style="font-weight:700">END SUBROUTINE </span><span class="m_-2273039022440570921gmail-n">DAs</span></pre><pre style="font-family:consolas,menlo,"liberation mono",courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4;color:rgb(51,51,51)"><span class="m_-2273039022440570921gmail-n"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4;color:rgb(51,51,51)"><span class="m_-2273039022440570921gmail-n"><font face="arial, helvetica, sans-serif">Which i later open into an array to operate into it, but when i try to access u0(:,j-2,:) it gives me the following error:</font></span></pre><pre style="font-family:consolas,menlo,"liberation mono",courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4;color:rgb(51,51,51)"><span class="m_-2273039022440570921gmail-n"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4"><font color="#333333" face="consolas, menlo, liberation mono, courier, monospace">Fortran runtime error: Index '-1' of dimension 2 of array 'u0' below lower bound of 0</font><span style="color:rgb(51,51,51);font-family:consolas,menlo,"liberation mono",courier,monospace;font-size:12px">
</span></pre><pre style="margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4"><font color="#333333" face="consolas, menlo, liberation mono, courier, monospace"><br></font></pre><pre style="margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4"><font face="arial, helvetica, sans-serif">So i'm guessing the DMDA is creating the arrays with dimensions starting at 0 instead of -1 as it should, right? what can be done in this case?</font></pre></pre></span></pre></div></div></blockquote><div><br></div><div>1) The DMDA only takes sizes, not index bounds, in the constructor.</div><div><br></div><div>2) Its not the DMDA you must be talking about, but the array you get from DMDAVecGetArrayF90() or VecGetArrayF90()</div><div><br></div><div>3) The VecGetArrayF90() always start from 0 since it is indexed in local indices</div><div><br></div><div>4) The DMDVecGetArrayF90() arrays are indexed by global indices for the patch your process owns (including ghosts if its a local vector)</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><pre style="margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4"><span class="m_-2273039022440570921gmail-p"><pre style="margin-top:0px;margin-bottom:0px;padding:0px;line-height:1.4"><div><font face="arial, helvetica, sans-serif">Thanks, </font></div><div><font face="arial, helvetica, sans-serif">Manuel</font></div></pre></span></pre></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Feb 4, 2017 at 4:18 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
See: <a href="http://www.mcs.anl.gov/petsc/documentation/changes/dev.html" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/d<wbr>ocumentation/changes/dev.html</a> search for DMDACreate and update your code.<br>
<span class="m_-2273039022440570921HOEnZb"><font color="#888888"><br>
Barry<br>
</font></span><div class="m_-2273039022440570921HOEnZb"><div class="m_-2273039022440570921h5"><br>
<br>
> On Feb 4, 2017, at 6:02 PM, Manuel Valera <<a href="mailto:mvalera@mail.sdsu.edu" target="_blank">mvalera@mail.sdsu.edu</a>> wrote:<br>
><br>
> Hello devs,<br>
><br>
> Ive been creating the framework to distribute the arrays from my model using the global/local vectors and the DMDAs, for this i created a small subroutine that is responsible for making the necessary calls:<br>
><br>
> SUBROUTINE DAs(da,globalv,localv)<br>
><br>
> ! use PetscObjects, only :: ierr<br>
><br>
><br>
> ! Umbrella program to update and communicate the arrays in a<br>
> ! distributed fashion using the DMDA objects from PETSc.<br>
> ! Manuel Valera 1/20/17<br>
><br>
> ! Arguments:<br>
> ! da = DMDA array either 1d,2d or 3d, already created and setup<br>
> ! globalv = global vector to be operated into<br>
> ! localv = local chunk each processor works in.<br>
><br>
><br>
><br>
> Vec,intent(inout) :: globalv,localv<br>
><br>
><br>
><br>
> DM,intent(inout) :: da<br>
><br>
> call DMCreateGlobalVector(da,global<wbr>v,ierr)<br>
> call DMCreateLocalVector(da,localv,<wbr>ierr)<br>
><br>
> call DMGlobalToLocalBegin(da,global<wbr>v,INSERT_VALUES,localv,ierr)<br>
> call DMGlobalToLocalEnd(da,globalv,<wbr>INSERT_VALUES,localv,ierr)<br>
><br>
><br>
><br>
> END SUBROUTINE DAs<br>
><br>
><br>
> I call this from another program where i have declared a vector as:<br>
><br>
> #include "petsc/finclude/petscdm.h"<br>
> #include "petsc/finclude/petscdmda.h"<br>
><br>
> use petsc<br>
> use petscdm<br>
> use petscdmda<br>
><br>
> IMPLICIT NONE<br>
><br>
> Vec :: xpdmda,yp,zp,xcp,ycp,zcp<br>
> DM :: da,dac,dau,dav,daw<br>
><br>
> CONTAINS<br>
> SUBROUTINE InitGridP<br>
><br>
> IMPLICIT NONE<br>
> !PetscInt :: ierr<br>
><br>
> ! CREATE DMDA:<br>
><br>
> call CDA3(da,IMax-1,JMax-1,KMax-1)<br>
><br>
> !xpdmda,yp,zp have the same dimensions than x,y,z<br>
> !xpl,ypl,zpl are the local versions of xp,yp,zp<br>
><br>
> !We create the global and local vectors and communicate their values:<br>
> call DAs(da,xpdmda,xpl,x)<br>
><br>
> And at this call it crashes with the following message:<br>
><br>
> [0]PETSC ERROR: --------------------- Error Message ------------------------------<wbr>------------------------------<wbr>--<br>
> [0]PETSC ERROR: Null argument, when expecting valid pointer<br>
> [0]PETSC ERROR: Null Object: Parameter # 2<br>
> [0]PETSC ERROR: See<br>
> <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/d<wbr>ocumentation/faq.html</a><br>
> for trouble shooting.<br>
> [0]PETSC ERROR: Petsc Development GIT revision: v3.7.5-2949-gc3c607c GIT Date: 2017-01-20 17:34:16 -0600<br>
> [0]PETSC ERROR: ./ucmsLEP on a arch-linux2-c-debug named ocean by valera Sat Feb 4 15:53:53 2017<br>
> [0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-fblaslapack --download-mpich --download-hdf5 --download-netcdf --download-hypre --download-metis --download-parmetis --download-trillinos --with-debugging=1<br>
> [0]PETSC ERROR: #3 VecSetLocalToGlobalMapping() line 79 in /usr/dataC/home/valera/petsc/s<wbr>rc/vec/vec/interface/vector.c<br>
> [0]PETSC ERROR: #4 DMCreateGlobalVector_DA() line 41 in /usr/dataC/home/valera/petsc/s<wbr>rc/dm/impls/da/dadist.c<br>
> [0]PETSC ERROR: #5 DMCreateGlobalVector() line 840 in /usr/dataC/home/valera/petsc/s<wbr>rc/dm/interface/dm.c<br>
><br>
><br>
><br>
> So my question is, do i have to setup the vectors in any additional way? i followed the fortran DMDA examples closely and i didnt notice anything extra,<br>
><br>
> Thanks,<br>
><br>
> Manuel<br>
<br>
</div></div></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div>
</div></div>