MATLAB Answers

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)?

5 ビュー (過去 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.


MathWorks Support Team
MathWorks Support Team 2009 年 6 月 27 日
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:
#include "fintrf.h"
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 件のコメント

サインイン to comment.

その他の回答 (0 件)

サインイン してこの質問に回答します。




Translated by