1

I'm trying to shift from intel ifort to IBM xlf, but when reading "unformatted output data"(unformatted I mean they are not the same length), there is problem. Here is an example:

program main
implicit none
real(8) a,b
open(unit=10,file='1.txt')
read (10,*) a
read (10,*) b
write(*,'(E20.14E2)'),a,b
close(10)
end program

1.txt:

0.10640229631236
8.5122792850319D-02

using ifort I get output:

0.10640229631236E+00
0.85122792850319E-01

using xlf I get output:

' in the input file.  The program will recover by assuming a zero in its place.e invalid digit '
0.10640229631236E+00
0.85122792850319E-01

Since the data in the 1.txt is unformatted, I can't use a fixed format to read the data. Dose anyone know how to solve this warning?

francescalus
  • 30,576
  • 16
  • 61
  • 96
xslittlegrass
  • 4,826
  • 4
  • 26
  • 32
  • Is there an apostrophe in the input file? Or any character besides digits, decimal point and "D"? Your reads are "list directed". – M. S. B. Nov 03 '12 at 22:33
  • Thanks @M.S.B. for the commons. Yes it seems to have some character after 0.10640229631236 that costs this warning. When I write those numbers to a new file by hand(change line after 0.10640229631236 by the enter key), this warning goes away. I "cat -v" these two files: With the warning file I get 0.10640229631236^M 8.5122792850319D-02 while the no warning files I get 0.10640229631236 8.5122792850319D-02 Do you know what that M stands for and where it comes from? – xslittlegrass Nov 04 '12 at 01:11
  • 1
    http://stackoverflow.com/questions/64749/m-character-at-end-of-lines – agentp Nov 04 '12 at 13:38
  • @george - perhaps you should add an actual answer with this, so this won't stand as an unanswered question and gather unnecessary attention? – amaurea Nov 04 '12 at 18:01

1 Answers1

0

(Question answered in the comments. See Question with no answers, but issue solved in the comments (or extended in chat) )

@M.S.B wrote:

Is there an apostrophe in the input file? Or any character besides digits, decimal point and "D"? Your reads are "list directed".

The OP Wrote:

Yes it seems to have some character after 0.10640229631236 that costs this warning. When I write those numbers to a new file by hand(change line after 0.10640229631236 by the enter key), this warning goes away. I cat -v these two files: With the warning file I get 0.10640229631236^M 8.5122792850319D-02 while the no warning files I get 0.10640229631236 8.5122792850319D-02 Do you know what that M stands for and where it comes from?

@agentp gave the link:

'^M' character at end of lines

Which explains that ^M is the windows character for carriage return

Community
  • 1
  • 1
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129