assign, echo = "file_name", truncate;where "file_name" is the name of an output file, or "terminal" and trunctate specifies if the file must be trunctated when opened (ignored for terminal). This allows switching the echo stream to a file or back, but only for the commands value, show, and print. Allows easy composition of future MAD-X input files. A real life example (always the same) is to be found under footprint example.
call, file = file_name;where "file_name" is the name of an input file. This file will be read until a "return;" statement, or until end_of_file; it may contain any number of calls itself, and so on to any depth.
coguess,tolerance=double,
x=double,px=double,y=double,py=double,t=double,pt=double,
clear=logical;
sets the required convergence precision in the closed orbit search
("tolerance", see as well Twiss command
tolerance.
The other parameters define a first guess for all future closed orbit searches in case they are different from zero.
The clear parameter in the argument list resets the tolerance to its default value
and cancels the effect of coguess in defining a first guess for subsequent
closed orbit searches.
Default = false, clear alone is equivalent to clear=true
create,table=table,column=var1,var2,_name,...;creates a table with the specified variables as columns. This table can then be filled, and finally one can write it in TFS format. The attribute "_name" adds the element name to the table at the specified column, this replaces the undocumented "withname" attribute that was not always working properly.
See the user table I example;
or an example of joining 2 tables of different length in one table including the element name: user table II
delete,sequence=s_name,table=t_name;deletes a sequence with name "s_name" or a table with name "t_name" from memory. The sequence deletion is done without influence on other sequences that may have elements that were in the deleted sequence.
dumpsequ, sequence = s_name, level = integer;Actually a debug statement, but it may come handy at certain occasions. Here "s_name" is the name of an expanded (i.e. USEd) sequence. The amount of detail is controlled by "level":
level = 0: print only the cumulative node length = sequence length
> 0: print all node (element) names except drifts
> 2: print all nodes with their attached parameters
> 3: print all nodes, and their elements with all parameters
exec, label;Each statement may be preceded by a label; it is then stored and can be executed again with "exec, label;" any number of times; the executed statement may be another "exec", etc.; however, the major usage of this statement is the execution of a macro.
exit;ends the program execution.
fill, table=table, row=integer;
The FILL command takes two arguments:
Only valid from version 5.02.03 onwards
Negative ROW values are allowed and count the row numbers from
the last row, allowing access to the table in reverse order of rows:
ROW = -1 accesses the last row of the table,
ROW = -2 accesses the one before last (penultimate) row, etc...
Only valid from version 5.02.03 onwards
Trying to access the table forward beyond the last row, i.e. ROW
strictly greater than nrow+1, where nrow is the number of rows in the table, or
trying to access the table backwards before the first row, i.e. ROW
strictly lower than -nrow, both result in a ``row out of bound'' message and no
variable values are set in the table.
Reminder: One can get access to the current number of rows in a table using the variable
TABLE(tablenanme, TABLELENGTH)See as well the user table example.
help,statement_name;prints all parameters, and their defaults of the statement given; this includes basic element types.
option, flag { = true | false };
option, flag | -flag;
sets an option as given in "flag"; the part in curly brackets is optional:
if only the name of the option is given, then the option will be set true
(see second line); a "-" sign preceding the name sets it to "false".
Example:
option,echo=true; option,echo;are identical, ditto
option,echo=false; option,-echo;The available options are:
name default meaning if true
==== ======= ===============
echo true echoes the input on the standard output file
warn true issues warnings
info true issues informations
debug false issues debugging information
echomacro false issues macro expansion printout for debugging
trace false prints the system time after each command
verify false issues a warning if an undefined variable is used
tell false prints the current value of all options
reset false resets all options to their defaults
no_fatal_stop false Prevents madx from stopping in case of a fatal error. Use at your own risk.
rbarc true converts the RBEND straight length into the arc length
thin_foc true if false suppresses the 1(rho**2) focusing of thin dipoles
bborbit false the closed orbit is modified by beam-beam kicks
sympl false all element matrices are symplectified in Twiss
twiss_print true controls whether the twiss command produces output.
threader false enables the threader for closed orbit finding in Twiss.
(see Twiss module)
bb_ultra_relati false To be documented
bb_sxy_update false To be documented
emittance_update true To be documented
fast_error_func false To be documented
The option "rbarc" is implemented for backwards compatibility with MAD-8
up to version 8.23.06 included; in this version, the RBEND length was just
taken as the arc length of an SBEND with inclined pole faces,
contrary to the MAD-8 manual.
print,text="...";prints the text to the current output file (see ASSIGN above). The text can be edited with the help of a macro statement. For more details, see there.
printf, text = "string", value = expr{,expr};
prints the numerical values specified in the value field, formatted according to
the string format provided in the text field, to the current output file. The string format can take numeric C or MAD format specifiers for double real values; integer and string formats are not supported but can be approximated with the %g in the case of integers, and via MACRO statements, which perform string substitution, themselves containing a PRINT statement.
The maximum number of values that can be printed in one statement is limited to 100.
If the number of format specifiers given in the string is higher than the number of values in the value field, undefined values are printed where they are not explicitly provided. If the number of format specifiers given in the string is lower than the number of values in the value field, the values that do not correspond to a format specifier are ignored.
Example:
a = 1.2; b = 3.4/0.3; c := 0.8*a/b;
printf, text = "String with floats a=%f, b=%.3g, text and MAD float c=%F;",
value = a, b, c;
printf, text = "More specifiers than values: %f, %.3g, %F", value = a, b;
printf, text = "More values than specifiers: %f, %.3g" , value = a, b, c;
produces the following output:
String with floats a=1.200000, b=11.3, text and MAD float c= 0.08470588235; More specifiers than values: 1.200000, 11.3, 6.953222976e-310 More values than specifiers: 1.200000, 11.3
Note that printf, like print, produces output that cannot be read back by MAD-X. For output that can be read back by MAD-X, use the command VALUE or TFS tables.
Note also that a percent sign (%) can be printed using the format text="%%".
quit;ends the program execution.
readtable,file=filename;reads a TFS file containing a MAD-X table back into memory. This table can then be manipulated as any other table, i.e. its values can be accessed, it can be plotted, written out again etc.
readmytable,file=filename,table=internalname;reads a TFS file containing a MAD-X table back into memory. This table can then be manipulated as any other table, i.e. its values can be accessed, it can be plotted, written out again etc. An internal name for the table can be freely assigned while for the command READTABLE it is taken from the information section of the table itself. This feature allows to store multiple tables of the same type in memory without overwriting existing ones.
removefile,file=filename;remove a file from the disk. It is more portable than
system("rm filename"); // Unix specific
renamefile,file=filename,name=newfilename;rename the file "filename" to "newfilename" on the disk. It is more portable than
system("mv filename newfilename"); // Unix specific
resbeam,sequence=s_name;resets the default values of the beam belonging to sequence s_name, or of the default beam if no sequence is given.
return;ends reading from a "called" file; if encountered in the standard input file, it ends the program execution.
save,beam,sequence=sequ1,sequ2,...,file=filename,beam,bare;saves the sequence(s) specified with all variables and elements needed for their expansion, onto the file "filename". If quotes are used for the "filename" capital and low characters are kept as specified, if they are omitted the "filename" will have lower characters only. The optional flag can have the value "mad8" (without the quotes), in which case the sequence(s) is/are saved in MAD-8 input format.
The flag "beam" is optional; when given, all beams belonging to the sequences specified are saved at the top of the save file.
The parameter "sequence" is optional; when omitted, all sequences are saved.
However, it is not advisable to use "save" without the "sequence" option unless you know what you are doing. This practice will avoid spurious saved entries. 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.
It is important to note that the precision of the output of the save command depends on the output precision. Details about default precisions and how to adjust those precisions can be found at the SET Format instruction page.
The Attribute 'bare' allows to save just 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 to seqedit it. 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; // new parameter "bare": only sequ. 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;
savebeta, label=label,place=place,sequence=s_name;marks a place "place" in an expanded sequence "s_name"; at the next TWISS command execution, a beta0 block will be saved at that place with the label "label". This is done only once; in order to get a new beta0 block there, one has to re-issue the command. The contents of the beta0 block can then be used in other commands, e.g. TWISS and MATCH.
Example (after sequence expansion):
savebeta,label=sb1,place=mb[5],sequence=fivecell; twiss; show,sb1;will save and show the beta0 block parameters at the end (!) of the fifth element mb in the sequence.
select, flag=flag,range=range,class=class,pattern=pattern,
slice=integer,column=s1,s2,s3,..,sn,sequence=s_name,
full,clear;
selects one or several elements for special treatment in a subsequent
command. All selections for a given command remain valid until "clear"
is specified; the selection criteria on the same command are logically
ANDed, on different SELECT statements logically ORed.
Example:
select,flag=error,class=quadrupole,range=mb[1]/mb[5]; select,flag=error,pattern="^mqw.*";selects all quadrupoles in the range mb[1] to mb[5], and all elements (in the whole sequence) the name of which starts with "mqw" for treatment by the error module.
"flag" can be one of the following::
"slice" is only used by makethin and prescribes the number of slices into which the selected elements have to be cut (default = 1).
"column" is only valid for tables and decides the selection of columns to be written into the TFS file. The "name" argument is special in that it refers to the actual name of the selected element. For an example, see SELECT.
SETVARS, TABLE=tablename, ROW=integer;The attributes of SETVARS are:
Negative ROW values are allowed and count the row numbers from
the last row, allowing access to the table in reverse order of rows:
ROW = -1 accesses the last row of the table,
ROW = -2 accesses the one before last (penultimate) row, etc...
Trying to access the table forward beyond the last row, i.e. ROW strictly greater than nrow, the number of rows in the table, or trying to access the table backwards before the first row, i.e. ROW strictly lower than -nrow, or trying to access the illegal ROW=0, all result in a ``row out of bound'' message and no variable values are returned and set.
SETVARS_LIN, TABLE=tablename, ROW1=integer, ROW2=integer, PARAM=string;The attributes of SETVARS_LIN are:
SETVARS_LIN sets the variables with values calculated through the following formula that MAD-X constructs internally as a deferred expression which is immediately evaluated:
value := value(row1)*(1-param) + value(row2)*param;Both the expression and the value of the expression are available to the user through respectively the commands SHOW and VALUE.
Negative ROWi values are allowed and count the row numbers from
the last row, allowing access to the table in reverse order of rows:
ROWi = -1 accesses the last row of the table,
ROWi = -2 accesses the one before last (penultimate) row, etc...
Trying to access the table forward beyond the last row, i.e. ROWi strictly greater than nrow, the number of rows in the table, or trying to access the table backwards before the first row, i.e. ROWi strictly lower than -nrow, or trying to access the illegal ROWi=0, all result in a ``row out of bound'' message and the expression is not constructed or evaluated.
show,command;prints the "command" (typically "beam", "beam%sequ", or an element name), with the actual value of all its parameters.
stop;ends the program execution.
system,"...";transfers the string in quotes to the system for execution.
Example:
system,"ln -s /afs/cern.ch/user/u/user/public/some/directory short";
tabstring(arg1,arg2,arg3)The"string function" tabstring(arg1,arg2,arg3) with exactly three arguments; arg1 is a table name (string), arg2 is a column name (string), arg3 is a row number (integer), count starts at 0. The function can be used in any context where a string appears; in case there is no match, it returns _void_.
title,"...";inserts the string in quotes as title in various tables and plots.
use,period=s_name,range=range,survey;expands the sequence with name "s_name", or a part of it as specified in the range. The survey option plugs the survey data into the sequence elements nodes on the first pass (see survey).
value,exp1,exp2,...;prints the actual values of the expressions given.
Example:
a=clight/1000.; value,a,pmass,exp(sqrt(2));results in
a = 299792.458 ; pmass = 0.938271998 ; exp(sqrt(2)) = 4.113250379 ;
write,table=table,file=file_name;writes the table "table" onto the file "file_name"; only the rows and columns of a preceding select,flag=table,...; are written. If no select has been issued for this table, the file will only contain the header. If the FILE argument is omitted, the table is written to standard output.
hansg, June 17, 2002