Is there a way to do something like the following in Fortran without having to do it explicitly for every dimension array?
Module OverloadTest
interface arrayStuff
module procedure :: arrayStuff_NxN, arrayStuff_2x2
end interface
contains
function arrayStuff_NxN(A) result(output)
real*8,dimension(:,:) :: A
real*8, dimension(size(A,1), size(A,2)-1) :: output
!code and stuff to populate output
end function arrayStuff_NxN
function arrayStuff_2x2(A) result(output)
real*8,dimension(:,:) :: A
real*8 :: output
!code and stuff to populate output
end function arrayStuff_2x2
End Module OverloadTest
To clarify I would like to be able to call arrayStuff function and if it is a 2x2 array I'd like it to pick the 2x2 and for all other sizes pick the NxN without having to specifically make a function for 3x3, 4x4, 5x5, ect.