Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.
1697 Discussions

Passing a coarray subarray to a function gives a wrong part of the array

sparonuz
Beginner
694 Views

I'm attempting to understand how to pass a slice of a multidimensional co-array to a function. I would like to use a function like this:

   function get_int_vec(vec_int_2get, rank) result(ret_val)
      implicit none
      integer,  dimension(:), codimension
  • , intent(in) :: vec_int_2get integer, intent(in) :: rank integer, allocatable, dimension(:) :: ret_val ret_val = vec_int_2get(:)[rank] end function ! get_int_vec
  • It works fine to get an entire array. But when passing a slice of a coarray, like:

     vec_getA(:) = get_int_vec(matrix_A(n, :), rank)

    where matrix_A is declared as

      integer, dimension(:, :), codimension[:],  allocatable :: matrix_A
    
    and properly allocated, I always get the first column of matrix_A instead of the n-th.
    I am compiling with Intel Parallel Studio XE 2018 cluster edition.
    I am attaching a minimal working example of the problem: it should print the same number as the rank of the image that is printing, instead of always 1.
    Thank you in andvance for the attention.
     
    0 Kudos
    0 Replies
    Reply