On Windows, if a file is open in Excel, one cannot write to it in a Fortran program. So if "junk.csv" is opened in Excel and I compile and run the code program xopen ! check what happens when program tries to open file already open implicit none integer, parameter :: iu = 20 character (len=*), parameter :: xfile="junk.csv" open (unit=iu,file=xfile,action="write",status="replace") end program xopen gfortran Target: i386-pc-mingw32 Configured with: ../trunk/configure --prefix=/mingw --enable-languages=c,fortran --with-gmp=/home/coudert/local --disable-nls --with-ld=/mingw/bin/ld --with-as=/mingw/bin/as --disable-werror --enable-bootstrap --enable-threads --host=i386-pc-mingw32 --disable-shared --enable-libgomp Thread model: win32 gcc version 4.3.0 20061021 (experimental) says At line 6 of file xopen_error.f90 Fortran runtime error: Permission denied I'd like it to say that file "junk.csv" could not be opened, to make debugging easier for the user. For example, Intel Visual Fortran says forrtl: The process cannot access the file because it is being used by another process. forrtl: severe (30): open failure, unit 20, file U:\vrao\fortran\junk.csv Image PC Routine Line Source ifort_xopen_error 0044382E Unknown Unknown Unknown ifort_xopen_error 00440AEC Unknown Unknown Unknown ifort_xopen_error 00405DFA Unknown Unknown Unknown ifort_xopen_error 00405A17 Unknown Unknown Unknown ifort_xopen_error 00401C81 Unknown Unknown Unknown ifort_xopen_error 0040106F _MAIN__ 6 xopen_error.f90 ifort_xopen_error 00449970 Unknown Unknown Unknown ifort_xopen_error 0042EBB8 Unknown Unknown Unknown kernel32.dll 7C816FD7 Unknown Unknown Unknown
Yes, this would be useful. Confirmed.
> gcc version 4.3.0 20061021 (experimental) I believe this has been fixed already by PR30005 since December 5. At least my gfortran prints: At line 6 of file foo.f90 Fortran runtime error: Permission denied trying to open file 'junk.csv'
(In reply to comment #2) > I believe this has been fixed already by PR30005 since December 5. Correct. The fix isn't in 4.2 though (which is what I tried :-) Closing as a duplicate of 30005. *** This bug has been marked as a duplicate of 30005 ***