mex difference between mwPointer and pointer in Fortran90
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Robert
am 23 Okt. 2014
Bearbeitet: James Tursa
am 23 Okt. 2014
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 Kommentare
Akzeptierte Antwort
James Tursa
am 23 Okt. 2014
Bearbeitet: James Tursa
am 23 Okt. 2014
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Fortran with MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!