-1

Here is the file to be read, a.tab:

7.600000e-05   
1.580000e-04   
1.384140e-01
4.566700e-02   
1.530000e-04   
1.374210e-01
2.238700e-02   
3.871300e-02   
1.339930e-01
-2.231400e-02   
3.835000e-02   
1.313520e-01
-4.551300e-02   
2.350000e-04   
1.327270e-01
-2.207500e-02  
-3.697500e-02   
1.261490e-01

My program:

PROGRAM MAIN
implicit none

integer             :: j,iostatus
double precision    :: test(18)

open(unit = 100, file = 'a.tab', status = 'old', action = 'read',iostat=iostatus)
 write(*,*) iostatus

 do j = 1,18
     read(100,*,end=10) test

 end do

10 close(100)
write(*,*)test

end 

the output is:

0
0

Why not read the file correctly if the iostat is equal to 0? The same program run on Windows works.

AlM
  • 11
  • 2
  • OK, please _edit your question_ when it is evidently unclear - if it needs repeated editing then it is likely to be downvoted. – halfer Jun 25 '16 at 17:08
  • After the edits, I think it is fine now, yes. I don't use Fortran though, so the real test is to wait for someone who can answer the question. `:-)` – halfer Jun 25 '16 at 17:43
  • Use relevant tags, your edit to remove osx and add osx-elcapitan instead was wrong. Please reade help to find out how to use this site. – Vladimir F Героям слава Jun 27 '16 at 05:49
  • 1
    It's probably worth noticing that the code reads the input file 18 times, each time trying to read 18 values. I wonder whether OP meant to read the 18 values one-at-a-time. Perhaps replace `test` with `test(j)` in the `read` statement. – High Performance Mark Jun 27 '16 at 11:16

1 Answers1

0

Since the program works on Windows, you might need to convert your input file for use in Unix. Try the dos2unix utility on a.tab before running on the Mac.