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.

How to avoid opening of implicit file fort.XXX

ZlamalJakub
New Contributor III
2,184 Views

Is there possibility to disable files fort.xxx created when program writes to unit which is not opened by OPEN statement and generate error instead?

My code sometimes generates these files and I cannot find when and why it happens.

0 Kudos
4 Replies
IanH
Honored Contributor III
2,184 Views

Compile your program with /traceback.  Before running it, set the environment variable FORTn (where n is the unit number) to something like "/path/that/does/not/exist".  Run your program.  Inspect the traceback.  Fix your program.  Profit!

[plain]>type preconnected.f90
PROGRAM preconnected
  WRITE (77, "('Hello world')")
END PROGRAM preconnected
>ifort /traceback preconnected.f90
Intel(R) Visual Fortran Compiler XE for applications running on IA-32, Version 14.0.0.050 Beta Build 20130417
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:preconnected.exe
-subsystem:console
-incremental:no
preconnected.obj

>set FORT77=path\that\does\not\exist

>preconnected.exe
forrtl: severe (29): file not found, unit 77, file U:\procrastination\path\that\does\not\exist
Image              PC        Routine            Line        Source
preconnected.exe   0113105E  _MAIN__                     2  preconnected.f90
preconnected.exe   0117A772  Unknown               Unknown  Unknown
preconnected.exe   01165AB4  Unknown               Unknown  Unknown
kernel32.dll       768ED2E9  Unknown               Unknown  Unknown
ntdll.dll          774E1603  Unknown               Unknown  Unknown
ntdll.dll          774E15D6  Unknown               Unknown  Unknown

[/plain]

0 Kudos
jimdempseyatthecove
Honored Contributor III
2,184 Views

Since you know what the unit numbers are, try adding code at the start of the program to open a file for read-only. This will occupy the unit number, then later in the run of the program, the write will fail. Hopefully you can locate the offending statemtents.

Jim Dempsey

0 Kudos
ZlamalJakub
New Contributor III
2,184 Views

Many thanks for responses I hope both help me very much.

0 Kudos
jimdempseyatthecove
Honored Contributor III
2,184 Views

IanH, good suggestion, much better (and less effort) than mine.

Since these files apparently written, setting the attribute Read Only might also locate the problem statement (though this may not prevent reads).

Jim Dempsey

0 Kudos
Reply