创建ODE函数Fortran

时间:2017-11-21 13:23:31

标签: function fortran ode

所以我试图在Fortran中为ODE创建一个函数,然后想要将此代码用于Runge-Kutta等方法。但是我在编写初始的ode函数时遇到了麻烦,我想用它来计算rhs给出xy值。

这是我的代码,如果有人能发现任何明显的事情:

  PROGRAM odemod

  IMPLICIT NONE

  REAL :: x,y,z

  PRINT*,"Enter number one"      
  READ*,x

  PRINT*,"Enter number two"     
  READ*,y

  z=ode(x,y)

  PRINT '("Answer = ",f10.4)',z

CONTAINS

  FUNCTION ode(x,y)      
    IMPLICIT NONE

    REAL, INTENT(IN) :: x,y

    ode=-y+2*x+4           
  END FUNCTION ode

END PROGRAM odemod

我收到这些错误

f90 -o odemod odemod.f90 odemod.f90:18.2:

  FUNCTION ode(x,y)   1 Error: Function result 'ode' at (1) has no IMPLICIT type odemod.f90:8.9:

  READ*,x
         1 Error: Symbol 'x' at (1) has no IMPLICIT type odemod.f90:10.9:

  READ*,y
         1 Error: Symbol 'y' at (1) has no IMPLICIT type

0 个答案:

没有答案