Re: running notebook from command line...
- To: mathgroup at smc.vnet.net
- Subject: [mg59365] Re: running notebook from command line...
- From: albert <awnl at arcor.de>
- Date: Sun, 7 Aug 2005 03:46:58 -0400 (EDT)
- References: <dd1ijb$1c2$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Lee, > I have a slow-running model that I want to run from a grid/parallel > computing center at my university which requires that my notebook be > "executable from the command line" (by staff not familiar with > mathematica) rather than the Mathematica front end. I've read the help > files, but I just can't figure out how to make this happen. > > The structure of my notebook is as follows: > > [ Initialization cells that set values for parameters ] > [ Initialization cells that define various functions ] > [ main loop that runs the model and writes results out to files ] > > Can anyone suggest how I can modify the notebook to be command line > executable and how to run it from the command line? Make every input cell in your notebook an initialization cell (the cells containing the main loop also) with selecting them and toggling: Cell -> CellProperties -> Initialization Cell if these are the first initialization cells you will be asked whether or not to create an auto save package file or not. Choose yes. If you are not asked so, set the option AutoGeneratePackage of the notebook to Automatic. This is done easiest in the OptionInspector: Edit -> Preferences then make sure to set the scope to Notebook (usualy it is set to global when you open it) and search: Notebook Optiosn -> File Options -> AutoGeneratePackage and choose Automatic. Now after saving the notebook there will be another file with the same name but ending in .m instead of .nb. This file is ready to be read by the kernel with no frontend. How to do that depends on the computer it should run on, for a grid-computing-center I suspect it could well be something Unix-like and you could use: math < thefileyougenerated.m > output.log to send this to a batch-system or something you might want to put this into a shell script so you only have one command to run. Of course for this to work you need to write your code in such a way that it makes no use of FrontEnd-functionality and als handles the export of graphics output in such a way that no windows will pop up but writes these to files instead (you could also think about generating a Notebook-Expression and save that to a file as result of your calculation, but remember: don't use the frontend). So you should try with some simple stuff first and run your real code with e.g. only one pass through the loop on your desktop without frontend to see what happens... good luck, Albert