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
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Fortran with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!