1 | /*!\file: mxGetAssignedField.c:
|
---|
2 | * \brief: abstract interface on parallel side for i/o, so it ressembles the serial i/o.
|
---|
3 | *
|
---|
4 | * In serial mode, this routine takes care of returning the field coming
|
---|
5 | * from the model. If largesize is 1, we are running out of core models in
|
---|
6 | * matlab, and we need to call the subsref private method from the model object
|
---|
7 | * in order to correctly load the data from disk.
|
---|
8 | */
|
---|
9 |
|
---|
10 | #include "./matlabio.h"
|
---|
11 |
|
---|
12 | mxArray* mxGetAssignedField(const mxArray* pmxa_array,int number,const char* field){
|
---|
13 |
|
---|
14 | //output
|
---|
15 | mxArray* mxfield=NULL;
|
---|
16 |
|
---|
17 | //input
|
---|
18 | mxArray *inputs[2];
|
---|
19 | mxArray *pindex = NULL;
|
---|
20 | const char *fnames[2];
|
---|
21 | mwSize ndim = 2;
|
---|
22 | mwSize onebyone[2] = {1,1};
|
---|
23 |
|
---|
24 | //We want to call the subsasgn method, and get the returned array.This ensures that if we are running
|
---|
25 | //large sized problems, the data is truly loaded from disk by the model subsasgn class method.
|
---|
26 | inputs[0]=(mxArray*)pmxa_array; //this is the model
|
---|
27 |
|
---|
28 | //create index structure used in the assignment (index.type='.' and index.subs='x' for field x for ex)
|
---|
29 | fnames[0] = "type";
|
---|
30 | fnames[1] = "subs";
|
---|
31 | pindex=mxCreateStructArray( ndim,onebyone,2,fnames);
|
---|
32 | mxSetField( pindex, 0, "type",mxCreateString("."));
|
---|
33 | mxSetField( pindex, 0, "subs",mxCreateString(field));
|
---|
34 | inputs[1]=pindex;
|
---|
35 |
|
---|
36 | mexCallMATLAB( 1, &mxfield, 2, (mxArray**)inputs, "subsref");
|
---|
37 |
|
---|
38 | return mxfield;
|
---|
39 | }
|
---|