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

closing/deleting files after exception

rkaehler
Beginner
770 Views
I have a CVF/Windows dll that implements exception handling using the "C Wrapper" seh technique, which works fine except:

If a divide by zero triggers the C exception handler, a work file I had open in the Fortran dll cannot be deleted by the C++ wrapper function or even the routine that calls the wrapper (even after unloading the dll). It is unavailable to another instance of the CVF dll. Nor can it be deleted through the OS GUI, until the whole calling program exits.

CVF/Windows must be protecting the file. I would like to be able to programatically delete this work file after the exception so the dll can be called again with other data (without exiting and restarting the whole program).

Any ideas on freeing the file up from the wrapper function or above?

Thanks for your thoughts.
0 Kudos
2 Replies
Steven_L_Intel1
Employee
770 Views
It's not that CVF is "protecting" the file, but that it does not establish handlers to close the file upon an unload of the DLL. (It would be wrong to do it for an exception.) Add a routine to the DLL to close the work files and call it from your exception code.

STeve
0 Kudos
rkaehler
Beginner
770 Views
Thanks Steve,

You were correct; the trick was that the files had to be deleted with FORTRAN code rather than the C++ code of the exception handler.
0 Kudos
Reply