Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Open statement causes crash, ignores Err=...

Ed_F_
Beginner
467 Views

My Fortran DLL writes a .csv file that users can open in Excel.  Sometimes the users may already have an earlier copy open in Excel, so I need to avoid crashing the program if it can't write a file which is already open in another application.  The following statement worked fine in Compaq Fortran, but now with Intel Parallel Studio XE 2013, the program crashes if the file is open in another application.

OPEN(16,FILE=csvfile,STATUS='unknown',err=199)

(line 199 initiates a graceful exit from the subroutine)

Any idea why the err=199 doesn't work?  Is there another way to accomplish the same thing?

0 Kudos
3 Replies
Ed_F_
Beginner
467 Views

Update:  The program is not crashing on the open statement, but on the subsequent Write statement.  It appears that there is no error on the open statement, so the Err=199 has no effect.

0 Kudos
andrew_4619
Honored Contributor III
467 Views

Just because you can open a file it does mean you have write access. Put more options on the open (e.g. ACTION='WRITE' or 'READWRITE' or put an error status on the first write....

0 Kudos
Ed_F_
Beginner
467 Views

app4619:  Action='WRITE' works.  Thanks for the help.

0 Kudos
Reply