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

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

Anders_S_1
Novice
499 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
Black Belt Retired Employee
499 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

2 Replies
Steve_Lionel
Black Belt Retired Employee
500 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.

Anders_S_1
Novice
499 Views

Hi Steve,

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

Best regards

Anders S

Reply