<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div> Looks like the tool to list the examples in the manual pages is broken since it didn't find these other examples, I'll take a look at it.<div class=""><br class=""></div><div class=""> There is also a discussion in the users manual<br class=""><div><br class=""></div><div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">$ git grep MatlabEngine | grep ex</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/docs/tex/manual/part2.tex:PetscMatlabEngineCreate(MPI_Comm comm,char *machine,PetscMatlabEngine *e);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/docs/tex/manual/part2.tex:PetscMatlabEnginePut(PetscMatlabEngine e,PetscObject obj);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/docs/tex/manual/part2.tex:PetscMatlabEngineGet(PetscMatlabEngine e,PetscObject obj);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/docs/tex/manual/part2.tex:PetscMatlabEnginePutArray(PetscMatlabEngine e,int m,int n,PetscScalar *array,char *name);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/docs/tex/manual/part2.tex:PetscMatlabEngineGetArray(PetscMatlabEngine e,int m,int n,PetscScalar *array,char *name);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/docs/tex/manual/part2.tex:PetscMatlabEngineEvaluate(PetscMatlabEngine,"format",...);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/docs/tex/manual/part2.tex:PetscMatlabEngineEvaluate(PetscMatlabEngine,"x = \%g *y + z;",avalue);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/docs/tex/manual/part2.tex:PetscMatlabEngineGetOutput(PetscMatlabEngine,char **);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/docs/tex/manual/part2.tex:PetscMatlabEnginedPrintOutput(PetscMatlabEngine,FILE*).</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/snes/tutorials/ex5.c: ierr = PetscMatlabEnginePut(PETSC_MATLAB_ENGINE_(comm),(PetscObject)localX);CHKERRQ(ierr);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/snes/tutorials/ex5.c: ierr = PetscMatlabEngineEvaluate(PETSC_MATLAB_ENGINE_(comm),"localF=ex5m(localX,%18.16e,%18.16e,%18.16e)",hx,hy,lambda);CHKERRQ(ierr);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/snes/tutorials/ex5.c: ierr = PetscMatlabEngineGet(PETSC_MATLAB_ENGINE_(comm),(PetscObject)localF);CHKERRQ(ierr);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/sys/tests/ex16.c:static char help[] = "Demonstrates PetscMatlabEngineXXX()\n";</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/sys/tests/ex16.c: ierr = PetscMatlabEngineGetOutput(PETSC_MATLAB_ENGINE_(PETSC_COMM_WORLD),&output);CHKERRQ(ierr);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/sys/tests/ex16.c: ierr = PetscMatlabEngineEvaluate(PETSC_MATLAB_ENGINE_(PETSC_COMM_WORLD),"MPI_Comm_rank");CHKERRQ(ierr);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/sys/tests/ex16.c: ierr = PetscMatlabEngineEvaluate(PETSC_MATLAB_ENGINE_(PETSC_COMM_WORLD),user);CHKERRQ(ierr);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/vec/vec/tests/ex31.c:static const char help[] = "Demonstrates PetscMatlabEngineXXX()\n";</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/vec/vec/tests/ex31.c: ierr = PetscMatlabEngineGetOutput(PETSC_MATLAB_ENGINE_WORLD,&output);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/vec/vec/tests/ex31.c: ierr = PetscMatlabEngineEvaluate(PETSC_MATLAB_ENGINE_WORLD,"MPI_Comm_rank");</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/vec/vec/tests/ex31.c: ierr = PetscMatlabEnginePut(PETSC_MATLAB_ENGINE_WORLD,(PetscObject)x);CHKERRQ(ierr);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/vec/vec/tests/ex31.c: ierr = PetscMatlabEngineEvaluate(PETSC_MATLAB_ENGINE_WORLD,"x = x + MPI_Comm_rank;\n");</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/vec/vec/tests/ex31.c: ierr = PetscMatlabEngineGet(PETSC_MATLAB_ENGINE_WORLD,(PetscObject)x);CHKERRQ(ierr);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">src/vec/vec/tests/ex31.c: ierr = PetscMatlabEngineEvaluate(PETSC_MATLAB_ENGINE_WORLD,"whos\n");CHKERRQ(ierr);</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><blockquote type="cite" class=""><div class="">On Jun 8, 2020, at 8:26 PM, Amneet Bhalla <<a href="mailto:mail2amneet@gmail.com" class="">mail2amneet@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class="">Great!<div class=""><br class=""></div><div class="">Clicking on some of the functions pointed me to this example</div><div class=""><a href="https://www.mcs.anl.gov/petsc/petsc-3.13/src/snes/tutorials/ex5.c.html" class="">https://www.mcs.anl.gov/petsc/petsc-3.13/src/snes/tutorials/ex5.c.html</a><br class=""></div><div class=""><br class=""></div><div class="">Are there more examples, which are perhaps simpler than the above, which I can refer to? </div></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 8, 2020 at 5:51 PM Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class=""><div class=""><br class=""></div><span style="font-size:13px" class=""> You should use the PetscMatlabEngine </span><a href="https://www.mcs.anl.gov/petsc/petsc-3.13/docs/manualpages/Sys/PetscMatlabEngine.html" style="font-size:13px" target="_blank" class="">https://www.mcs.anl.gov/petsc/petsc-3.13/docs/manualpages/Sys/PetscMatlabEngine.html</a><br style="font-size:13px" class=""><br style="font-size:13px" class=""><span style="font-size:13px" class=""> Barry</span><div class=""><font size="2" class=""><br class=""></font><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Jun 8, 2020, at 7:09 PM, Amneet Bhalla <<a href="mailto:mail2amneet@gmail.com" target="_blank" class="">mail2amneet@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">Hi Folks,<div class=""><br class=""></div><div class="">My parallel application written in C++ (which also uses PETSc library for linear solvers) requires calling control and optimization toolbox of MATLAB at every time step to get a small number of double values. Likewise the MATLAB function will need to know some values from the parallel C++ application to return those doubles. I'm wondering if there is a recommended way of calling MATLAB from parallel C/C++/Fortran codes, and if PETSc has some interface that could be leveraged for this exchange. <br clear="all" class=""><div class=""><br class=""></div><div class="">Thanks,</div>-- <br class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">--Amneet <br class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div></div></div></div>
</div></blockquote></div><br class=""></div></div></blockquote></div><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div dir="ltr" class="gmail_signature"><div dir="ltr" class=""><div class="">--Amneet <br class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div></div>
</div></blockquote></div><br class=""></div></body></html>