Program Test integer, pointer, contiguous :: a(:,:),b(:) b(1:size(a))=>a end Program Test
compiles with a warning when the standard 08 checking flag is up.
warning #8589: Fortran 2008 specifies that if a bound remapping list is specified, data target must be of rank one. b(1:size(a))=>a
Looking up the message on google yielded that there was once a discussion about similar issue https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/475663
Is this a standard violation and do I have to change the code, or is it just a bug??
In the application "a" is a large array and must be vectorized for some matrix multiplication. Using the pointer I try to avoid copying data via "reshape".
If an array is eligible for 1D remapping, it should be OK to declare CONTIGUOUS. ifort is supposed to be capable then of any optimization which could be performed on a 1D array.
.. Is this a standard violation and do I have to change the code ..
Fortran standard allows the target of a pointer array of higher rank to be of rank one, not the other way around. So if you want the code to conform to the standard, then you would need to change it. If one's code has to operate on a so-called base data that are "quite large", then it makes sense to employ a target array of rank one for it. And as needed, have pointers of higher rank e.g., 2D map to relevant sections of such a base array:
<type>, target :: base_data(..) <type>, pointer :: matrix(:,:) matrix(1:m, 1:m) => base_data(idx:idx+m*m-1)
I read about the standard, but it seemed odd to me because internally a 2D is a 1D anyway. Cant see how a 1D pointer, probably forced to have the contiguous attribute, to a 2D array will cause trouble.
FortranFan's solution is ok but involves large code changes. Moreover, every blas level3 call would have to be prefaced by a pointer casting. Seems clumsy.