<div>Hi, </div><div><br></div><div>I have looked into this "<span style="font-family:arial, sans-serif;font-size:14px;background-color:rgb(255, 255, 255)">The X you passed in is not a valid Mat (we could see that from the earlier call</span>"</div>
I have added the following lines to my code:<div> <br><div>Call MatView(AppCtx%M, PETSC_VIEWER_STDOUT_WORLD,iErr);CHKERRQ(iErr) </div>
<div>Call MatView(AppCtx%K, PETSC_VIEWER_STDOUT_WORLD,iErr);CHKERRQ(iErr)</div><div>Call MatView(AppCtx%Jac, PETSC_VIEWER_STDOUT_WORLD,iErr);CHKERRQ(iErr)</div><div><br></div><div>Before calling TSSolve and in the functions called by TSSetRHSFunction, TSSetIFunction, TSSetIJacobian</div>
<div><br></div><div>Although these matrices are correctly defined before calling TSSolve, in functions called by TSSetRHSFunction, TSSetIFunction. I get </div><div><br></div><div><div>[0]PETSC ERROR: MatView() line 727 in /opt/HPC/petsc-dev/src/mat/interface/matrix.c Invalid Pointer to Object: Parameter # 1</div>
</div><div><br></div><div>or </div><div><br></div><div><div>Program received signal SIGSEGV, Segmentation fault.</div></div><div><br></div><div>when trying to view AppCtx%M or AppCtx%K</div><div><br></div><div>Actually my entire context user AppCtx is corrupted in IJacobian</div>
<div><br></div><div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)"><ul><li style="margin-left:15px">IJacobain </li></ul><div><div>(gdb) set language c </div><div>Warning: the current language does not match this frame.</div>
<div>(gdb) p appctx</div><div>$1 = {meshtopology = {num_dim = 0, num_verts = 17361392, num_elems = 0, num_elem_blks_global = 1, num_elem_blks = 0, elem_blk = 0x7fff342fed44, num_node_sets_global = 32767, </div><div> num_node_sets = 0, node_set = 0x7fff342fed44, num_side_sets_global = 0, num_side_sets = 875560448, mesh = {v = 32767}}, exo = {comm = 0, exoid = 0, filename = <error reading variable>, </div>
<div> title = <error reading variable>, num_qa = 0, qa_rec = 0x7fff342fed44, num_ebproperties = 0, ebproperty = 0x7fff342fed44, num_ssproperties = 0, ssproperty = 0x7fff342fed44, </div><div> num_nsproperties = 32603, nsproperty = 0x7fff342fed44, num_globvariables = 10, globvariable = 0x7fff342fed44, num_cellvariables = 32603, cellvariable = 0x7fff342fed44, </div>
<div> num_vertvariables = 32767, vertvariable = 0x7fff342fed44}, myexo = {comm = 32603, exoid = 875557088, filename = <error reading variable>, title = <error reading variable>, num_qa = 0, </div><div> qa_rec = 0x7fff342fed44, num_ebproperties = 32603, ebproperty = 0x7fff342fed44, num_ssproperties = 0, ssproperty = 0x7fff342fed44, num_nsproperties = 32767, nsproperty = 0x7fff342fed44, </div>
<div> num_globvariables = 0, globvariable = 0x7fff342fed44, num_cellvariables = 0, cellvariable = 0x7fff342fed44, num_vertvariables = 0, vertvariable = 0x7fff342fed44}, elem = 0x7fff342fed44, </div><div> gradu = {v = 335007449088}, elasticenergy = 4.1421357839642116e-311, u = {sec = {v = 335007449088}, component_sec = 0x7fff342fed44, vec = {v = 3760492082398003035}, localvec = {</div>
<div> v = 167881681698815}, scatter = {v = 159704063934464}, num_components = 0, component_size = 0x7fff342fed44}, f = {sec = {v = 0}, component_sec = 0x7fff342fed44, vec = {</div><div> v = 87979072163971071}, localvec = {v = 8126078124032}, scatter = {v = 8126078124032}, num_components = 0, component_size = 0x7fff342fed44}, extforceswork = 8.6701337941472592e-303, </div>
<div> totalenergy = 9.3259520631612332e-304, bcflag = {sec = {v = -5667103038041489408}, component_sec = 0x7fff342fed44, num_components = 32603, component_size = 0x7fff342fed44}, k = {</div><div> v = -5730207330369273856}, m = {v = 87758826241032027}, jac = {v = -5730213910259171328}, rhs = {sec = {v = -5666668292861853696}, component_sec = 0x7fff342fed44, vec = {</div>
<div> v = -5666668292861820929}, localvec = {v = 3760511323851489115}, scatter = {v = 87766866419810303}, num_components = 0, component_size = 0x7fff342fed44}, ksp = {</div><div> v = 6013542811304225138}, pc = {v = 18963712520581748}, loginfo = {io_stage = 0, setup_stage = 875562344, meshcreateexodus_stage = 32767, meshdistribute_stage = 875562352, </div>
<div> matassembly_stage = 32767, rhsassembly_stage = -1319374026, kspsolve_stage = 32603, postproc_stage = 0, matassemblyblock_event = 0, rhsassemblyblock_event = 0, postproc_event = 0}, </div><div> appparam = {restart = false, verbose = 0, testcase = 0, prefix = <error reading variable>, logviewer = {v = -5819891440125214720}, mylogviewer = {v = 32603}}, ts = {v = 88033721327812608}, </div>
<div> maxsteps = 0, maxtime = 9.0477955801092479e-303, u_0 = {sec = {v = 0}, component_sec = 0x7fff342fed44, vec = {v = -5930345144141217792}, localvec = {v = 3760497545596403547}, scatter = {</div><div> v = 94489313279}, num_components = 0, component_size = 0x7fff342fed44}}</div>
</div><div><br></div><ul><li style="margin-left:15px">dans RHSPoisson</li></ul></div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">(gdb) set language c</div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
Warning: the current language does not match this frame.</div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">(gdb) p appctx</div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
$2 = {meshtopology = {num_dim = 2, num_verts = 137, num_elems = 232, num_elem_blks_global = 1, num_elem_blks = 1, elem_blk = 0x7fffa5ff9b50, num_node_sets_global = 2, num_node_sets = 2, </div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
node_set = 0x7fffa5ff9b50, num_side_sets_global = 0, num_side_sets = 0, mesh = {v = 38875504}}, exo = {comm = 1140850688, exoid = 0, filename = <error reading variable>, </div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
title = <error reading variable>, num_qa = 0, qa_rec = 0x7fffa5ff9b50, num_ebproperties = 0, ebproperty = 0x7fffa5ff9b50, num_ssproperties = 0, ssproperty = 0x7fffa5ff9b50, </div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
num_nsproperties = 0, nsproperty = 0x7fffa5ff9b50, num_globvariables = 0, globvariable = 0x7fffa5ff9b50, num_cellvariables = 0, cellvariable = 0x7fffa5ff9b50, num_vertvariables = 0, </div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
vertvariable = 0x7fffa5ff9b50}, myexo = {comm = 1140850689, exoid = 0, filename = <error reading variable>, title = <error reading variable>, num_qa = 0, qa_rec = 0x7fffa5ff9b50, </div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
num_ebproperties = 2, ebproperty = 0x7fffa5ff9b50, num_ssproperties = 2, ssproperty = 0x7fffa5ff9b50, num_nsproperties = 1, nsproperty = 0x7fffa5ff9b50, num_globvariables = 0, </div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
globvariable = 0x7fffa5ff9b50, num_cellvariables = 0, cellvariable = 0x7fffa5ff9b50, num_vertvariables = 0, vertvariable = 0x7fffa5ff9b50}, elem = 0x7fffa5ff9b50, gradu = {v = 0}, </div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
elasticenergy = 0, u = {sec = {v = 38942496}, component_sec = 0x7fffa5ff9b50, vec = {v = 39336784}, localvec = {v = 39310784}, scatter = {v = 39385408}, num_components = 1, </div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
component_size = 0x7fffa5ff9b50}, f = {sec = {v = 39353184}, component_sec = 0x7fffa5ff9b50, vec = {v = 39456784}, localvec = {v = 39476448}, scatter = {v = 39526144}, </div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
num_components = 1, component_size = 0x7fffa5ff9b50}, extforceswork = 0, totalenergy = 0, bcflag = {sec = {v = 39632224}, component_sec = 0x7fffa5ff9b50, num_components = 1, </div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
component_size = 0x7fffa5ff9b50}, k = {v = 40465120}, m = {v = 40559808}, jac = {v = 40613120}, rhs = {sec = {v = 39491184}, component_sec = 0x7fffa5ff9b50, vec = {v = 39597824}, </div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
localvec = {v = 39617488}, scatter = {v = 39667184}, num_components = 1, component_size = 0x7fffa5ff9b50}, ksp = {v = 4294967955}, pc = {v = 0}, loginfo = {io_stage = 3, setup_stage = 4, </div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
meshcreateexodus_stage = 1, meshdistribute_stage = 2, matassembly_stage = 5, rhsassembly_stage = 6, kspsolve_stage = 7, postproc_stage = 8, matassemblyblock_event = 1, </div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
rhsassemblyblock_event = 2, postproc_event = 3}, appparam = {restart = 2992725822, verbose = 0, testcase = 2, prefix = <error reading variable>, logviewer = {v = 6890688}, mylogviewer = {</div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
v = 0}}, ts = {v = 42310832}, maxsteps = 1000, maxtime = 10, u_0 = {sec = {v = 39843104}, component_sec = 0x7fffa5ff9b50, vec = {v = 39789632}, localvec = {v = 39809296}, scatter = {</div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">
v = 39858992}, num_components = 1, component_size = 0x7fffa5ff9b50}}</div></div><div><br></div>
<div><br></div><div>I use : </div><div><br></div><div> Call TSSetIJacobian(AppCtx%TS, AppCtx%Jac, AppCtx%Jac, IJacobianPoisson, AppCtx, ierr); CHKERRQ(iErr)</div><div><br></div><div>and </div><div><br></div><div><div>
#undef __FUNCT__</div><div>#define __FUNCT__ "IJacobianPoisson"</div><div> SubRoutine IJacobianPoisson(dummyTS, t, U, Udot, a, Jac, PreJac, AppCtx, iErr)</div><div> Type(TS) :: dummyTS</div>
<div> PetscReal :: t, a </div><div> Type(Vec) :: U, Udot</div><div> Type(Mat) :: Jac, PreJac </div>
<div>
Type(AppCtx_Type) :: AppCtx</div><div> PetscInt :: iErr</div><div> Character(len=MEF90_MXSTRLEN) :: IOBuffer </div><div>! a*AppCtx%M + AppCtx%K</div>
<div> Write(IOBuffer, *) 'Begin IJacobianPoisson \n'</div><div> Call PetscPrintf(PETSC_COMM_WORLD, IOBuffer, iErr); CHKERRQ(iErr)</div><div> Call MatView(AppCtx%M, PETSC_VIEWER_STDOUT_WORLD,iErr);CHKERRQ(iErr)</div>
<div> Call MatView(AppCtx%K, PETSC_VIEWER_STDOUT_WORLD,iErr);CHKERRQ(iErr)</div><div> Call MatView(AppCtx%Jac, PETSC_VIEWER_STDOUT_WORLD,iErr);CHKERRQ(iErr)</div><div>!Initialisation de la matrice Jac ?</div><div>
!! Condition aux limites ?? </div><div> call MatAXPY(Jac, a, AppCtx%M, AppCtx%K, iErr); CHKERRQ(iErr)</div><div><br></div><div> End Subroutine IJacobianPoisson</div>
</div><div><br></div><div>Could the Fortran binding be incorrect for this specific function or am I really really missing something here? </div><div><br></div><div>Thanks </div>
</div>