Fortran subroutine looks like this:
subroutine MatMult(a, b, m, n, k, answer)
!DEC$ ATTRIBUTES DLLEXPORT :: MatMult
!DEC$ ATTRIBUTES ALIAS: 'MatMult' :: MatMult
!DEC$ ATTRIBUTES REFERENCE :: a
!DEC$ ATTRIBUTES REFERENCE :: b
!DEC$ ATTRIBUTES REFERENCE :: answer
!DEC$ ATTRIBUTES VALUE :: m, n, k
integer, intent(in) :: m, n, k
real(8), intent(in) :: a(m, n)
real(8), intent(in) :: b(n, k)
real(8), intent(out) :: answer(m, k)
!this is just a test
answer = transpose(matmul(transpose(a), transpose(b)));
end subroutine
Fortran’s code is compiled from f90 into a dll.
In Julia I call MatMult passing my arrays
function mult()
matrixSize = 2
mA = [[2 3] ; [4 5]]
mB = [[2 1] ; [4 1]]
mC = zeros(Float64, matrixSize, matrixSize)
ccall((:MatMult, "FortranWorker.dll"), Cvoid, (Ptr{Matrix{Float64}}, Ptr{Matrix{Float64}}, Int64, Int64, Int64,Ptr{Matrix{Float64}}), mA, mB, matrixSize, matrixSize, matrixSize, mC)
end
The array returned contains all zeroes. Unfortunately I can’t step into fortran code when debugging in VS Code. I’ve tried compiling fortran code as .so library - not the dll - but then Julia pretends not see my .so library. Could be because fortran is in f90 format and not in f95?
Any suggestions are appreciated!!!