Windows 7 - Unable to write a file

Windows 7 - Unable to write a file

mohanmuthu's picture

Hi,

Recently I migrated from Win XP to Win 7. As part of my work, I use fortran based EXE to perform calculations. Where, it creates a new directory and dumps the output in several files there. With Win 7, I get the error "forrtl: severe (157): Program Exception - access violation" when the EXE tend to create the files within the directory it created.

I tried running the executable in command prompt "as administrator", even then it throws the same error. When I checked the properties of new directory created by the EXE, Read-Only option is partially enabled with comment (only applies to file in folder).

Can anyone help me fixing this issue?

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Tim Prince's picture

You should avoid creating directories and files outside user owned file space (e.g. avoid the directories where the compiler is installed). Windows 7 rightly stops you from doing things which XP didn't care about.

In user owned space, if you have lost permissions, you whould be able to fix them in Windows Explorer (right click on directory, choose properties, then security tab, and set permissions for your user name.

mecej4's picture

Fortran does not have "directory" as a known entity independent of operating systems. A simple fix is for you to create the directory using OS commands or GUI tools before running the EXE, then to run the EXE.

Steve Lionel (Intel)'s picture

I think the directory protection is a red herring, and that you misunderstand the term "access violation" in this context.  Please read Don't Touch Me There - What error 157 (Access Violation) is trying to tell you for more information.  I recommend running the program under the debugger and seeing where exactly in the program it is failing.

Steve
mohanmuthu's picture

@ Tim - I confirmed the full control over the directory. Still the problem exist.

@ mecej4 - My code creates the directory using SYSTEM (....) function and it works good. Issue is, it couldn't create any file within the newly created directory.

@ Steve - Thank you for the post. Now I understand error "157" better. Will debug and try to locate the error and see what improvement I can make.

jimdempseyatthecove's picture

I've seen this too where when the created directory is located in the root system folder (C:\) that the attributes are "funny" (often hidden and read only).

Jim Dempsey

www.quickthreadprogramming.com

Login to leave a comment.