Search code examples
modulefortranfortran90subroutine

Is there a way to distinguish between subroutines of the same name in two different fortran90 modules?


If I am unfortunate enough to have to work with two different Fortran90 modules that have a subroutine name in common, is there a way to distinguish between the two subroutines?


Solution

  • You can use only:

    module m1
    contains
      subroutine sub
      end subroutine
    
      subroutine other_m1
      end subroutine
    end module
    
    module m2
    contains
      subroutine sub
      end subroutine
    
      subroutine other_m2
      end subroutine
    end module
    
      use m1, only: sub, other_m1
      use m2, only: other2
    
      call sub
    end
    

    You can also rename one of them in the use statement:

      use m1
      use m2, some_other_name => sub
    
      call sub
    end