1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Am I using interfaces in Fortran correctly?

  1. Jul 23, 2011 #1
    I'm having problems compiling files with interfaces in Fortran. My compiler is NAG Fortran Compiler Release 5.2. I get this error:

    -------------------------------------
    Error: subroutines.f90, line 2: USE TEST_MOD in program-unit MY_SUB imports
    symbol MY_SUB
    detected at TEST_MOD@<end-of-statement
    ---------------------------------------

    This happens when I try to compile this file, called 'subroutines.f90':

    Code (Text):

    subroutine my_sub (a)
      use test_mod
      real a
      print *, a
    end subroutine
     
    The mod file 'test_mod' it refers to compiles correctly, and its code is here:

    Code (Text):

    module test_mod interface
      subroutine my_sub (a)
        real a
      end subroutine
    end interface
    end module

    END
     
    Am I using the correct code, or is something wrong here? Thanks!
     
  2. jcsd
  3. Aug 17, 2011 #2
    I'm not really a Fortran programmer, but it seems like you're importing a subroutine called my_sub into another one of the same name. What exactly are you trying to do?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook