Command Line Options

When starting up Magma, various command-line options can be supplied, and a list of files to be automatically loaded can also be specified. These files may be specified by simply listing their names as normal arguments (i.e., without a - option) following the Magma command. For each such file name, a search for the specified file is conducted, starting in the current directory, and in directories specified by the environment variable MAGMA_PATH after that if necessary. It is also possible to have a startup file, in which one would usually store personal settings of parameters and variables. The startup file is specified by the MAGMA_STARTUP_FILE environment variable which should be set in the user's .cshrc file or similar. This environment variable can be overridden by the -s option, or cancelled by the -n option. The files specified by the arguments to Magma are loaded after the startup file. Thus the startup file is not cancelled by giving extra file arguments, which is what is usually desired.

Magma also allows one to set variables from the command line --- if one of the arguments is of the form var:=val, where var is a valid identifier (consisting of letters, underscores, or non-initial digits) and there is no space between var and the :=, then the variable var is assigned within Magma to the string value val at the point where that argument is processed. (Functions like StringToInteger should be used to convert the value to an object of another type once inside Magma.)

magma -b
If the -b argument is given to Magma, the opening banner and all other introductory messages are suppressed. The final "total time" message is also suppressed. This is useful when sending the whole output of a Magma process to a file so that extra removing of unwanted output is not needed.
magma -c filename
If the -c argument is given to Magma, followed by a filename, the filename is assumed to refer to a package source file and the package is compiled and Magma then exits straight away. This option is rarely needed since packages are automatically compiled when attached.
magma -d
If the -d option is supplied to Magma, the licence for the current magmapassfile is dumped. That is, the expiry date and the valid hostids are displayed. Magma then exits.
magma -n
If the -n option is supplied to Magma, any startup file specified by the environment variable MAGMA_STARTUP_FILE or by the -s option is cancelled.
magma -r workspace
If the -r option is supplied to Magma, together with a workspace file, that workspace is automatically restored by Magma when it starts up.
magma -s filename
If the -s option is supplied to Magma, the given filename is used for the startup file for Magma. This overrides the variable of the environment variable MAGMA_STARTUP_FILE if it has been set. This option should not be used (as it was before), for automatically loading files since that can be done by just listing them as arguments to the Magma process.
magma -S integer
When starting up Magma, it is possible to specify a seed for the generation of pseudo-random numbers. (Pseudo-random quantities are used in several Magma algorithms, and may also be generated explicitly by some intrinsics.) The seed should be in the range 0 to (2 ^ (32) - 1) inclusive. If -S is not followed by any number, or if the -S option is not used, Magma selects the seed itself.
magma -t N
If the -t option is supplied to Magma at the command line, together with a positive number N, then the number of POSIX threads is set to N at startup (so this is equivalent to calling SetNthreads(N); after Magma has started).

Example Env_Startup (H4E1)

By typing the command

magma file1 x:=abc file2

Magma would start up, read the user's startup file specified by MAGMA_STARTUP_FILE if existent, then read the file file1, then assign the variable x to the string value "abc", then read the file file2, then give the prompt.

V2.28, 13 July 2023