Re: Logical Unit mystery; clarification [message #7460] |
Tue, 19 November 1996 00:00  |
Andy Loughe
Messages: 174 Registered: November 1995
|
Senior Member |
|
|
David Fanning wrote:
>
> Russ Welti <rwelti@mapper.mbt.washington.edu> writes:
>
>> At one point in my IDL program, as I do one of many SAVEs and RESTOREs,
>> I get:
>>
>> RESTORE: All available logical units are currently in use.
>>
>> But a subsequent HELP,/FILES shows only my expected 1 log file open!
>>
>> IDL> help,/files
>> Unit Attributes Name
>> 100 Read, Write, Append /u/rwelti/dev/sage/log.ostrandr
>>
>>
>> And, if I do a CLOSE,/ALL at error point above, the RESTORE can be done OK.
>
> I don't know exactly why this is happening, but I wouldn't be surprised if
> the RSI programmer fell into the same trap I have fallen into numerous
> times in my own programs.
>
> There are two pools of logical unit numbers you can use. The pool of
> numbers from 1-99, which you can use directly, and the pool of numbers
> from 100-128 that IDL manages with the GET_LUN procedure or keyword.
>
> If you choose a LUN from the user pool (e.g., 4), then you are suppose
> to close the file and free up the LUN by using the CLOSE command:
>
> OPENR, 4, file
> ...
> CLOSE, 4
>
> If you let IDL choose a LUN from its pool, you are suppose to close the
> file and free the LUN to be used over again with the FREE_LUN command.
>
> OPENR, lun, file, /GET_LUN
> ...
> FREE_LUN, lun
>
> What I have been guilty of many times, is using the CLOSE command
> with a LUN from IDL's pool. Like this:
>
> OPENR, lun, file, /GET_LUN
> ...
> CLOSE, lun
>
> This closes the file, but it doesn't free up the logical unit number to
> be used over again. I think this is exactly what is happening with
> your RESTORE problem. After a time, you run out of LUNs.
>
> Fortunately, the ALL keyword to the CLOSE command closes not
> only all the files, but it does an additional *freeing* of the LUNs
> managed by IDL. That's why your program works again.
>
> David
Thanks for the useful info. Now the question...
Why this confusing functionality within IDL?
It seems this could be fixed very easily within free_lun,
just test the magnitude of the lun.
--
Andrew F. Loughe afl@cdc.noaa.gov
University of Colorado, CIRES http://cdc.noaa.gov/~afl
Campus Box 449 phn:(303)492-0707 fax:(303)497-7013
Boulder, CO 80309-0449 "He who laughs last thinks slowest!"
|
|
|