<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I made the change in the function so I now get this error <br>PetscErrorCode ComputeRho(DMMG *dmmg, Vec rho)<br>
{<br> DA distA = (DA)dmmg->dm; <br> <br>In function ‘PetscErrorCode Myfunc(_n_DMMG**, _p_Vec*)’: <br>
error: request for member ‘dm’ in ‘* dmmg’, which is of non-class type ‘_n_DMMG*’<br><br>It looks like I have a null pointer to _n_DMMG** instead of _n_DMMG*</blockquote><div><br></div><div> It seems like your code expects you to pass a DMMG object not a DMMG* object. There are two ways to fix this:</div>
<div><br></div><div>1) In your function 'ComputeRho' change all references of dmmg to *dmmg, i.e.:</div><div><br></div><div>DA distA = (DA)(*dmmg)->dm;</div><div><br></div><div>2) Change your function declaration back to what you had:</div>
<div><br></div><div>PetscErrorCode ComputeRho(DMMG dmmg, Vec rho)</div><div>{...}</div><div><br></div><div>and then pass the object to your function as so:</div><div><br></div><div>ComputeRho(*dmmg, b);</div><div><br></div>
<div>Do you need your dmmg to be a pointer in your 'main' function? It looks like your declaration could just be:</div><div><br></div><div><div>extern PetscErrorCode Myfunc(DMMG,Vec);</div><div><br></div><div>>>>>>>>>>>>>>>>></div>
<div>int main(int argc,char **argv)</div><div>{</div><div> DMMG dmmg;</div><div>...Vec b;</div><div><br></div><div>Myfunc(dmmg,b)</div><div>}</div><div><br></div><div>PetscErrorCode Myfunc(DMMG dmmg, Vec b)</div>
<div>{</div><div> DA da = (DA)dmmg->dm;</div><div>.....</div><div>}</div></div><div><<<<<<<<<<<<<<<<<</div><div><br></div><div>and that would fix everything.</div>
<div><br></div><div>Sean</div></div>