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


-- 
           Summary: print file name when file cannot be opened for writing
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vivekrao4 at yahoo dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31053

Reply via email to