Thursday, 5 September 2013

Overloading a subroutine and function in Fortran

Overloading a subroutine and function in Fortran

Is it possible to overload a subroutine and function using the interface
blocks? So one can call a procedure via a function or subroutine. For
example:
...
interface TestRoutine
module procedure TestRoutine_fun
module procedure TestRoutine_sub
end interface TestRoutine
Contains
function TestRoutine_fun(....) result(...)
...
end function TestRoutine_fun
subroutine TestRoutine_sub(...)
...
end subroutine TestRoutine_sub
...
When I tried to compile code similar to this I got the error: Error: In
generic interface 'TestRoutine' at (1) procedures must be either all
SUBROUTINES or all FUNCTIONs. Thanks in advance!

No comments:

Post a Comment