| Re: All input data are in a line : tricky I/O Fortran error |
|
 |
|
 |
|
 |
|
 |
Group: comp.lang.fortran · Group Profile
Author: dpbdpb Date: Sep 27, 2007 06:26
sh wrote:
...
> I've just encountered a tricky I/O error in F90.
> Here is the loop ( I extracted the loop and put it in this trivial
> program):
>
> Program trick
> real model(100,100)
> integer i,j
> open(3,file='model.dat', status='old')
> DO i=1,100
> DO j=1,100
> read(3,*) model(i,j)
> END DO
> END DO
> close(3)
> write(*,*) true_model
> end program trick
>
> The input file is just 1000 lines of real.
>
> This loop works perfectly in this program, but as soon as the loop is
> in my real program, sometime it works, sometime it fails with this error :
>
> all input data are in a line...
>
>
> If I remove "status='old', it would work all the time.
> Same if I check with an istat in the open or read statement.
>
> I don't really understand what is involved in the open and read
> statement.
> And from where the following error message "all input data are in a
> line..." comes out !
>
> Somebody has an explenation for this tricky behavior ?
>
>
> I'm running on openSuse 10.2 and I compile with ifort 9.1
Les commented on the mismatch in number of elements expected vis a vis
the length of the input file. Easily a typo in the posting, and should
give an end-of-file reached if that were the case.
If it works successfully in the test program but not in your "real"
program, then the problem is in something not shown/present in the
provided test program but in the other one. Consequently, not likely to
be able to diagnose it from the sample provided.
I don't recognize the error and again as Les says it doesn't have the
"look and feel" of a Fortran-compiler error message. I would do a text
search on the actual program source for that text as I suspect it is
something being output by your program and finding what triggers that in
the program logic will isolate the cause.
--
|