1

I have functions and subroutines in my module. Then I use that module inside the main program. But inside my module there is function where I call another function. While I compile that it says undefined reference in Fortran.

module A
  implicit none
  real*8 :: k(1:4),ls(1:4)
contains
  function B(p,q)
    implicit none
    real*8 :: p,q,B
     B=p+q
  end function B

  subroutine C(u,v,res)
   implicit none
   real*8 :: u,v,res,B

   res=B(u,v)

  end subroutine
end module A

program main
  use A
  implicit none
  real*8 :: Out
  call C(4.d0,3.d0,out)
  write(*,*) out
end program main

I would like to get 7.0d0 ,but I am getting undefined reference in Fortran for B.

francescalus
  • 30,576
  • 16
  • 61
  • 96

0 Answers0