13.07.2014 Views

Madagascar Programming Reference Manual

Madagascar Programming Reference Manual

Madagascar Programming Reference Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.3. EXPLANATION OF THE CODE 19<br />

is the same as sf floatalloc except for the fact that the former allocates an array<br />

of two dimensions, size of the memory block assigned in this case is the product of<br />

the two integers given as arguments (e.g. nz*nx in this case).<br />

Then sf floatread (p. 109) of the RSF API is used to read the data from the<br />

files into the allocated memory blocks (arrays). The sf floatread takes the arrays,<br />

integers and files as arguments and returns arrays filled with the data from the files.<br />

46-50: 46 /* allocate temporary arrays */<br />

47 um = sf_floatalloc2(nz,nx);<br />

48 uo = sf_floatalloc2(nz,nx);<br />

49 up = sf_floatalloc2(nz,nx);<br />

50 ud = sf_floatalloc2(nz,nx);<br />

Just like the memory blocks were allocated for input files to be read in to, we now<br />

allocate memory for the temporary arrays which will be used just for the calculation,<br />

using sf floatalloc2 (p. 42).<br />

52-59: 52 for (iz=0; iz

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!