我正在尝试编写一个程序来计算两个向量的叉积(输入是“真实”类型,例如 [1.3 3.4 1,5])。但我不断收到许多错误:
program Q3CW
implicit none
REAL :: matA(3), matB(3)
REAL :: A11, A12, A13
REAL :: B11, B12, B13
real :: productc(3), answer(3)
read*,A11, A12, A13
read*,B11, B12, B13
matA = (/A11, A12, A13/)
matB = (/B11, B12, B13/)
answer = productc(matA, matB)
print*,'Answer = ', answer(1), answer(2), answer(3)
end program
real function productc(matIn1, matIn2)
real, dimension(3) :: matIn1, matIn2
productc(1)=(/matIn1(2)*matIn2(3)-matIn1(3)*matIn2(2)/)
productc(2)=(/matIn1(3)*matIn2(1)-matIn1(1)*matIn2(3)/)
productc(3)=(/matIn1(1)*matIn2(2)-matIn1(2)*matIn2(1)/)
end function
这是我得到的错误:
Error: Q33333.f95(20) : Statement function definition for pre-existing procedure PRODUCTC; detected at )@=
Error: Q33333.f95(21) : Statement function definition for pre-existing procedure PRODUCTC; detected at )@=
Error: Q33333.f95(22) : Statement function definition for pre-existing procedure PRODUCTC; detected at )@=
Warning: Q33333.f95(23) : Function PRODUCTC has not been assigned a value; detected at FUNCTION@<end-of-statement>
Build Result Error(3) Warning(1) Extension(0)
知道问题可能是什么吗?