mex difference between mwPointer and pointer in Fortran90

1 次查看(过去 30 天)
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