Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

CONTIGUOUS attribute for dummy arguments: what happens when the actual argument is not contiguous?

$
0
0

Steve,

The code listed below compiles and runs without any errors in Intel Fortran XE 2013 Update 2 (13.1.0.149).  And it writes out a result value of false for the statement on line 27.  But do you think this is correct?  I was expecting a compiler error given the CONTIGUOUS attribute on the dummy argument in AssumedShape subroutine?  Does it not require that the actual argument has to be simply contiguous and which is not the case here?

You would recall from the Fortran 2008 standard:

5 5.3.7 CONTIGUOUS attribute
6 C530 An entity with the CONTIGUOUS attribute shall be an array pointer or an assumed-shape array.
7 1 The CONTIGUOUS attribute specifies that an assumed-shape array can only be argument associated with a
8 contiguous effective argument, or that an array pointer can only be pointer associated with a contiguous target.
9 2 An object is contiguous if it is
10 (1) an object with the CONTIGUOUS attribute,
11 (2) a nonpointer whole array that is not assumed-shape,
12 (3) an assumed-shape array that is argument associated with an array that is contiguous,
13 (4) an array allocated by an ALLOCATE statement,
14 (5) a pointer associated with a contiguous target, or
15 (6) a nonzero-sized array section (6.5.3) provided that
16 (a) its base object is contiguous,
17 (b) it does not have a vector subscript,
18 (c) the elements of the section, in array element order, are a subset of the base object elements
19 that are consecutive in array element order,
20 (d) if the array is of type character and a substring-range appears, the substring-range specifies all
21 of the characters of the parent-string (6.4.1),
22 (e) only its final part-ref has nonzero rank, and ..

 

PROGRAM p
 
   IMPLICIT NONE
 
   INTEGER, ALLOCATABLE :: a(:,:)
   INTEGER :: Istat
 
   ALLOCATE(a(5,5), STAT=Istat)
   IF (Istat /= 0) THEN
      STOP
   END IF
 
   a = 0
 
   CALL AssumedShape(a(3,:))
 
   STOP
 
CONTAINS
 
   SUBROUTINE AssumedShape(arg)
 
      !..
      INTEGER, CONTIGUOUS, INTENT(IN) :: arg(:)
 
      !..
      WRITE(*,*) "Is arg contiguous? ",IS_CONTIGUOUS(arg)
 
      RETURN
 
   END SUBROUTINE AssumedShape
 
END PROGRAM p

Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>