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

vector subscript of an array

Pierre_Archambeau
227 Views

Hi,

Could you explain the difference between the two calls?

The first call changes the expected values ​​while the second provides zero.

Thanks,

Pierre

 

    module essai
    
    contains

        subroutine testarray(array)
            real(4),dimension(:) :: array
            array(:)=1      
        end subroutine      

    end module
    
    program moi
    
    use essai
    
    real(4), dimension(1,20), target :: array
    integer, dimension(2) :: part = (/1,4/)
   
    array=0
    call testarray(array(1,1:4:3))

    array=0
    call testarray(array(1,part))

    end program

    

 

 

0 Kudos
2 Replies
mecej4
Honored Contributor III
227 Views

In the second CALL, the actual argument is an array section with a variable used to designate the section. Therefore, I believe, the actual argument is an expression and is, therefore, in the subroutine you are not allowed to assign a value to it.

0 Kudos
Steven_L_Intel1
Employee
227 Views

The second call uses what is called a "vector subscript". This causes a temporary copy to be passed and any changes discarded. Consider what would happen if part was defined instead as (/3,3/).

0 Kudos
Reply