- #1
Bashkir
- 31
- 1
I'm writing a subroutine for solving Newton's method for the root of a function and I am coming across an interesting problem. This is the start of my code, where it is says the error is occurring
SUBROUTINE Newton(f, x1, x2, dx, aroot, error)
IMPLICIT NONE
! Declare Arguments
REAL, EXTERNAL :: f
REAL, INTENT(IN) :: x1
REAL, INTENT(IN) :: X2
REAL, INTENT(IN) :: dx
REAL, INTENT(OUT) : aroot
INTEGER, INTENT(OUT) :: error
! Declare parameter:
REAL, PARAMETER :: epsilon = 1.0E-5 ! Convergence criterion
!Declare local variables:
LOGICAL :: l_value_a ! True if f(xa) > 0
LOGICAL :: l_value_b ! True if f(xb) > 0
LOGICAL :: l_value_m ! True if f(xm) > 0
INTEGER :: i ! Index variable
INTEGER :: n ! Number of iterations
REAL :: value_a, value_b, value_m ! f(xa), f(xb), f(xm)
REAL :: xa, xb, xm ! Start, middle, end of interval
Now, when I try to compile the whole routine it gives me this error
REAL, INTENT(OUT) : aroot
1
Error: Invalid character in name at (1)
Newton.f90:1.38:
SUBROUTINE Newton(f, x1, x2, dx, aroot, error)
1
Error: Symbol 'aroot' at (1) has no IMPLICIT type
I'm really not sure where I am going wrong here. Any help would be appreciated. Thank you!
SUBROUTINE Newton(f, x1, x2, dx, aroot, error)
IMPLICIT NONE
! Declare Arguments
REAL, EXTERNAL :: f
REAL, INTENT(IN) :: x1
REAL, INTENT(IN) :: X2
REAL, INTENT(IN) :: dx
REAL, INTENT(OUT) : aroot
INTEGER, INTENT(OUT) :: error
! Declare parameter:
REAL, PARAMETER :: epsilon = 1.0E-5 ! Convergence criterion
!Declare local variables:
LOGICAL :: l_value_a ! True if f(xa) > 0
LOGICAL :: l_value_b ! True if f(xb) > 0
LOGICAL :: l_value_m ! True if f(xm) > 0
INTEGER :: i ! Index variable
INTEGER :: n ! Number of iterations
REAL :: value_a, value_b, value_m ! f(xa), f(xb), f(xm)
REAL :: xa, xb, xm ! Start, middle, end of interval
Now, when I try to compile the whole routine it gives me this error
REAL, INTENT(OUT) : aroot
1
Error: Invalid character in name at (1)
Newton.f90:1.38:
SUBROUTINE Newton(f, x1, x2, dx, aroot, error)
1
Error: Symbol 'aroot' at (1) has no IMPLICIT type
I'm really not sure where I am going wrong here. Any help would be appreciated. Thank you!