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

Using a part of an array as an argument in a function call

Anders_S_1
New Contributor III
847 Views

Hi,

I have a question how to use a part of an array as an argument in a function. How large a part I want to send to the subroutine varies.

Program

integer ix1,ix2,a(100,100)

do i=1,9

ix1=1+(i-1)*10

ix2=i*10

call sub(a(ix1:ix1+i,ix2:ix2+i))

enddo

stop

end

How shall I declare the array in subroutine sub to make it work (if possible)?

Best regards

Anders S

0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
847 Views

Best way is to declare as an assumed-shape array, (:,:). An explicit interface to the subroutine must be visible to the caller. See here.

View solution in original post

0 Kudos
2 Replies
Steve_Lionel
Honored Contributor III
848 Views

Best way is to declare as an assumed-shape array, (:,:). An explicit interface to the subroutine must be visible to the caller. See here.

0 Kudos
Anders_S_1
New Contributor III
847 Views

Hi Steve,

Thanks a lot for a rapid answer! Your suggestion has already been implemented and works fine.

Best regards

Anders S

0 Kudos
Reply