Recently I encountered unexpected behavior of Fujitsu Fortran Version 2.0.0 while dealing with a subroutine which has dummy array with the contiguous
attribute.
I have reduced the problem to a simple example which is here:
program test
INTEGER, DIMENSION(:,:), ALLOCATABLE :: t
INTEGER :: i, j
ALLOCATE(t(3,3))
DO i = 1, 4
DO j = 1, 4
t(i,j) = i*j
!!PRINT *, t(i,j)
END DO
END DO
CALL fun(t(2,1:4:2))
DEALLOCATE(t)
CONTAINS
SUBROUTINE fun(arg)
! Contiguous dummy argument arg
INTEGER, CONTIGUOUS :: arg(:)
PRINT *, arg(2)
END SUBROUTINE
end program test
That pice of code can be successfully compiled by gfortran (GNU Fortran (GCC) 6.3.0) but fails on cluster with Fujitsu Fortran compiler (mentioned above) giving the following error code:
"test_contiguous.f90", line 13: The actual argument number 1 of procedure 'fun' corresponding to a dummy argument 'arg' with the CONTIGUOUS attribute must be contiguous.
I am confused because as I understood compiler should make a contiguous temporary at the entrance of the subroutine (as is shown for example here: Fortran 2008 contiguous)
In fact I have two questions:
- What is specification for such situation?
- Can it be a flag for compiler forcing him to create a contiguous temporary for such case?
I am trying to build third-party software and cannot change the source as I want.