The IDL Programmer's Friend: IDLSAV Files

IDL has a set of built-in functions that make it simple to save and read data sets to/from a file. The IDLSAV file format stores intact variables (and, optionally, other information) in a way that they can easily be recovered for use in subsequent program operations.

This feature can be used to store data extracted from a GEOS-Chem BPCH file. Reading data from an IDLSAV file is much faster than rerunning the CTM_GET_DATA function, especially when the BPCH file is very large. It is most useful when used to store data subsets, though it is possible to store the whole DataInfo structure, if desired.

More information can be found in the IDL Reference Guide: Save function Page 2262, Restore function Page 2230.

To save variables to a file:

idl> save, var1, var3, var3, filename='name', description='description', /verbose

To restore variables from a file:

idl> restore, filename='name', /verbose

Here is the output from an example file idlsav_demo.pro:

IDL> idlsav_demo
======================================
Set variable values and print contents
======================================
Structure of arrNumbers variable:
ARRNUMBERS      INT       = Array[10]
  Contents:
           0
           1
           2
           3
           4
           5
           6
           7
           8
           9

Structure of strarrWords variable:
STRARRWORDS     STRING    = Array[10]
  Contents:
         one
         two
       three
        four
        five
         six
       seven
       eight
        nine
         ten

Structure of dblNumber variable:
DBLNUMBER       DOUBLE    =        123.45679
  Contents:
  123.456789

Save contents of variables to an IDLSAV file:
% SAVE: Portable (XDR) SAVE/RESTORE file.
% SAVE: Saved variable: ARRNUMBERS.
% SAVE: Saved variable: STRARRWORDS.
% SAVE: Saved variable: DBLNUMBER.

======================================
Destroying original values:
======================================
Current contents of variables:
Structure of arrNumbers variable:
ARRNUMBERS      INT       = Array[1]
  Contents:
           0

Structure of strarrWords variable:
STRARRWORDS     STRING    = Array[1]
  Contents:
     nothing

Structure of dblNumber variable:
DBLNUMBER       DOUBLE    =        0.0000000
  Contents:
    0.000000

======================================
Now restore original variables and print contents:
======================================
% RESTORE: Portable (XDR) SAVE/RESTORE file.
% RESTORE: Save file written by rwpage@ctm.geo.mtu.edu, Fri Oct  8 09:13:54 2010.
% RESTORE: IDL version 7.1 (linux, x86_64).
% RESTORE: Description: An IDLSAV example.
% RESTORE: Restored variable: ARRNUMBERS.
% RESTORE: Restored variable: STRARRWORDS.
% RESTORE: Restored variable: DBLNUMBER.
Structure of arrNumbers variable:
ARRNUMBERS      INT       = Array[10]
  Contents:
           0
           1
           2
           3
           4
           5
           6
           7
           8
           9

Structure of strarrWords variable:
STRARRWORDS     STRING    = Array[10]
  Contents:
         one
         two
       three
        four
        five
         six
       seven
       eight
        nine
         ten

Structure of dblNumber variable:
DBLNUMBER       DOUBLE    =        123.45679
  Contents:
  123.456789