I am trying to write a function that takes in a rank 1 matrix (a row vector) and outputs a column vector as the inbuilt TRANSPOSE()
does not accept rank 1 matrices. When I call the following function using a row vector A = [1 2 3]
, I get:
forrtl: severe (40): recursive I/O operation, unit -1, file unknown
in the program's output window.
! Below is the code in the main program that ends up calling rowToColumnVec
REAL, DIMENSION(1:3,1) :: A, B, C ! Define 3 column vectors
INTEGER :: length
length = SIZE(A, DIM = 1)
CALL oneDimInput(A, length)
CALL oneDimInput(B, length)
WRITE(*,*) "A = ", A
READ(*,*)
WRITE(*,*) "A transpose is ", rowToColumnVec(A)
READ(*,*)
! Below is code that exists in a separate .f90 file that is used by the main
! program. I know that the main program has no problem running other
! functions and subroutines from this .f90 file.
FUNCTION rowToColumnVec(A)
IMPLICIT NONE
REAL, DIMENSION(1,1:3), INTENT(IN) :: A
REAL, DIMENSION(1:3,1) :: B
REAL, DIMENSION(1:3,1) :: rowToColumnVec
B(1,1) = A(1,1)
B(2,1) = A(1,2)
B(3,1) = A(1,3)
rowToColumnVec(1,1) = B(1,1)
rowToColumnVec(2,1) = B(2,1)
rowToColumnVec(3,1) = B(3,1)
WRITE(*,*) "Shape B: ", SHAPE(B)
READ(*,*)
END FUNCTION rowToColumnVec
What is going wrong?
Also, is there a different built in function for Rank 1 matrix transposition?
Edit: added code in main program that calls the function.