"m " <firstname.lastname@example.org> wrote in message <email@example.com>... > Hello, > > I have two cubes of data and I want to make a linear regression between two little cubes (one in each big cube of data), so I make this code (example here) : X_pad and Y_pad are our data but with a padding around the cube to compute the linear regression everywhere. > So I have to do three loops and I make a mex file in Fortran to do it. > > But when I run it, with, for example data with this size : 1500x300x800, I have this error : > > 'test.mexa64': test.mexa64: cannot map zero-fill pages: Cannot allocate memory > > Do you know what that mean and how to fix it ? > > Here is the interface function :
You do NOT want to do what you are doing above. The variables x, y, z, sized, and win are LOCAL variables, meaning they will in all likelihood get their memory from the stack which has a limited size. So you are probably overflowing your stack. Particularly for large variables you need to be getting this memory from the heap, not the stack. So make these variables allocatable instead. E.g.,
integer*4 numel, istat parameter(numel = 9000000000) real*8, allocatable :: x(:), y(:), z(:), sized(:), win(:) : allocate(x(numel),stat=istat) if( istat /= 0 ) then ! take appropriate action endif : etc for y, z, sized, win
Then at the end of your code deallocate them.
Another option to consider is this F95/MATLAB interface package which allows you to point directly at MATLAB variable memory, often avoiding the need to copy memory: