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

Get a free file unit number

jaeger0
Beginner
667 Views
I have maybe a trivial question, but however I can not fount the function in the manual.

I'm using a lot of files, so I want to use an unique file unit-number, not used somewhere else at the same time. Is there a method to proof if a file-unit is arlready used ?
0 Kudos
1 Reply
GVautier
New Contributor III
667 Views
[cpp]
integer*4 function get_free_file_unit_number integer*4, parameter :: first_unit= 10 integer*4, parameter :: last_unit =9999 logical*4 test do get_free_file_unit_number=first_unit,last_unit inquire(get_free_file_unit_number,opened=test) if (.not.test) return enddo get_free_file_unit_number=-1 end function[/cpp]

0 Kudos
Reply