| MATLAB Application Program Interface | Search  Help Desk |
| Passing Pointers in Fortran |
mxArray. Because there is no way to create a new data type in Fortran, MATLAB passes a special identifier, called a pointer, to a Fortran program. You can get information about an mxArray by passing this pointer to various API functions called "Access Routines". These access routines allow you to get a native Fortran data type containing exactly the information you want, i.e., the size of the mxArray, whether or not it is a string, or its data contents.
There are several implications when using pointers in Fortran:
.%VAL construct.
%VAL construct, then there is one type
of pointer you can use without requiring an access routine, namely a pointer
to data (i.e., the pointer returned by mxGetPr or mxGetPi). You can use %VAL
to pass this pointer's contents to a subroutine, where it is declared as a
Fortran double-precision array.
%VAL construct, you must use
the mxCopy__ routines (e.g., mxCopyPtrToReal8) to access the contents of the
pointer.
.integer*8. On all other platforms, pointers should be declared as
integer*4.
.F in the examples
directory for a possible approach.