Help with FORTRAN error message

  • Context: Comp Sci 
  • Thread starter Thread starter Daniel1992
  • Start date Start date
  • Tags Tags
    Error Fortran
Click For Summary
SUMMARY

The FORTRAN error message "Invalid character in name" arises from the incorrect use of the exponentiation operator. In FORTRAN, the correct operator for exponentiation is '**', not '^'. Additionally, constants such as Pi and e must be defined in the program prior to their use. Properly defining these constants and using the correct operator will resolve the error.

PREREQUISITES
  • Basic understanding of FORTRAN programming syntax
  • Knowledge of defining constants in FORTRAN
  • Familiarity with mathematical operations in FORTRAN
  • Understanding of error messages in programming
NEXT STEPS
  • Learn how to define constants in FORTRAN
  • Study the correct use of operators in FORTRAN, particularly '**' for exponentiation
  • Explore common FORTRAN error messages and their resolutions
  • Review mathematical functions and their implementations in FORTRAN
USEFUL FOR

Students learning FORTRAN, programmers debugging FORTRAN code, and anyone interested in mathematical programming in FORTRAN.

Daniel1992
Messages
21
Reaction score
0

Homework Statement



I get the follwing error message in the FORTRAN program I am trying to code.

P(i)=(1/(sigma*sqrt(2*Pi)))*e^(-(x-xbar)^2/(2*sigma^2))
----------------------------1
Error: Invalid character in name at (1)

I assume this means there is something it doesn't like about 2*Pi but I can't work out what it is.

Any help would be appreciated.
 
Physics news on Phys.org
1 Pi should be defined elsewhere in your program, as should the constant e.
2. the character ^ is not used for exponentiation. The double * is the proper operator, thus x*x = x**2.
 
Well that was abvious :rolleyes:

forgot that '**' is used to creates powers.

Thanks for that :)
 

Similar threads

Replies
4
Views
3K
Replies
7
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K