Re: running calculations in a batch mode
- To: email@example.com
- Subject: [mg12033] Re: running calculations in a batch mode
- From: "P.J. Hinton" <firstname.lastname@example.org>
- Date: Fri, 24 Apr 1998 01:52:06 -0400
- Organization: Wolfram Research, Inc.
- References: <email@example.com>
On 17 Apr 1998, Tatyana Polenova wrote: > How can I launch Mathematica jobs in background? I would like to be able > to set up calculations that take long time and log out of the system. I > am using SGI (IRIX 6.4). Currently the program is written as > Mathematica notebook; does it have to be rewritten as a plain file or > one can evaluate the definitions using the Front End, and then quit the > Front end leaving the jobs running? > thanks you very much It isn't possible to start kernel-based batch calculations directly from the front end, but by saving the inputs in your notebook as a package, you can export your calculations from your notebook to a plain text file that is suitable for input on a batch job. Click open Edit -> Preferences on the front end. On the resulting dialog box, set the scope to be Notebook. Then in the Lookup line of this dialog box, enter the characters "AutoGen." This should open up some submenus to the AutoGeneratedPackage option. Set this to Automatic, and the front end will automatically export all initialization cells in InputForm to a file that has the same base filename as your notebook, but with the .m extension that is used to denote Mathematica packages. This export will take place each time you save your notebook. The automatic generation can be turned off by setting the AutoGeneratedPackage function to be None. Next, within your notebook, select each cell that contains a calculation you want to run as part of a batch file. Click on the front end menu command sequence Cell -> Cell Properties -> Initialization Cell. This will mark each cell that you selected as an initialization cell. The .m file created by the front end can be used as an input for batch mode operation. Running the kernel in batch mode question that gets asked every month or so on this newsgroup. The answer can be found in the booklet _Getting Started with Mathematica under Unix and X_, p. 30. This material is also available under the System Information portion of the online help. The syntax for running batch calculations in the kernel, regardless of Unix flavor is: math < infile > outfile Where "math" is the shell command that you invoke to run the kernel by itself. In most cases it will be "math", but if this doesn't work, contact your system administrator to find out what command this may be. The file "infile" is a the file containing the inputs to the kenrel. The file "outfile" is the file where where output is to be directed. If you want your inputs to be echoed in the outfile, then you will need to add the following expression to the beginning of infile: AppendTo[$Echo, "stdout"] If you wish to log your results in the form of a notebook rather than a plain text file, you can use the package ProgrammingInMathematica`NotebookLog`, which is described in Roman Maeder's book _Programming in Mathematica_, 3rd ed. -- P.J. Hinton Mathematica Programming Group firstname.lastname@example.org Wolfram Research, Inc. http://www.wolfram.com/~paulh/