Manual Reference Pages  - associated (3fortran)

NAME

ASSOCIATED(3) - [STATE:INQUIRY] Association status of a pointer or pointer/target pair

SYNOPSIS

result = associated(pointer [,target])

         logical function associated(pointer,target)

type(TYPE(kind=KIND)),pointer :: pointer type(TYPE(kind=KIND)),pointer,optional :: target

CHARACTERISTICS

o POINTER shall have the pointer attribute and it can be any type or may be a procedure pointer
o TARGET shall be a pointer or a target. It must have the same type, kind type parameter, and array rank as POINTER.
o The association status of neither POINTER nor TARGET shall be undefined.
o the result is a default logical value

DESCRIPTION

ASSOCIATED(3) determines the status of the pointer POINTER or if POINTER is associated with the target TARGET.

OPTIONS

o POINTER : A pointer to test for association. Its pointer association status shall not be undefined.
o TARGET : A target that is to be tested for occupying the same storage units as the pointer POINTER. That is, it is tested as to whether it is pointed to by POINTER.

RESULT

ASSOCIATED(3) returns a scalar value of type logical. There are several cases:
1. When the optional TARGET is not present then ASSOCIATED(POINTER) is [char46]true. if POINTER is associated with a target; otherwise, it returns [char46]false..
2. If TARGET is present and a scalar target, the result is .true. if TARGET is not a zero-sized storage sequence and the target associated with POINTER occupies the same storage units. If POINTER is disassociated, the result is .false..
3. If TARGET is present and an array target, the result is .true. if TARGET and POINTER have the same shape, are not zero-sized arrays, are arrays whose elements are not zero-sized storage sequences, and TARGET and POINTER occupy the same storage units in array element order.

As in case 2, the result is .false., if POINTER is disassociated.

4. If TARGET is present and an scalar pointer, the result is .true. if TARGET is associated with POINTER, the target associated with TARGET are not zero-sized storage sequences and occupy the same storage units.

The result is .false., if either TARGET or POINTER is disassociated.

5. If TARGET is present and an array pointer, the result is .true. if target associated with POINTER and the target associated with TARGET have the same shape, are not zero-sized arrays, are arrays whose elements are not zero-sized storage sequences, and TARGET and POINTER occupy the same storage units in array element order.
6. If TARGET is present and is a procedure, the result is true if and only if POINTER is associated with TARGET and, if TARGET is an internal procedure, they have the same host instance.
7. If TARGET is present and is a procedure pointer, the result is true if and only if POINTER and TARGET are associated with the same procedure and, if the procedure is an internal procedure, they have the same host instance.

EXAMPLES

Sample program:

    program demo_associated
    implicit none
    real, target  :: tgt(2) = [1., 2.]
    real, pointer :: ptr(:)
       ptr => tgt
       if (associated(ptr)     .eqv. .false.) &
       & stop ’POINTER NOT ASSOCIATED’
       if (associated(ptr,tgt) .eqv. .false.) &
       & stop ’POINTER NOT ASSOCIATED TO TARGET’
       if (associated(ptr) ) &
       & print *, ’POINTER ASSOCIATED’
       if (associated(ptr,tgt) ) &
       & print *, ’POINTER ASSOCIATED TO TARGET’
    end program demo_associated

Results:

     >  POINTER ASSOCIATED
     >  POINTER ASSOCIATED TO TARGET

STANDARD

Fortran 95

SEE ALSO

NULL(3)

Fortran intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 associated (3fortran) November 02, 2024
Generated by manServer 1.08 from 4f5ff0bb-c642-4c41-9ba9-64d305dcf4f7 using man macros.