IDL provides extensive Input/Output facilities at the user level. Internally, it uses native Input/Output facilities (UNIX system calls or Windows system API) in addition to the standard C library stream package (stdio). The choice of which facilities to use are made based on the target platform and the requested features for the file.

Most external code linked with IDL (CALL_EXTERNAL, system routines, etc.) should not do Input/Output directly for the following reasons:

  • Part of the IDL philosophy is that Input/Output is handled by dedicated I/O facilities provided by IDL, and that computational code should accept data from IDL variables and return results in the same way. This gives the user of your code the freedom and flexibility to save their data in any of the many forms supported by IDL’s core I/O facilities, and frees you from writing complex and error prone input/output code.
  • Using IDL’s Input/Output facilities frees you from having to code around platform specific differences in I/O behavior.
  • Input/Output from languages other than C often require runtime library support code to run at program startup before your code and successfully perform I/O. For example, Fortran Input/Output may depend on a Fortran runtime subsystem having been initialized. IDL, as a C program, does not perform initialization of such libraries for other languages. If you know enough about your Fortran system, you can often supply the missing initialization call, but such workarounds are usually not well documented, and are inherently platform specific.

For the reasons above, only minimal I/O abilities are available from IDL's internals, and only for files that explicitly use the standard C stdio library. Therefore, if your application must directly perform I/O to a file managed by IDL, it is necessary to use the standard C library streampackage (stdio) by specifying the IDL_F_STDIO flag to IDL_FileOpen(). Most of the routines associated with the standard C library I/O package can be used in the normal manner.

Disallowed C Library Routines and Their IDL Counterparts


The C library routines listed in the following table should not be used; use the IDL-specific functions instead:

C-Library Function

IDL Function

fclose()

IDL_FileClose()

fdopen()

IDL_FileOpen()

feof()

IDL_FileEOF()

fflush()

IDL_FileFlushUnit()

fopen()

IDL_FileOpen()

freopen()

IDL_FileOpen()

Note: In order to access a file opened using IDL_FileOpen() in this manner, you must ensure that it is stdio compatible by specifying IDL_F_STDIO as part of the extra_flags argument to IDL_FileOpen(). Failure to do this will cause your code to fail to execute as expected.