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

anomalies with ASSOCIATEd names and elemental procedures

joseph_battelle
Beginner
911 Views
In the current compiler there are anomalies in which assignments are allowed in elemental functions when the ASSOCIATE construct is used. It seems some associated names take on host-associated status. Nesting ASSOCIATE constructs removes this status--even for actual host-associated selectors. In all cases using the selector directly instead of the associate-name inside the construct "does the right thing" even when the associate-name does not. See examples below. I haven't grok'd enough of the standard to know whether something that is "construct associated" keeps track of--or magically gains--"host association" status so my expectations below in the code may not be standard conforming.
Compiling with Intel Visual Fortran 11.1.065 [IA-32]...

[fortran]module M5

  type :: option
    integer :: id = 0
    integer :: form = 0
    logical :: multi = .false.
    integer :: code
  end type option
  
  integer :: hosted = 0
  
contains

    elemental subroutine set (opt)
        type(option), intent(inout) :: opt
        
        associate (f => opt% form, r => opt% code, t=>hosted)     
            associate (s => opt% code, u=>hosted)
                select case (f)
                case (0) !OK; assign without using associate-name
                    opt% code = 5   ! EXPECTED as opt is not host associated
                case (1) !error #7617: This host associated object appears in a 'defining' context
                         ! in a PURE procedure or in an internal procedure contained in a PURE procedure.   
                    r = 5           ! UNEXPECTED; should be same as case 0             
                case (2) !OK; assign through inner-most associate-name    
                    s = 5           ! removes host-associated status
                case (3) !error #7617: This host associated object appears in a 'defining' context
                         ! in a PURE procedure or in an internal procedure contained in a PURE procedure.          
                    t = 5           ! EXPECTED; associate-name t is host associated
                case (4) !OK
                    u = 5           ! UNEXPECTED; expect to be same as case 3 and 5
                case (5) !error #7617: This host associated object appears in a 'defining' context
                         ! in a PURE procedure or in an internal procedure contained in a PURE procedure.          
                    hosted = 5      ! EXPECTED; hosted is host associated
                end select
            end associate
        end associate
        
    end subroutine set
  
  subroutine foo()
    type(option) :: v(5)
    call set(v)
  end subroutine foo
  
end module[/fortran]
0 Kudos
1 Solution
Steven_L_Intel1
Employee
911 Views
Escalated as issue DPD200157282. Thanks for the nice test case.

View solution in original post

0 Kudos
4 Replies
joseph_battelle
Beginner
911 Views
Bump. Just want to make sure this doesn't get overlooked because the compiler is definitely acting strange and inconsistently when combining associate and elemental procedures. The nested associate shows more weirdness but isn't required. The error that is forcing me to stop using associate in my code is at the first level.
0 Kudos
Steven_L_Intel1
Employee
911 Views
Thanks - we'll take a look at this.
0 Kudos
Steven_L_Intel1
Employee
912 Views
Escalated as issue DPD200157282. Thanks for the nice test case.
0 Kudos
Steven_L_Intel1
Employee
911 Views
This was fixed in version 12.
0 Kudos
Reply