Fortran-95中的Rank 1转置 - 递归I / O操作错误

时间:2017-06-07 16:13:39

标签: fortran intel-fortran

我正在尝试编写一个接受秩1矩阵(行向量)并输出列向量的函数,因为内置TRANSPOSE()不接受秩1矩阵。当我使用行向量A = [1 2 3]调用以下函数时,我得到:

forrtl: severe (40): recursive I/O operation, unit -1, file unknown

在程序的输出窗口中。

! 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

出了什么问题?

此外,Rank 1矩阵换位是否有不同的内置函数?

编辑:在主程序中添加了调用该函数的代码。

0 个答案:

没有答案