Fortran Using Fortran Subarrays in f90: Passing Single Columns/Rows into a Subroutine

  • Thread starter Thread starter natski
  • Start date Start date
  • Tags Tags
    Fortran
AI Thread Summary
Passing a single column or row of an array to a subroutine in Fortran 90 is feasible as long as the subroutine is defined with the correct array shape. The syntax for calling the subroutine should be adjusted for clarity, such as using "CALL test(x(:,1,1))" for a specific column. In the subroutine, the array can be declared with "DIMENSION(:), INTENT(whatever)" to allow for flexible sizing. It's common practice to use assumed array sizing, which lets the compiler determine the dimensions based on the passed argument.
natski
Messages
262
Reaction score
2
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
 
Technology news on Phys.org
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:
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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
3
Views
2K
Replies
59
Views
11K
Replies
2
Views
7K
Replies
8
Views
4K
Replies
5
Views
3K
Replies
5
Views
8K
Back
Top