The SAVE procedure saves variables, system variables, and IDL routines in a SAVE file using the XDR (eXternal Data Representation) format for later recovery by RESTORE. Note that variables and routines cannot be saved in the same file.
IDL routines or data can be saved in a file with any extension; however, it is common to use the extension .sav for SAVE files. Using the .sav extension has two benefits: 1) it makes it clear to another IDL user that the file contains IDL routines or data that can be restored, and 2) it allows IDL to locate routines with the same base name as the file in SAVE files located in IDL’s path.
The process of saving an instance of an object with saving its definition are different. A reference to an instantiated object is stored in an IDL variable and must be saved in a SAVE file as a variable, whereas an object definition is an IDL routine, and must be saved in a SAVE file as a routine. Important: restoring an instance of an object does not restore the object’s definition. If the object is defined in .pro code, you must save the object definition routine and the object instance variable in separate SAVE files, and restore both instance and definition in the target IDL session.
SAVE files containing routines may not be compatible between different versions of IDL; however, files containing data are always backwards-compatible. See Creating Save Files of Program Files for details on version compatibility.
IDL cannot save data objects that rely on state information stored in an external library. Examples of such objects include IDLffXMLDOM and IDLffJPEG2000. These objects are not stored in a SAVE file.
Save the status of all currently-defined variables in the file variables1.sav by entering:
SAVE, /VARIABLES, FILENAME = 'variables1.sav'
The variables can be restored with the RESTORE procedure.
Save the user procedures MYPROC and MYFUN:
SAVE, /ROUTINES, 'MYPROC', 'MYFUN', FILENAME = 'myroutines.sav'
SAVE [, Var1, ..., Varn] [, /ALL] [, BUFFER=[deviceid,bufferFilename]] [, /COMM, /VARIABLES] [, /COMPRESS] [, DESCRIPTION=string] [, EMBED=embedFilename] [, FILENAME=string] [, /IGNORE_NOSAVE] [, /ROUTINES] [, /SYSTEM_VARIABLES] [, /VERBOSE]
The names of one or more variables that are to be saved. If the ROUTINES keyword is present, the Var arguments should be strings containing the names of the routines to be saved. If no Var arguments are provided, the items specified by the supplied keywords are saved.
Set this keyword to save all common blocks, system variables, and local variables from the current IDL session.
Note: Routines and variables cannot be saved in the same file. Setting the ALL keyword does not save routines.
Set this keyword to a two-element string array containing the buffer device ID and the path to the legacy buffer license file to be added to the generated SAVE file. The SAVE procedure will add the buffer license to the SAVE file if the IDL session has access to a Developer’s Kit license.
SAVE, /ROUTINES, BUFFER=["BUFFER_DEVICE_ID", pathToBufferFile+"buffer_license.bin"]
Use this keyword with the ROUTINES keyword.
Note: Legacy licensing will be deprecated after IDL 8.9 and a buffer license will no longer be valid. Use the EMBED keyword along with a Next-Generation license instead.
Set this keyword to save all main level common block definitions. Note that setting this keyword does not cause the contents of the common block to be saved unless the VARIABLES keyword is also set.
If COMPRESS is set, IDL writes all data to the SAVE file using the ZLIB compression library to reduce its size. IDL’s SAVE file compression support is based on the freely available ZLIB library by Mark Adler and Jean-loup Gailly.
Compressed SAVE files can be restored by the RESTORE procedure in exactly the same manner as any other SAVE file. The only visible differences are that the files will be smaller, and writing and reading them will be somewhat slower under typical conditions.
Set this keyword equal to a string that will be saved in the SAVE file:
SAVE, data, $
DESCRIPTION="Solar Obs: 2452884.9, 40 deg 0' N 105 deg 16' W"
This string can be later recovered using the RESTORE procedure or the IDL_Savefile object class. The ability to associate a descriptive string to a SAVE file can be used by IDL programs to identify data, and can also be used as an aid in managing large collections of data.
Set this keyword to a string with the path to the Next-Generation embedded license file to be added to the generated SAVE file. The SAVE procedure will add the embedded license to the SAVE file if the IDL session has access to a Developer’s Kit license.
SAVE, /ROUTINES, EMBED=pathToFile+"license-embedded.dat"
Use this keyword with the ROUTINES keyword.
A string containing the name of the file into which the IDL objects should be saved. While there are no arbitrary limitations on the name of a file created with the SAVE procedure, use the .sav extension for your files for consistency. If this keyword is not specified, the file idlsave.dat is used.
By default, any user-defined routines that are marked with "compile_opt NOSAVE" will not be included in the save file. Set the IGNORE_NOSAVE keyword to include all routines inside the save file, regardless of the compile_opt setting. See compile_opt for details.
Set this keyword to save user defined procedures and functions in a machine independent, binary form. If parameters are present, they must be strings containing the names of the procedures and/or functions to be saved. If no parameters are present, all compiled routines are saved. Routines and variables cannot be saved in the same file.
SAVE (.SAV) files containing routines are not guaranteed to be compatible between successive versions of IDL. You will not be able to RESTORE SAVE files containing routines if they are made with incompatible versions of IDL. In this case, you should recompile your original code with the newer version of IDL. A SAVE file containing data will always be restorable.
By default, any user-defined routines that are marked with "compile_opt NOSAVE" will not be included in the save file. To override this behavior for just a few routines, you should specify these routines as input parameters. You can also set IGNORE_NOSAVE to include all routines, regardless of the compile_opt setting. See compile_opt for details.
Set this keyword to save the current state of all system variables.
Note: Saving system variables is not recommended, as the structure may change between versions of IDL.
Set this keyword to save all variables in the current program unit. This option is the default.
Set this keyword to print an informative message for each saved object.
Added DESCRIPTION keyword
Added EMBEDDED keyword
Added note about compile_opt NOSAVE
Added IGNORE_NOSAVE keyword
Added BUFFER keyword
Deprecated EMBEDDED keyword
||Added EMBED keyword
HEAP_NOSAVE, HEAP_SAVE, JOURNAL, RESOLVE_ALL, RESTORE, IDL_Savefile, Version Compatibility of SAVE Files, COMPILE_OPT