Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

F08 warning when using a 1D pointer for a 2D array (bound remapping)

may_ka
Beginner
356 Views

Hi all,

this code:

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".

 

Thanks

 

0 Kudos
3 Replies
TimP
Honored Contributor III
356 Views

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.

0 Kudos
FortranFan
Honored Contributor II
356 Views

may.ka wrote:

.. 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)

 

0 Kudos
may_ka
Beginner
356 Views

Hi,

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.

cheers
 

0 Kudos
Reply