mex difference between mwPointer and pointer in Fortran90

조회 수: 2 (최근 30일)
Robert
Robert 2014년 10월 23일
편집: James Tursa 2014년 10월 23일
What is the difference between mwPointer and intrinsic pointer in Fortran 90? Can you use mwPointer the way you would use an intrinsic F90 pointer?
Thanks Rob

채택된 답변

James Tursa
James Tursa 2014년 10월 23일
편집: James Tursa 2014년 10월 23일
An mwPointer is simply a macro that translates into a signed integer (32-bit or 64-bit) in Fortran. It is used to store memory addresses and to handle large values in inputs/outputs for several API functions. There is no data type or size information bound to this value ... it is up to the user to use it properly. You can think of it as a raw address like a C pointer.
A Fortran intrinsic pointer, on the other hand, is basically a descriptor (i.e., structure) of some sort (implementation specific) that contains a variety of information. It has an inherent type and rank that it points to (e.g., 2D real(8) or 4D integer(4), etc), it maintains an association status at all times (is it currently pointed to something or not), and when used in an expression it is automatically dereferenced (i.e., using it will automatically affect the target it is pointing to). E.g., a straight assignment using = will affect the target, not the pointer value. You have to use special operators (e.g., =>) and functions (nullify) to change the pointer value itself.
You CANNOT use mwPointer like you would use a Fortran intrinsic pointer. They are completely different animals. The only caveat to this is that a Fortran intrinsic pointer to a scalar is sometimes physically represented by the compiler as a simple 32-bit or 64-bit address (not necessary to store any size information). So its physical representation might be roughly equivalent to an mwPointer.
If you want to see examples of using Fortran intrinsic pointers with mex routines, take a look at this FEX submission:

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by