I am trying to run parallel simulations of finite elements in Mathematica using the AceGen and AceFEM software along with a MATLAB script called from Mathematica.

I can run some of the simulations that do not require the MATLAB script in parallel using the pseudo approach below.

```
(*Launch multiple kernels*)
Get("AceFEM`");
kernels = ParallelEvaluate(
Get("AceFEM`Remote`");
$KernelID)
(*Solve FEM problem*)
Output=ParallelTable(
{output1,output2}
,{problem,ListOfFEMProblems});
```

For problems that require the MATLAB script, I tried to modify the code to load MATLink and the MATLAB script in all cores in two different ways.

Focus 1:

```
(*Launch multiple kernels*)
Get("AceFEM`");
kernels = ParallelEvaluate(
Get("AceFEM`Remote`");
$KernelID)
(*Load MATLink*)
Needs("MATLink`");
OpenMATLAB();
MatlabFunction = MFunction("MatlabFunctionName", "OutputArguments" -> 2);
(*Solve FEM problem*)
Output=ParallelTable(
{MATLABout1,MATLABout2}=MatlabFunction(Param1,Param2,Param3,Param4);
{output1,output2}
,{problem,ListOfFEMProblems});
```

With the following error:

```
(kernel 4) Set::shape : Lists {MATLABout1,MATLABout2} and MATLink`MFunction(MatlabFunctionName,OutputArguments->2)(Param1,Param2,Param3,Param4) are not the same shape.
```

Focus 2:

```
(*Launch multiple kernels*)
Get("AceFEM`");
kernels = ParallelEvaluate(
Get("AceFEM`Remote`");
$KernelID)
(*Load MATLink*)
ParallelNeeds("MATLink`");
ParallelEvaluate(
OpenMATLAB();
MatlabFunction = MFunction("MatlabFunctionName", "OutputArguments" -> 2);
);
(*Solve FEM problem*)
Output=ParallelTable(
{MATLABout1,MATLABout2}=MatlabFunction(Param1,Param2,Param3,Param4);
{output1,output2}
,{problem,ListOfFEMProblems});
```

With the mistakes:

```
(kernel 1) Global`OpenMATLAB::shdw : Symbol OpenMATLAB appears in multiple contexts {Global`,MATLink`}; definitions in context Global` may shadow or be shadowed by other definitions.
(kernel 1) Global`MFunction::shdw : Symbol MFunction appears in multiple contexts {Global`,MATLink`}; definitions in context Global` may shadow or be shadowed by other definitions.
```

Appears for each of the 4 kernals. As well as what happened previously `Set::shape`

error.

(For clarity, calling the MATLAB function works perfectly for non-parallel problems)

What is the correct approach to MATLink parallelization?