필터 지우기
필터 지우기

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

조회 수: 1 (최근 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
matlabroot
at the MATLAB command prompt.)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R14SP1

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by