通用“ fminsearch”

时间:2019-02-24 03:53:55

标签: optimization fortran overloading

我已经在fortran90中编写了以下程序:

module constants


   real*8, parameter :: zero = 0.0d0
   real*8, parameter :: one = 1.0d0
   real*8, parameter :: two = 2.0d0

end module constants

module common

   use constants
   real*8 :: a_A, a_B, e_A, e_B, b_A, b_B

end module common   

module procedures

   use constants

   contains

   function f(p)

      use common

      real*8, dimension(2), intent(in) :: p
      real*8, dimension(2) :: f

      f(1) = a_A*((two*p(1)/p(1) + p(2))**(-e_A)) - (exp(b_A*p(1)) - one)
      f(2) = a_B*((two*p(2)/p(1) + p(2))**(-e_B)) - (exp(b_B*p(2)) - one)

      f = f

      return

   end function f

   subroutine wait

      write(6,"('Waiting...')")
      read *

      return

   end subroutine wait

end module procedures

program main 

   use constants
   use common
   use procedures
   use toolbox

   real*8, dimension(2) :: plow,phigh,pmin   

   a_A = one
   a_B = one
   e_A = one
   e_B = one
   b_A = 0.1d0
   b_b = 0.1d0


   plow(1) = 6.0d0
   plow(2) = 6.0d0

   phigh(1) = 8.0d0
   phigh(2) = 8.0d0

   pmin = one

   call fminsearch(pmin,fret,plow,phigh,f)

   write(6,"(3f15.8)") pmin(1),pmin(2), fret

end program main  

当我运行它时,出现以下错误

call fminsearch(pmin, fret, plow, phigh, f)
                                     1
Error: There is no specific subroutine for the generic ‘fminsearch’ at (1) 

我认为函数参数存在问题,但是有人可以让我更清楚地了解出什么问题吗?我是fortran的新手,不太了解。据我所知,我已经用intent(in)声明了x并声明了该函数的向量输出。

谢谢

0 个答案:

没有答案