Attempt to call a routine with argument as a procedure when a real was required

142 Views Asked by At

I have a Fortran program that compiles without problems, but then gets an error:

Attempt to call a routine with argument number one as a procedure when a real(kind=2) was required

ROOTS!X_ROOT - in file exercise2base.f90 at line 20 [+0074]

main - in file exercise2base.f90 at line 65 [+00c8]

I don't really know what this means, I thought maybe it means that I pass an argument to some function which is not the right type, but the references that are given don't make sense:

  • line 20 is end function x_rtsmpl
  • line 66 is answer=x_root(bb_integral,l1,l2,epsx,epsf,root_type)

so I don't understand what's going on...

I'm using Silverfrost with Plato IDE.

module roots
  implicit none
  character(20) :: root_type

contains

  function x_rtsmpl(f,x1,x2,epsx,epsf) result(x_root)
    implicit none
    real(2) :: x_root
    real(2), intent(IN) :: x1,x2,epsx,epsf
    interface
      function f(x)
        implicit none
        real(2), intent(IN) :: x
        real(2) :: f
      end function f
    end interface
    real(2) :: xx,fx
    x_root=x1
  end function x_rtsmpl

  function x_root(f,x1,x2,epsx,epsf) result(x_r)
    implicit none
    real(2) :: x_r
    real(2), intent(IN) :: x1,x2,epsx,epsf
    interface
      function f(x)
        implicit none
        real(2), intent(IN) :: x
        real(2) :: f
      end function f
    end interface
      x_r=x_rtsmpl(f,x1,x2,epsx,epsf)
    return
  end function x_root

end module roots

module blackbody
  implicit none
  private
  public :: Ibb

contains
  function Ibb(lambda)
    real(2) , intent (in) :: lambda
    real(2) :: Ibb
    Ibb=lambda+1._2
    return
  end function Ibb

end module blackbody

program master

  use roots
  use blackbody
  implicit none
  real(2) :: l2,epsx,epsf,answer,l1,epsi,requested
  l1=4.d-7
  l2=1.d-4
  epsx=1.d-2*l1
  epsf=1.d-1
  epsi=1.d-4
  answer=x_root(Ibb,l1,l2,epsx,epsf)

end program master

EDIT: The code is now trimmed all the way down to its basic functions with only declarations and simple "dummy" calculations.

0

There are 0 best solutions below