Re: [Q] How to compute in the background?
- To: firstname.lastname@example.org
- Subject: [mg10725] Re: [Q] How to compute in the background?
- From: "P.J. Hinton" <email@example.com>
- Date: Mon, 2 Feb 1998 00:44:20 -0500
- Organization: Wolfram Research, Inc.
- References: <firstname.lastname@example.org>
On 30 Jan 1998, Alessandro Rossi wrote: > I am trying to figuring out if it is possible to have the Math Kernel of > a Sun workstation run a little iterative program and save the results > to a file being at the same time able to close the terminal session. > I'll try to be more clear (please excuse my bad English and poor > computing knowledge): What I really like to do is: > > - open a session of Mathematica (no matter if with the Front End or only > on the Kernel) on the Sun Ultra 1 workstation of my laboratory (the > Math version is 2.2); > > - start to run the Mathematica code, that has a long iteration and that > in the end saves all the results on a file; > > - logout from the workstation, while Mathematica keeps on computing my > code till the end of the iteration (so that everyone else can use the > workstation and I can wait for the results to be writed in the results > file without keeping busy the terminal station); > > Is it possible to do so? > This will really save me a lot of time. > > Any suggestion or hint will really be appreciated. It sounds as if you want to run the Mathematica kernel in batch mode. This is possible under Unix by invoking the kernel with the following syntax: math < infile.txt > outfile.txt & Here infile.txt is the file that you want to use as input. The outfile.txt is the file that will contain the output from the kernel session. If you want your inputs to be echoed in the outfile, you can add the following to the first line of your input file: AppendTo[$Echo, "stdout"] You can use the notebook front end to create the input file using the automatic package generation feature. 1) On the front end menu bar, click on Edit -> Preferences to bring up the Option Inspector dialog box. 2) Enter the following text in the Lookup line of the Option Inspector dialog box: AutoG This expands the Notebook Option|FileOptions subsections to reveal an option called AutoGeneratedPackage. Change this value from its default of Manual to Automatic. 3) Close the Option Inspector dialog box. Enter each input into an Input style cell. Each of these cells should then be endowed with the Initialization Cell property. You can do this by selecting a cell's bracket and hitting the menu command sequence Cell -> Cell Properties -> Initialization Cell The front end uses the Initialization Cell property to determine whether the cell should be written to the package file. Now, when you attempt to save a notebook with initialization cells, the front end will automatically create a companion file with the same base filename but with a .m extension. This package file contains the contents of the initialization cells in InputForm, and it should be suitable for batch input into the kernel. -- P.J. Hinton Mathematica Programming Group email@example.com Wolfram Research, Inc. http://www.wolfram.com/~paulh/ Disclaimer: Opinions expressed herein are those of the author alone.