<div class="gmail_quote">On Tue, Jul 10, 2012 at 1:22 PM, TAY wee-beng <span dir="ltr"><<a href="mailto:zonexo@gmail.com" target="_blank">zonexo@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 bgcolor="#FFFFFF" text="#000000">Do you mean DMDAVecGetArrayDOFF90 ? I tried to compile but it gives
the error during linking:<br>
<br>
1>dm_test2d.obj : error LNK2019: unresolved external symbol
DMDAVECGETARRAYDOFF90 referenced in function MAIN__<br></div></blockquote><div><br></div><div>Matt was suggesting that someone should implement this function, it doesn't exist currently.</div><div><br></div><div>
Fortran makes this stuff really painful and we don't know how to make it do something reasonable without depending on your types. You can write your own DMDAVecGetArrayF90WithYourType(), but sadly, it requires some circus tricks to make work. (We can't put this in PETSc because we don't know what your field type is.)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
<br>
Also from the manual of DMDAVecGetArray, it says:<br>
<i><br>
Fortran Notes: From Fortran use DMDAVecGetArrayF90() and pass for
the array type <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscScalar.html#PetscScalar" target="_blank">PetscScalar</a>,pointer
:: array(:,...,:) of the appropriate
dimension. For a DMDA created with a dof of 1 use the dimension of
the DMDA, for a DMDA created with a dof greater than 1 use one
more than the
dimension of the DMDA. The order of the indices is
array(xs:xs+xm-1,ys:ys+ym-1,zs:zs+zm-1) (when dof is 1) otherwise
array(1:dof,xs:xs+xm-1,ys:ys+ym-1,zs:zs+zm-1) where the values are
obtained from
<a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMDAGetCorners.html#DMDAGetCorners" target="_blank">DMDAGetCorners</a>()
for a global array or <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMDAGetGhostCorners.html#DMDAGetGhostCorners" target="_blank">DMDAGetGhostCorners</a>()
for a local array. Include finclude/petscdmda.h90 to access this
routine.
</i><br>
<br>
I just tried with dof = 2 and there's no problem. However, the
manual says that for dof > 1, the array is <i>array(1:dof,xs:xs+xm-1,ys:ys+ym-1,zs:zs+zm-1)</i>.<br>
<br>
Should it be <i>array(0:dof-1,xs:xs+xm-1,ys:ys+ym-1,zs:zs+zm-1)</i>
instead? I had problems with the former, but the latter works fine.<br>
<br>
Also, I'm still not sure how the memory is allocated. If I have:<br>
<br>
<i>Vec x_local<div class="im"><br>
<br>
PetscScalar,pointer :: array2(:,:,:)<br>
<br>
with DMDACreate2d using dof = 2,<br>
<br>
call DMDAVecGetArrayF90(da,x_local,array2,ierr)<br>
<br>
access array2 ....<br>
<br>
call DMDAVecRestoreArrayF90(da,x_local,array2,ierr)</div></i><div class="im"><br>
<br>
How is the memory for "array2" allocated ? Is it allocated all the
time, or only between the DMDAVecGetArrayF90 and
DMDAVecRestoreArrayF90?<br></div></div></blockquote></div><br>