New to Fortran (just started today), having trouble with the natural logarithm:
PROGRAM log
IMPLICIT NONE
REAL :: x
PRINT *, "Enter a number:"
READ *, x
x = log (x)
PRINT *, "The natural log of x is:", x
END PROGRAM log
The compiler keeps throwing up the error:
x = log (x)
1
Error: Symbol at (1) is not appropriate for an expression
Other intrinsic functions work fine. What am I doing wrong?
The problem is that you’ve shadowed (overridden) the definition of the symbol
log– which would normally refer to the standard library mathematical function – with the name of your program, which is alsolog. If you change the name of the program to, say,logtest:You’ll find that the program works as expected.