Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran subarrays

  1. Aug 30, 2010 #1
    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?

  2. jcsd
  3. Sep 1, 2010 #2


    User Avatar
    Science Advisor

    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:
    Code (Text):

    DIMENSION(10,10,10) :: x

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

    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.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook