I'm somewhat new to Fortran, but I'm starting to collect a lot of functions and subroutines in modules that I use over and over again. I've been trying to build my own library so that I could call some of these functions and subroutines from new source code that I write. So far I've been able to get the subroutines to work, but not the functions. I just don't know how to call the function from with in the code.
Here's an example. The following function takes in an integer and returns the Identity matrix.
module test
contains
function IDENTITY(rows) !RETURNS THE IDENTITY MATRIX
real, dimension(rows,rows) :: IDENTITY
integer, intent(in) :: rows
integer :: i, j
!f2py intent(in) rows
!f2py intent(out) IDENTITY
!f2py depend(rows) IDENTITY
IDENTITY = ZEROS(rows,rows)
do i = 1, rows
do j = 1, rows
if (i == j) then
IDENTITY(i,j) = 1
endif
enddo
enddo
end function IDENTITY
end module
Now I compile this into an object file then archive it into a library. I then write a small program in which I'd like to use this function--and here's the problem I want to avoid. I've figured I have to put a \use\ statement in my source so that it will use the module. Then I've got to include the path to the .mod when compiling. But eventually, I'm going to have a whole section full of use statements. I'd like to avoid having to do all those things and just make everything nice and neat. Is there a way? Any help would be great,
Thank You