Fortran Error when reading list, Fortran 77

AI Thread Summary
The discussion revolves around troubleshooting an error encountered while running a Fortran 77 simulation program using the g77 compiler. The error message indicates an "invalid number: incomprehensible list input," which occurs during a READ statement attempting to read data from a file named combin.fig. The user provides the context of their operating system setup, noting they are using a 64-bit Ubuntu but compiling in a 32-bit environment due to compatibility issues.Key insights from the conversation suggest that the error may not be with the format of the data being read, as the provided data appears correct. Instead, it is recommended to investigate earlier parts of the program to ensure that the correct amount of data is being read before this READ statement. A practical approach is suggested: print the data read by previous statements to confirm its accuracy. Additionally, a technique is mentioned to ensure data is written out correctly by using a flush command after write operations, which can help in diagnosing where the issue lies.
stenssok
Messages
1
Reaction score
0
Hello,

I'm trying to run a simulation program, written in Fortran 77 for the g77 compiler ( I use gcc version 3.4.6). I get the following error message when running the program:

invalid number: incomprehensible list input
apparent state: unit 3 named combin.fig
last format: list io
lately reading sequential formatted external IO
Aborted

The error is for the following READ statement:

Code:
READ(3,*) ((XPOS(J,IL),YPOS(J,IL),J=1,NABUR(IL)),IL=1,NL)

and the list it is trying to read, from the file combin.fig (unit 3), looks like this:

-1, 0.625, 2, 0.625, 0, 1.625, 1, 1.625,
-1, -0.375, 0, -0.375, 1, -0.375, 2, -0.375
-1, 0.375, 2, 0.375, 0, -0.625, 1, -0.625,
-1, 1.375, 0, 1.375, 1, 1.375, 2, 1.375

Maybe I should also give you the values of the variables:

NABUR = 8 8 0 0
NL = 2

I'm not very experienced in Fortran (or programming) so please keep it simple.

My OS is 64-bit Ubuntu 11.10 Oneric, but I compile in a chroot (32-bit Ubuntu 10.04 Natty) because the program doesn't compile in a 64-bit OS. Normally I can run the program in both systems.

Thanks
 
Technology news on Phys.org
Assuming XPOS and YPOS are real (or double precision) variables, I can't see anything wrong here.

This type of error message almost always means what it says. So if the data that you SHOULD be reading here is in the correct format (which it seems to be), that leaves the possibility that you are actually reading a different part of the file which really IS in the wrong format.

That would mean the error happened earlier, when some other part of the program read either too much or too little data.

I would work backwards. Start by printing out the data that was read by the READ statement before this one, and check if it is right. If it's wrong, keep working backwards till you find the problem.
 
yeah, that part is fine. I checked reading that data with this program:

Code:
program impdo
   integer i,j,nabur(4)
   real x(8,4),y(8,4)
   data nabur/8, 8, 0, 0/
   read(*,*) ((x(i,j),y(i,j),i=1,nabur(j)), j=1,4)
   write(*,'(8(1x,f6.3))') ((x(i,j), y(i,j), i=1,nabur(j)), j=1,4)
end

and it works fine...the error must be happening somewhere else.

Try reading and writing back out as soon as you read something to confirm what you are reading...you will realize immediately where your problem is.

There is a trick, though. Fortran will not write out whenever you ask with a simple write...it will do it when there is enough data in the queue...but it may never get there if it fails before then...to force a write, follow it with a flush.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
2
Views
2K
Replies
5
Views
5K
Replies
12
Views
3K
Replies
8
Views
3K
Replies
21
Views
3K
Replies
5
Views
2K
Back
Top