Fortran Unclassifiable Statement error in fortran 90

  • Thread starter Thread starter Sandbox.WeC
  • Start date Start date
  • Tags Tags
    Error Fortran
Click For Summary
The discussion revolves around troubleshooting a Fortran program that encounters compilation errors related to unclassifiable statements. The program is designed to read values from a data file, perform logarithmic calculations, and write results to another file. Key issues identified include the incorrect use of square brackets instead of parentheses in the logarithmic calculations and the incorrect notation for scientific notation, where "1exp24" should be "1e24". Additionally, concerns were raised about the initial read statements, which may not have variables to store the read values, potentially causing further errors. The importance of compiler error messages, particularly line numbers, was also highlighted as a useful tool for debugging.
Sandbox.WeC
Messages
5
Reaction score
0
I'm writing this program for an assignment and I have run into a roadblock. I thought it was a pretty simple program, but I think my lack of experience with fortran is working against me.. Here is the bare code:

Program Readfile
implicit none
real(kind=8)::x,y,z,u,v
integer::n

OPEN(unit=12,file="file1.data")
OPEN(unit=13,file="file2.data")

read(12,*)
read(12,*)

DO n=1,38,1
read(12,*)x,y
z = LOG10[x]
u = LOG10[y]
v = LOG10[(x*x*x*y)/(1exp24)]
write(13,*)x,y,z,u,v
END DO

close(12)
close(13)
END PROGRAM

It is a simple concept. All it has to do is open file1 to get 2 values, then write in file2 those values, and a couple functions of them. The read(12,*) lines are used to skip the first two lines in file one, because they are junk. I am doing n=1,38 because there are 38 lines the program must do this to. The problem arises with the z= , u= , and v= statements. When I compile using the command gfortran file.f90 -o file.o it comes back and gives me Unclassifiable statement errors for all 3. What is my problem? Sorry if it is really obvious..
 
Technology news on Phys.org
The [ ] should be ( ).

Also 1exp24 should be 1e24, unless 1exp24 is a F90 "enhancement" over F77 that I don't know about.
 
In addition to what AlephZero said, your first two READ statements are probably causing problems. These statements require one or more variables for the value(s) read to be stored in. I haven't written any fortran code for about 15 years, but I think this is correct.

Does your compiler give the line number of the unclassifiable statement? That would be helpful information.
 
Mark44 said:
In addition to what AlephZero said, your first two READ
statements are probably causing problems. These statements require one or more variables for the value(s) read to be stored in.

I think those are OK. They will read and ignore the first two lines of the file, assuming that's what the OP wants to do.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
28K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K