Am I using interfaces in Fortran correctly?

  • Context: Comp Sci 
  • Thread starter Thread starter ASGtFT
  • Start date Start date
  • Tags Tags
    Fortran
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
ASGtFT
Messages
10
Reaction score
0
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:
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:
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!
 
Physics news on Phys.org
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?