Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MEX FILE PROBLEM about ARRAY EXPANSION LIMITS

1 view
Skip to first unread message

Edwards

unread,
Apr 28, 2005, 12:03:28 PM4/28/05
to
Hi,there;
I have one problem when debugging the MEX file writing in FORTRAN.
The question comes from the data transfer between MATLAB and FORTRAN,
which is mainly in GATEWAY subroutine. The data from matlab matrix
can not be fully transferred to fortran codes due to the array
expansion limits. In my case, I have 125*94 matrix in matlab. While
upon execution the mex file in gateway routine, I found out through
debugger that only 1000 first elements(first 10 collumns and 61
elements in 11th column) are transferred. Only first 736 elements are
correct and other 274 elements are close to infinite. The 1001th
elements just said the array expansion is limited 1000 nodes.
Any kind of help is appreicated!If you need other infor. to make a
judgement, let me know.

Edwards

Ben Barrowes

unread,
Apr 28, 2005, 1:22:09 PM4/28/05
to
What OS? What fortran? what exact error? Who/what said "the array
expansion is limited 1000 nodes"?

Edwards

unread,
Apr 28, 2005, 3:18:16 PM4/28/05
to
My codes written in fixed fortran format were debugged on
Digital Visual Fortran in Windows XP OS.
The error is the incorrect transfer of parts of the input data from
matlab to fortran.
Basically, one of the input matrix is pretty big(125*94).
I debugged the mex file and found out the mex file can not correctly
transfer this matrix to fortran subroutine.Some of the value was
changed to infinity and some of them were zeros.
And i used %val construct to transfer data.

And about that error"array expansion is limited to 1000 nodes" cames
out when i use "watch" in visual fortran to look at the variable
value. It probably is due to the array size is too big and DIGITAL
VISUAL FORTRAN might not open it. What do you think?

Thanks,

Ben Barrowes

unread,
Apr 28, 2005, 5:01:48 PM4/28/05
to
As you suggest, this may be a limitation of the viewer, i.e. the DVF
debugger can only view 1000 nodes, but the data was passed successfully
anyway. Try a
print *, variablename(1,:)
statement to look at some of the data that you think was not passed
correctly. It might be there.

If you want to see some examples of using fortran pointers instead of
%val, see:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=4443&objectType=file#
in the examples directory.

Edwards

unread,
Apr 29, 2005, 11:46:38 AM4/29/05
to
Hi,Ben;
The problem was solved last night. I found out the reason for that
problem is that fortran codes can not read sparse matrix variables
from matlab no matter I use %val construct or mxCopy function. Matlab
must use some special way to store the variable in memory so that
Fortran can not read it. So that I changed the codes in matlab to
transfer that sparse matrix to full matrix and it turned out the data
transfer has no problem now.But it might slow down the computation.
Any comments on this issue?

Thanks for your help!

Edwards

Edwards

unread,
Apr 29, 2005, 11:46:40 AM4/29/05
to
Hi,Ben;
The problem was solved last night. I found out the reason for that
problem is that fortran codes can not read sparse matrix variables
from matlab no matter I use %val construct or mxCopy function. Matlab
must use some special way to store the variable in memory so that
Fortran can not read it. So that I changed the codes in matlab to
transfer that sparse matrix to full matrix and it turned out the data
transfer has no problem now.But it might slow down the computation.
Any comments on this issue?

Thanks for your help!

Edwards

Ben Barrowes

unread,
Apr 29, 2005, 12:28:54 PM4/29/05
to
The fortran mex sparse capabilities have little documentation. In the
online docs, there is only:
http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/ch5_fo12.html#21299
Search the newsgroup for more.

It will slow your computation down because you have lost any advantage
from the sparse matrix.

Matlab's native support for sparse matrices is pretty good (and fast).
You may not gain much in terms of speed by going to a fortran mex file.

Ben

Duane Bozarth

unread,
Apr 29, 2005, 12:46:25 PM4/29/05
to
Ben Barrowes wrote:
>
> The fortran mex sparse capabilities have little documentation. In the
> online docs, there is only:
> http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/ch5_fo12.html#21299
> Search the newsgroup for more.
>
> It will slow your computation down because you have lost any advantage
> from the sparse matrix.
>
> Matlab's native support for sparse matrices is pretty good (and fast).
> You may not gain much in terms of speed by going to a fortran mex file.
...

Depending on what you're doing, there are Fortran sparse routines for
various operations available on Netlib. But, however, most internal
operations in Matlab are already pretty well optimized so as noted, the
gain may not be significant.

0 new messages