0

So I am trying to create a function in Fortran for an ODE and later want to use this code for methods such as Runge-Kutta etc. However I am having trouble coding the initial ode function that I want to use to calculate the rhs given a x and y value.

Here's my code, if anyone can spot anything obvious:

  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

and I am getting these errors

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
SFL
  • 1
  • 3

0 Answers0