Error when reading list, Fortran 77

Click For Summary
SUMMARY

The forum discussion addresses an error encountered while running a Fortran 77 simulation program using the g77 compiler (gcc version 3.4.6). The error message "invalid number: incomprehensible list input" indicates a problem with the data being read from the file combin.fig. The discussion emphasizes the importance of verifying the data being read and suggests debugging by printing the data before the problematic READ statement. Additionally, it highlights the necessity of using a flush command to ensure data is written out correctly.

PREREQUISITES
  • Understanding of Fortran 77 syntax and data types
  • Familiarity with the g77 compiler and gcc version 3.4.6
  • Basic knowledge of file I/O operations in Fortran
  • Experience with debugging techniques in programming
NEXT STEPS
  • Investigate Fortran 77 file I/O operations and data formatting
  • Learn how to use the FLUSH statement in Fortran to manage output
  • Explore debugging techniques specific to Fortran, such as using print statements
  • Review the structure and format of data files used in Fortran programs
USEFUL FOR

This discussion is beneficial for Fortran developers, particularly those working with legacy code in Fortran 77, as well as programmers troubleshooting file I/O errors and seeking to improve their debugging skills.

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.
 

Similar threads

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