Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29295 Discussions

Default file location for regular file and scratch file

philippe_bernier
Beginner
1,019 Views
Hi,
I have an older program that open a file without specifying a path name. I know I can use the "DEFAULTFILE" specifier to indicate where to create-it. But, is there a function available to get the Windows Temp folder I can use with this?
Also, when I open a file of type 'SCRATCH', I know the program opens a file of a random name but for some reasons, the file is open in the root of the C drive. This drive is typically set as read only for regular user Windows account (especially with Windows Vista / 7). Why isn't the scratch file created in the Windows temp by default and is there a way to force the scracth file to be created in a specific folder? Can I use the same trick as above (DEFAULTFILE=)?
Thank You
Philippe Bernier
0 Kudos
1 Reply
Steven_L_Intel1
Employee
1,019 Views
You can use the GET_ENVIRONMENT_VARIABLE intrinsic to retrieve the value of "TEMP", which points to your temp folder. An undocumented feature is that you can use environment variables in the FILE= specificer of OPEN, like this:

OPEN (1,FILE="%TEMP%\somefile.dat")

I don't think this works in DEFAULTFILE.

Scratch files are opened in the temp directory, so perhaps TEMP (or TMP - I don't remember which it uses first) points to C:\?
0 Kudos
Reply