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

forrtl: severe (157) when trying to close a file

AndyM
Beginner
452 Views
When I try to close some files I'm getting
forrtl: severe (157): Program Exception - access violation

Other files accessed in the same way in the same run close just fine.

The file is opened with
open(kElanFile,file=trim(ElanFileName),status='unknown')
Some ascii data is written to it.
The close statement is simply
close(kElanFile)

I never had trouble closing a file before. Does anyone have any ideas?
Thanks, Andy
0 Kudos
3 Replies
Greg_T_
Valued Contributor I
452 Views
Hi Andy,

It looks like you already get the run-timeerror number, but would it help to add the IOSTAT option to the CLOSE statement? Perhaps it could provide another error code to help diagnose the problem.

Is it possible that the kElanFile unit number gets changed as the program runs, or another file is using the same unit number? I've had file close errors when there is an unexpected change to a file unit number. I've also had file close problems with file shared across the local network (my PC to the server) if there is a network interuption. Does using a different file unit value help, or does the error still occur?

Regards,
Greg
0 Kudos
Steven_L_Intel1
Employee
452 Views
Getting Error 157 on a CLOSE suggests that there has been a corruption of a run-time library data structure. The way I usually try to diagnose this is to selectively remove code before the close to see which, when removed, makes the error go away.
0 Kudos
AndyM
Beginner
452 Views
Thanks for the input guys.

It turned out that boundaries of an array were being violated,
but traceback was making it appear that the error occurred when a file was being closed.
0 Kudos
Reply