<div dir="ltr">Thank you Matthew, i was aware of this function but i couldn't find an example with DMDAs, i now see ex5 has that and after some work i was able to use it in Fortran, now my code is working as intended, i did learn something new,<div><br></div><div>Thanks again,</div><div><br></div><div>Manuel </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 10, 2018 at 12:00 PM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</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"><div class="gmail_quote"><span class=""><div dir="ltr">On Tue, Jul 10, 2018 at 2:11 PM Manuel Valera <<a href="mailto:mvalera-w@sdsu.edu" target="_blank">mvalera-w@sdsu.edu</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 dir="ltr">Hi guys,<div><br></div><div>It's me with another basic question, this time i need to find the global maximum and minimum of DMDA array to do an average, it is usually operated over a local vector but it has a global vector too, the code works as intended in one core but it comes up with different values for this average when i quote more than one processor,</div><div><br></div><div>Is there an easy way to find maximum and minimums over a DMDA array? </div></div></blockquote><div><br></div></span><div><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecMax.html" target="_blank">http://www.mcs.anl.gov/petsc/<wbr>petsc-current/docs/<wbr>manualpages/Vec/VecMax.html</a><br></div><div><br></div><div>  Thanks,</div><div><br></div><div>    Matt</div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I currently have the following:</div><div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">call DMDAVecRestoreArrayF90(<wbr>daDensity,LocDensity,dens,<wbr>ierr)<br>call DMDAVecGetArrayF90(daDensity,<wbr>gDensity,Gdens,ierr)<br>!Erase global density since it has already been broadcasted before and we use<br>!the local version only:<br>Gdens = 0.0d0<br>call DMDAVecRestoreArrayF90(<wbr>daDensity,gDensity,Gdens,ierr)<br>!Broadcast the values of the updated density to the global array:<br>call DMLocalToGlobalBegin(<wbr>daDensity,LocDensity,ADD_<wbr>VALUES,gDensity,ierr)<br>call DMLocalToGlobalEnd(daDensity,<wbr>LocDensity,ADD_VALUES,<wbr>gDensity,ierr)<br>call DMDAVecGetArrayF90(daDensity,<wbr>gDensity,Gdens,ierr) </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">!Calculate 'average' on the global domain, taking care is done on inner points<br>!only:<br>       rho_P0 = (minval(Gdens(xstart:xend-1,<wbr>ystart:yend-1,zstart:zend-1))  +  &<br>                &maxval(Gdens(xstart:xend-1,<wbr>ystart:yend-1,zstart:zend-1)))<wbr>/2.0D0<br>       print*,'My rho_P0: ', rho_P0<br>call DMDAVecRestoreArrayF90(<wbr>daDensity,gDensity,Gdens,ierr)<br>call DMDAVecGetArrayF90(daDensity,<wbr>LocDensity,dens,ierr)</blockquote></div><div><br></div><div>The idea here was to use the global vector so it would have the information of the whole array, but is not working as intended, what am i doing wrong?</div><div><br></div><div>Thanks,</div><div><br></div><div>Manuel </div></div>
</blockquote></span></div><span class="HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_6257737322632627772gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>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><br></div><div><a href="http://www.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~<wbr>knepley/</a><br></div></div></div></div></div></font></span></div>
</blockquote></div><br></div>