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

USEROPEN and filename returned by INQUIRE

Leigh
Beginner
765 Views
Hi,

I am using the USEROPEN specifier of the OPEN statement. My useropen function changes the name of the file bering opened. Put another way, the name of the file that is actually opened is not the one that was specified in the OPEN statement.

That all works fine, except for one thing.

The INQUIRE statement's NAME specifier returns the filename that was passed to the OPEN statement, not the name of the file that was actually opened.

Is there a way for me have the INQUIRE statement return the name of the file actually opened for the name specifier?

Many thanks,
Leigh.
0 Kudos
4 Replies
Steven_L_Intel1
Employee
765 Views
I don't think so. The library routine would have to query the OS to see what the filename was for the handle. I will file a feature request asking that this be done if it is possible.
0 Kudos
Leigh
Beginner
765 Views
Thanks.

Following on from your suggestion, is there a way for me to obtain the file handle associated with a unit?

I have seen the PXFFILENO routine in the POSIX compatibility module. That seems to have too many preconditions.

Thanks again,
Leigh.
0 Kudos
Steven_L_Intel1
Employee
765 Views
No - but since you're using USEROPEN you have that and can save it in a module or common block variable.
0 Kudos
Leigh
Beginner
765 Views
Steve,

I was just thinking that myself.

I'm planning to just store unit number, file handle pairs. Then, if I need to, I can get the path using GetFinalPathNameByHandle() (I hope).

I need to do some special processing around file deletions. My approach is to replace CLOSE(unit=n, status='delete') by CALL MYCLOSE(unit=n, status='delete'). It would be nice if the MYCLOSE subroutine can work out the file to operate on just from the the unit number.

Anyway, thnaks for the help.

Leigh.
0 Kudos
Reply