The SAVE command saves a sequence to a specified file together with all relevant information.
The parameters are defined as:
SEQUENCE lists the sequences to be saved, separated by commas.
This attribute is optional and when omitted, all known
sequences are saved.
However, because of internal inconsistencies that can result in spurious
entries in the output file, the user is strongly advised to always provide
explicitly the names of sequences to be saved.
FILE the filename of the output file. (Default: ”save”)
BEAM an optional flag to specify that all beams linked to the specified sequences are saved at the top of the output file.
BARE an optional flag to save only the sequence without the element definitions nor beam information. This allows to re-read in a sequence with might otherwise create a stop of the program. This is particularly useful to turn a line into a sequence in order to further edit it with SEQEDIT.
MAD8 an optional flag to request that the sequences should be saved using \madeightinput format.
NOEXPR an optional flag to save values of expressions
instead of the expressions themselves: the expressions in commands
and variables are expanded and evaluated before saving.
This option must be used with care because the exported values were not deeply
checked and the code that writes variables and commands is widely spread
in the internal structure.
This option does not apply only for the saving of sequences in \madeightformat.
NEWNAME provides a name for the saved sequence, overriding the original name. (see EXTRACT above)
Any number of SELECT, FLAG=save, ... commands may precede the SAVE command. In that case, the names of elements, variables, and sequences must match the pattern(s) if given, and in addition the elements must be of the class(es) specified. See here for a SAVE with SELECT example.
The precision of the output of the SAVE command depends on the defined output precision for \madx, which can be adjusted with the SET, FORMAT... command.
Note that with BARE=false the saved sequence may contain redundant efinitions of elements, ie the same element is defined in the declaration of elements in the form label: type... and in the sequence itself in the form label: type, at=.... This is flagged by \madxas implicit element redefinition and is ignored but a warning is issued.
Example:
tl3: LINE = ( ldl6, qtl301, mqn, qtl301, ldl7, qtl302,
mqn, qtl302, ldl8, ison);
dltl3: LINE=(delay, tl3);
Use, period=dltl3;
Save, sequence=dltl3, file=t1, bare; // only sequence is saved
Call, file=t1; // sequence is read in and is now a "real" sequence
// if the two preceding lines are suppressed, seqedit will print a warning
// and else do nothing
Use, period=dltl3;
Twiss, save, betx=bxa, alfx=alfxa, bety=bya, alfy=alfya;
Plot, vaxis=betx, bety, haxis=s, colour:=100;
SEQEDIT, SEQUENCE=dltl3;
remove,element=cx.bhe0330;
remove,element=cd.bhe0330;
ENDEDIT;
Use, period=dltl3;
Twiss, save, betx=bxa, alfx=alfxa, bety=bya, alfy=alfya;