147. Pointer can remap array shape and bounds.#
topic: Pointers
Note
This tip is a draft1.
A pointer can be used to map an array to an array of the same type and size but a different shape, rank, or bounds, for example
real, target :: y(6) real, pointer :: p(:,:) p(-1:1,1:2) => y ! map y(:) to 3x2 matrix with LB -1, 1
A pointer can be used to map an array to an array of the same type and size but a different shape, rank, or bounds, for example
— FortranTip (@fortrantip) March 8, 2022
real, target :: y(6)
real, pointer :: p(:,:)
p(-1:1,1:2) => y ! map y(:) to 3x2 matrix with LB -1, 1pic.twitter.com/rZ72DjBWgH
- 1
From the perspective of FortranTip Browser, “draft” means that it hasn’t been edited for formatting, hasn’t had corresponding Fortran programs added, the text content hasn’t been enhanced, etc. Draft texts are extracted from the corresponding Tweet using the Twitter API.