Рет қаралды 34
This video is part of the playlist • Fortran Refresher . Click the link to view the entire playlist.
Accompanying notebook: github.com/pel...
Pointers in Fortran are declared with the pointer option in addition to a data type. Unlike void pointers in C, Fortran pointers must only "point" to objects of the same data type, and there is a restriction in that pointers can only "point" to objects with the target attribute set, or memory pointed at by other pointers. Using Fortran pointers is usually not best practice because their misuse can introduce memory safety bugs, however they are useful for interopability with C code in libraries such as HIP.
Using the allocate command, we can allocate memory and associate it with a Fortran pointer, and then treat the pointer as an array.