<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Jul 10, 2018 at 2:11 PM Manuel Valera <<a href="mailto:mvalera-w@sdsu.edu">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><div><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecMax.html">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecMax.html</a><br></div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><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(daDensity,LocDensity,dens,ierr)<br>call DMDAVecGetArrayF90(daDensity,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(daDensity,gDensity,Gdens,ierr)<br>!Broadcast the values of the updated density to the global array:<br>call DMLocalToGlobalBegin(daDensity,LocDensity,ADD_VALUES,gDensity,ierr)<br>call DMLocalToGlobalEnd(daDensity,LocDensity,ADD_VALUES,gDensity,ierr)<br>call DMDAVecGetArrayF90(daDensity,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,ystart:yend-1,zstart:zend-1)) + &<br> &maxval(Gdens(xstart:xend-1,ystart:yend-1,zstart:zend-1)))/2.0D0<br> print*,'My rho_P0: ', rho_P0<br>call DMDAVecRestoreArrayF90(daDensity,gDensity,Gdens,ierr)<br>call DMDAVecGetArrayF90(daDensity,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></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_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/~knepley/</a><br></div></div></div></div></div></div>