Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
2 Views

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

Jump to solution

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

Accepted Solutions
Highlighted
Black Belt
2 Views

Best way is to declare as an

Jump to solution

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

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran

View solution in original post

0 Kudos
2 Replies
Highlighted
Black Belt
3 Views

Best way is to declare as an

Jump to solution

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

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran

View solution in original post

0 Kudos
Highlighted
Beginner
2 Views

Hi Steve,

Jump to solution

Hi Steve,

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

Best regards

Anders S

0 Kudos