Error when reading list, Fortran 77

In summary, the programmer is trying to run a simulation program written in Fortran 77, but gets an error message that says "invalid number: incomprehensible list input". The problem is that the data that the program is trying to read from a file is in the wrong format.
  • #1
stenssok
1
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
  • #2
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.
 
  • #3
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.
 

FAQ: Error when reading list, Fortran 77

Why am I getting an error when trying to read a list in Fortran 77?

There could be several reasons for this error. Some common causes include incorrect formatting of the list, incorrect data types, or a mismatch between the number of items in the list and the number of variables used to store them. It is important to carefully check your code for any mistakes and make sure the list is properly defined and formatted.

How can I fix an "Error when reading list" in Fortran 77?

The first step in fixing this error is to identify the cause. Make sure the list is properly defined and formatted, and that the correct data types are being used. You may also want to check for any typos or missing punctuation. If the error persists, try using a debugger or adding print statements to your code to help identify the issue.

Can a "Error when reading list" be caused by a missing or incorrect list delimiter?

Yes, a missing or incorrect delimiter in your list can cause this error. Fortran 77 requires that lists are properly delimited with commas or other appropriate characters. Make sure to double check your list for any missing or incorrect delimiters.

How do I read a list with Fortran 77?

To read a list in Fortran 77, you will need to use the READ statement and specify the list name and data types for each item in the list. For example, if your list contains integers, you would use the format "READ (list_name) integer1, integer2, ..." Make sure to also include appropriate delimiters between each item in the list.

Are there any specific syntax rules for reading lists in Fortran 77?

Yes, there are some specific syntax rules to keep in mind when reading lists in Fortran 77. These include proper use of delimiters, matching data types between the list and variables used to store the data, and making sure the number of items in the list matches the number of variables specified in the READ statement. It is important to carefully review the Fortran 77 syntax rules to ensure your code is properly written.

Similar threads

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