How can I declare pointer types on 32-bit and 64-bit platforms without changing the code in a Fortran MEX-file in MATLAB 7.1 (R14SP3)?
조회 수: 7(최근 30일)
표시 이전 댓글
I am trying to execute my Fortran MEX-file on a 64-bit Linux machine using MATLAB 7.1 (R14SP3). I previously successfully compiled the file on a 32-bit Linux machine. My file uses the INTEGER datatype.
Now that I am moving to a 64-bit machine, I will need to use the INTEGER*8 datatype. Rather than replacing all occurrences of INTEGER with INTEGER*8, I want to know whether there is a way to write architecture-independent code that will use the correct INTEGER datatype depending on what architecture the MEX-file is executed on.
This enhancement has been incorporated in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
If your Fortran compiler supports preprocessing, use the MWPOINTER macro instead of INTEGER to declare mxArrays and other MATLAB pointer types. The Fortran preprocessor converts MWPOINTER to INTEGER*4 on 32-bit platforms and INTEGER*8 on 64-bit platforms.
To use MWPOINTER, you must include the following line in your Fortran source file:
For examples of use of MWPOINTER, open any of the files with the extension .F in the directory $MATLAB\extern\examples (where $MATLAB is the MATLAB root directory on your machine, as returned by typing
at the MATLAB command prompt.)
댓글 수: 0
Find more on Fortran with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!