Fortran Natural Logarithm Error

New to Fortran (just started today), faced 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 continues to throw an error:

 x = log (x) 1 Error: Symbol at (1) is not appropriate for an expression 

Other internal functions work fine. What am I doing wrong?

+4
source share
1 answer

The problem is that you overshadowed (redefined) the definition of the log symbol - which would usually refer to the mathematical function of the standard library - with the name of your program, which is also equal to log . If you change the name of the program to, say, logtest :

 PROGRAM logtest ... END PROGRAM logtest 

You will find that the program is working properly.

+7
source

Source: https://habr.com/ru/post/1442542/


All Articles