PDA

View Full Version : Fortran subarrays


natski
Aug30-10, 01:17 PM
Dear all,

I am using f90 and trying to pass only one column/row of an array into a subroutine. So I want something like...

call test(x(1,:),....)

If "test" defines the first entry as a vector, will this work?

Natski

minger
Sep1-10, 11:59 AM
It will work, so long as the variable in the subroutine has the proper shape. Also, you're syntax is a little wrong, here's what it would look like:

DIMENSION(10,10,10) :: x

CALL test( x(:,1,1) )
END PROGRAM

SUBROUTINE test
DIMENSION(:),INTENT(whatever) :: x
...

There are a few different methods to sizing the array in the subroutine. Often times we'll not specify the size and let the compiler use an "assumed" array sizing.