Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Run-time error when opening/reading an ASCII file

$
0
0
 

 

I am compiling a large program, which depends on several external Fortran and C libraries, on a Mac OS X 10.9.5 with Intel Fortran Compiler 15.0.1. I get a run-time error when opening an external (ASCII) file and reading it. The strangeness is that the file exist (inquired form within the program) and the that calling open gives a status = 0 (see the test program below).The simple test program below compiles and runs well on gfortran, while with ifort it gives a runtime error, which I reported below (including the backtrace, as given by gdb).

I tried to compile the same test program excluding one external library at a time, and identified which libraries are creating the run-time error. The problem is that I used these (Fortran) libraries in the past without getting any run-time error, so it's really hard to understand what could be the problem...

I also run the same test on a Linux machine with Intel Fortran 13.1.0 and I get the same error...

--------------- test program ---------------------

program test_open

  implicit none

  character(len=100)    :: fileName, line
  integer               :: status
  logical               :: exist, opened

  fileName = 'foo.txt'

  inquire( file = fileName, exist = exist )
  print *, 'exist: ', exist

  open ( 77, file = fileName, iostat = status )
  print *, 'status: ', status

  inquire( 77, opened = opened )
  print *, 'opened: ', opened

  read( 77, '(a)' ) line

  print *, 'line: ', line

  close( 77 )

end program test_open

--------------- end test program ---------------------

------- shell output --------------

 exist:  T
 status:            0
 opened:  T
forrtl: No such file or directory
forrtl: severe (29): file not found, unit 77, file /Users/jchevall/My_Codes/BANGS/build/fort.77
Image              PC                Routine            Line        Source

Stack trace terminated abnormally.

--------------- GNU debugger output ---------------------

exist: T
status:            0
opened:  T
forrtl: No such file or directory

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000202aca780
0x0000000102c4d3cb in tbk_get_pc_info ()
(gdb) backtrace
#0  0x0000000102c4d3cb in tbk_get_pc_info ()
#1  0x0000000102c4cc34 in stackwalk_cb ()
#2  0x0000000102c4c971 in tbk_string_stack_signal_impl ()
#3  0x0000000102c22281 in tbk_stack_trace_impl ()
#4  0x0000000102c220b6 in tbk_stack_trace ()
#5  0x0000000102bd8cea in for__issue_diagnostic ()
#6  0x0000000102bd82de in for__io_return ()
#7  0x0000000102bfb871 in for_read_seq_fmt ()
#8  0x00000001000017e5 in test_open () at test_open.f90:20
#9  0x00000001000012be in main ()
(gdb)

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>