<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div> Matt,<div><br></div><div> Actually DAVecRestoreArrayF90() only works for 1 dimensional DAs. The F90 interface has to be written for 2 and 3d and the creation of Fortran 3d arrays (and 4d for dof > 1) stuff written. </div><div><br></div><div> Barry</div><div><br></div><div><br><div><div>On Jun 22, 2010, at 6:21 PM, Matthew Knepley wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">On Tue, Jun 22, 2010 at 12:59 PM, Mark Cheeseman <span dir="ltr"><<a href="mailto:mark.cheeseman@kaust.edu.sa">mark.cheeseman@kaust.edu.sa</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">
<div dir="ltr">Hi,<br><br>I am trying to write a PETSc program in FORTRAN90 where I need to update a single value in a global distributed array. I know the global coordinates of the position that needs to be updated in the global array but I cannot get the mapping from the local vector correct. In this case, I am working on a domain with global dimensions [arraysize(1),arraysize(2),arraysize(3)] and I want to alter a single point in the global distributed array, uGLOBAL, at the global position [arraysize(1)/2-1,arraysize(2)-1,3]. I cannot seem to be able to do this... what am I doing wrong?<br>
<br>...<br>DA da<br>Vec uGLOBAL, uLOCAL, tmp<br>PetscErrorCode ierr<br>PetscScalar, pointer :: xx<br>PetscInt rank, source_rank, i,j,k, row<br><br clear="all">....<br><br>call MPI_Comm_rank( PETSC_COMM_WORLD, rank, ierr )<br>
call DACreate3d( PETSC_COMM_WORLD, DA_NONPERIODIC, DA_STENCIL_BOX, &<br> arraysize(1), arraysize(2), arraysize(3), PETSC_DECIDE, &<br> PETSC_DECIDE, PETSC_DECIDE, 1, 5, PETSC_NULL_INTEGER, &<br>
PETSC_NULL_INTEGER, PETSC_NULL_INTEGER, da, ierr)<br>call DACreateGlobalVector( da, pNOW, ierr )<br>call DAGetCorners( da, xs, ys, zs, xl, yl, zl, ierr )<br></div></blockquote><div><br></div><div>call DAVecGetArrayF90()</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div dir="ltr"> do i = xs,xs+xl-1<br> if ( i.eq.arraysize(1)/2-1 ) then<br> do j = ys,ys+yl-1<br>
if ( j.eq.arraysize(2)/2-1 ) then<br> do k = zs,zs+zl-1<br> if ( k.eq.3 ) then<br></div></blockquote><div><br></div><div> array(k,j,i) = pressure</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div dir="ltr"> endif<br> enddo<br> endif<br> enddo<br>
endif<br> enddo<br><br></div></blockquote><div><br></div><div>call </div></div></blockquote> <br><blockquote type="cite"><div class="gmail_quote"><div> </div><div>That should work.</div><div><br></div><div> Matt</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div dir="ltr">Thank you,<br>Mark<br><br>-- <br>Mark Patrick Cheeseman<br><br>Computational Scientist<br>KSL (KAUST Supercomputing Laboratory)<br>Building 1, Office #126<br>King Abdullah University of Science & Technology<br>
Thuwal 23955-6900<br>
Kingdom of Saudi Arabia<br> <br>EMAIL : <a href="mailto:mark.cheeseman@kaust.edu.sa" target="_blank">mark.cheeseman@kaust.edu.sa</a><br>PHONE : +966 (2) 808 0221 (office)<br> +966 (54) 470 1082 (mobile)<br>
SKYPE : mark.patrick.cheeseman<br>
</div>
</blockquote></div><br><br clear="all"><br>-- <br>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<br>
</blockquote></div><br></div></body></html>