I am learning to program in fortran and was making a basic program. In it I am trying to return an array from a function in my program, which is resulting in this error: Interface mismatch in global procedure 'test1' at (1): Rank mismatch in function result (0/1)
.
Below is a reconstruction of the error:
program Test
implicit none
integer :: a
interface
function test1(n) result (m)
integer :: n
end function test1
end interface
a = test1(4)
end program Test
function test1(n) result (m)
implicit none
integer :: n, m(2)
m(1) = n**2
end function test1
The error is after the interface
statement at function test1(n) result (m)
.
Since I am new to fortran, I assume I have missed something basic so any help is appreciated.