<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 10/7/2012 6:05 PM, Matthew Knepley
wrote:<br>
</div>
<blockquote
cite="mid:CAMYG4G=Osib5w+Bx1KCmeHTrxfuFth_0Tg32EeJ7bVcYLvS+6g@mail.gmail.com"
type="cite">On Tue, Jul 10, 2012 at 11:03 AM, TAY wee-beng <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>></span>
wrote:<br>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div><br>
<pre cols="72">Yours sincerely,
TAY wee-beng</pre>
On 10/7/2012 2:07 PM, Matthew Knepley wrote:<br>
</div>
<blockquote type="cite">On Tue, Jul 10, 2012 at 5:39 AM, TAY
wee-beng <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>></span>
wrote:<br>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> Hi,<br>
<br>
I read in the manual in page 50 that it's
recommended to declare struct to represent field for
dof > 1 for DM.<br>
</div>
</blockquote>
<div><br>
</div>
<div>We mean C struct. C makes it easy (just use a
pointer type cast). Fortran makes it hard
unfortunately.</div>
<div><br>
</div>
<div> Matt</div>
</div>
</blockquote>
Ok, I'll try to use another mtd. <br>
<br>
Btw, if I declare:<br>
<br>
<i>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)</i><br>
<br>
How is the memory for "array2" allocated ? Is it allocated
all the time, or only between the DMDAVecGetArrayF90 and
DMDAVecRestoreArrayF90?<br>
<br>
Also, can I "reuse" array2? For e.g., now for y_local:<br>
<br>
<i>call DMDAVecGetArrayF90(da,y_local,array2,ierr)<br>
<br>
access array2 ....</i> <i><br>
<br>
call DMDAVecRestoreArrayF90(da,y_local,array2,ierr)</i>
<br>
</div>
</blockquote>
<div><br>
</div>
<div>The right thing to do here is to implement
DMDAVecGetArratDOFF90().</div>
<div><br>
</div>
<div> Matt</div>
</div>
</blockquote>
<br>
Hi,<br>
<br>
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>
<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">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">DMDAGetCorners</a>()
for a global array or <a
href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMDAGetGhostCorners.html#DMDAGetGhostCorners">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<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)</i><br>
<br>
How is the memory for "array2" allocated ? Is it allocated all the
time, or only between the DMDAVecGetArrayF90 and
DMDAVecRestoreArrayF90?<br>
<br>
Thanks!<br>
<br>
<br>
<blockquote
cite="mid:CAMYG4G=Osib5w+Bx1KCmeHTrxfuFth_0Tg32EeJ7bVcYLvS+6g@mail.gmail.com"
type="cite">
<div class="gmail_quote">
<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"> Thank you!<br>
<br>
<blockquote type="cite">
<div class="gmail_quote">
<div> <br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> I'm using
Fortran and for testing, I use dof = 1 and write as:<br>
<br>
<i>type field<br>
<br>
</i><i>PetscScalar</i><i> u (or
real(8) :: u)<br>
<br>
end type field<br>
<br>
type(field), pointer :: field_u(:,:)</i><br>
<br>
When I tried to use :<br>
<br>
<i>call DMDAVecGetArrayF90(da,x_local,field_u,ierr)</i><br>
<br>
I got the error : There is no matching specific
subroutine for this generic subroutine call.
[DMDAVECGETARRAYF90]<br>
<br>
The da, x_local has been defined with the specific
DM routines. It worked if I use :<br>
<br>
<i>PetscScalar,pointer :: array(:,:) and<br>
<br>
call DMDAVecGetArrayF90(da,x_local,array,ierr)</i><br>
<br>
May I know what did I do wrong?<span><font
color="#888888"><br>
<br>
<span class="HOEnZb"><font color="#888888"> <br>
<pre cols="72">--
Yours sincerely,
TAY wee-beng</pre>
</font></span></font></span></div>
<span class="HOEnZb"><font color="#888888"> </font></span></blockquote>
<span class="HOEnZb"><font color="#888888"> </font></span></div>
<span class="HOEnZb"><font color="#888888"> <br>
<br clear="all">
<div><br>
</div>
-- <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>
</font></span></blockquote>
<br>
<br>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <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>
<br>
<br>
</body>
</html>