I am having trouble with a function that returns a (small) 5-dimensional array. The behavior is so strange, I think it must be caused by a bug in the compiler - though I am pretty new to Fortran so I could be wrong.
I'm running the latest compiler (version 7.0.0.0) on Windows 8.
I have written some simplified code which triggers the problem:
program main
use testModule
implicit none
integer, parameter :: r1=10,r2=2,r3=10,r4=2
integer, parameter :: res(4) = (/r1,r2,r3,r4/)
real :: x(r1,r2,r3,r4,4)
x = testFunction(res)
print*,'Press ENTER to close'
read*
end program main
with the following module in its own ft95 file:
module testModule
implicit none
contains
function testFunction(res) result(x)
integer, intent(in) :: res(4)
real :: x(res(1),res(2),res(2),res(4),4)
x = 1
end function testFunction
end module testModule
At the moment, the following error at occurs runtime: 'Attempt to call a routine with an inconsistent INTERFACE relating to the return type' (with the debugger pointing to the line where testFunction is called).
But as I have been fiddling around trying to figure out the problem, I have also seen access violation and out of memory errors. Furthermore, the problem goes away when the module is included in the same ft95 file as the main program - but not unless the IDE is first restarted. So it all seems pretty bizarre.
I'm going to try to find a workaround, but any help would be appreciated.