Closing Files
After work involving the file is complete, it should be closed. Closing a file removes the association between the file and its unit number, thus freeing the unit number for use with a different file. There is usually an operating system-imposed limit on the number of files a user may have open at once. Although this number is large enough that it rarely causes problems, situations can occur where a file must be closed before another file may be opened. In any event, it is good style to only keep needed files open.
There are three ways to close a file:
Calling the CLOSE procedure is the most common way to close a file unit. For example, to close file unit number 1, use the following statement:
In addition, if FREE_LUN is called with a file unit number that was previously allocated by GET_LUN, it calls CLOSE before deallocating the file unit. Finally, all open files are automatically closed when IDL exits.