Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Error when reading list, Fortran 77

  1. Jun 21, 2012 #1

    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

    The error is for the following READ statement:

    Code (Text):
    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.

  2. jcsd
  3. Jun 21, 2012 #2


    User Avatar
    Science Advisor
    Homework Helper

    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.
  4. Jun 21, 2012 #3
    yeah, that part is fine. I checked reading that data with this program:

    Code (Text):

    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)
    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.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook