I can pass the input file to fortran program, like this:
./foo < inputfile
But in gdb, I tried this:
gdb ./foo
run < inputfile
It displays nothing and doesn't work.
Update: My system is MACOS high sierra GDB version: 8.0
Example of main program getting optionally an input data file from argument :
program test
character(256) :: cfile
integer :: unit,status,itest
call get_command_argument(1,cfile)
if(cfile /= "") then
unit=15
open(unit,file=cfile,iostat=status)
if(status /= 0) then
write(*,*) 'invalid file ',trim(cfile)
stop
endif
else
unit=5
endif
read(unit,*) itest
write(*,*) itest
! ...
end program
Input deck "d.dat" :
25
Test :
[coul@localhost ~]$ gfortran -g test.f90
[coul@localhost ~]$ ./a.out < d.dat
25
[coul@localhost ~]$ gdb a.out
GNU gdb (GDB) Fedora 7.10.1-31.fc23
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
(gdb) run d.dat
Starting program: /home/coul/a.out d.dat
25
(gdb)
~/.bashrcor other shell startup script that prevents it from working. - Employed Russian