IS_CONTIGUOUS(3) - [ARRAY:INQUIRY] Test if object is contiguous
result = is_contiguous(array)
logical function is_contiguous(array)type(TYPE(kind=**)),intent(in) :: array
o a kind designated as ** may be any supported kind for the type o ARRAY may be of any type. It shall be an array or assumed-rank. If it is a pointer it shall be associated. o the result is a default logical scalar
IS_CONTIGUOUS(3) returns .true. if and only if an object is contiguous.
An object is contiguous if it is
An object is not contiguous if it is an array subobject, and
o (1) an object with the CONTIGUOUS attribute, o (2) a nonpointer whole array that is not assumed-shape, o (3) an assumed-shape array that is argument associated with an array that is contiguous, o (4) an array allocated by an ALLOCATE statement, o (5) a pointer associated with a contiguous target, or o (6) a nonzero-sized array section provided that
o (A) its base object is contiguous, o (B) it does not have a vector subscript, o (C) the elements of the section, in array element order, are a subset of the base object elements that are consecutive in array element order, o (D) if the array is of type character and a substring-range appears, the substring-range specifies all of the characters of the parent-string, o (E) only its final part-ref has nonzero rank, and o (F) it is not the real or imaginary part of an array of type complex. It is processor-dependent whether any other object is contiguous.
o the object has two or more elements, o the elements of the object in array element order are not consecutive in the elements of the base object, o the object is not of type character with length zero, and o the object is not of a derived type that has no ultimate components other than zero-sized arrays and o characters with length zero.
o ARRAY : An array of any type to be tested for being contiguous. If it is a pointer it shall be associated.
The result has the value .true. if ARRAY is contiguous, and .false. otherwise.
Sample program:
program demo_is_contiguous implicit none intrinsic is_contiguous real, DIMENSION (1000, 1000), TARGET :: A real, DIMENSION (:, :), POINTER :: IN, OUT IN => A ! Associate IN with target A OUT => A(1:1000:2,:) ! Associate OUT with subset of target A ! write(*,*)IN is ,IS_CONTIGUOUS(IN) write(*,*)OUT is ,IS_CONTIGUOUS(OUT) ! end program demo_is_contiguousResults:
IN is T OUT is F
Fortran 2008
****(3)
fortran-lang intrinsic descriptions
Nemo Release 3.1 | is_contiguous (3fortran) | April 28, 2024 |