Batch Processing
You can run Tecplot Focus in batch mode to create plots without displaying any graphics to the screen. This saves time when processing multiple files for printing or export. In batch mode, Tecplot Focus can be executed locally on your workstation computer or remotely using a terminal (Linux only).
Batch Processing Setup
-
Create a macro file to control the batch processing. You may do this either by using Macros.
and recording a Tecplot Focus session, or by using any text editor. See -
Create layout and stylesheet files, as necessary.
-
Prepare data files.
-
Debug the macro file by running Tecplot Focus while not in batch mode.
Macros are more likely to be forward compatible (i.e. work with future releases) only if the file is started with a layout or stylesheet. Refer to the Scripting Guide for more information. |
When you launch Tecplot Focus in batch mode, you provide the name of a macro file to execute. The minimal command to launch Tecplot Focus in batch mode is as follows:
tecfocus -b -p mymacrofile.mcr
The -b
flag instructs Tecplot Focus to run in batch mode and the -p
tells Tecplot Focus to run the filename that follows (mymacrofile.mcr in this case).
The -p flag can be omitted if the macro file uses the .mcr extension (thus in the example above it could be omitted).
|
Batch Mode and Linux
See Tecplot Focus Command Line for information on batch mode command line arguments for Linux. If you have any issues with running in batch mode, see the Rendering and Export Troubleshooting guide for more information.
Batch Mode and Windows
Under Windows, invoking Tecplot Focus from the command line or in a .bat file returns immediately rather than waiting for the application to finish working, as is normal on Linux and Mac.
When using batch mode, however, you generally want to wait until Tecplot Focus has finished one operation before proceeding with the next. To do this, precede the command with start /wait
.
For example:
start /wait tecfocus -b -p mymacrofile.mcr
Batch Mode and Mac
When running batch mode on a Mac, the full path to the executable must be called:
"/Applications/Tecplot Focus 2024 R1/Tecplot Focus 2024 R1.app/Contents/MacOS/Tecplot Focus 2024 R1" -b mymacro.mcr
If you are running many files in batch mode, it may be helpful to set up an alias for the full executable path. To set up an alias, type the following in ~/.bashrc:
alias tecfocus='"/Applications/Tecplot Focus 2024 R1/Tecplot Focus 2024 R1.app/Contents/MacOS/Tecplot Focus 2024 R1"'
With the alias defined, running macros in batch mode becomes easier. Simply add the -b flag followed by the macro you wish to use:
tecfocus -b mymacro.mcr
For more information on setting an alias and running Tecplot from the command line in Mac see the Installation Guide.
Batch Processing Using a Layout File
Combining layout files with batch processing is both powerful and flexible, and is also the recommended procedure. With layout files, you can organize a plot using one or more frames in a single file. The layout file manages datasets and can be altered on the fly, either on the command line or within a macro that loads the layout file.
The layout file must contain a
$!READDATASET macro instruction compatible with the data being loaded.
The easiest way to create such a layout is to load a file similar to the
file(s) you wish to process into Tecplot Focus, then set up the plot as
desired and save the layout. The filename specified in the layout’s
$!READDATASET instruction will be overridden by the filename specified
on the command line (see below).
|
For example, to do the following sequence of tasks in batch mode:
-
Load a data file from a user-supplied file name.
-
Create a specific style of plot.
-
Create a PostScript file of the plot.
You can set up the batch script as follows:
-
Obtain a representative data file to be plotted.
-
Create a layout of the style of plot you want. (For this example, name the file batch.lay).
-
Use a text editor to create the following macro (For this example call this macro batch.mcr):
#!MC 1410 $!EXPORTSETUP EXPORTFORMAT = PS PRINTRENDERTYPE = VECTOR $!PRINTSETUP PALETTE = MONOCHROME $!EXPORT EXPORTREGION = CURRENTFRAME $!Quit
-
Use the following command to run the job in batch mode:
tecfocus -b -p batch.mcr -y psoutput.ps batch.lay mydatafile
tecfocus -b |
Launches Tecplot Focus in batch mode |
-p |
Tells Tecplot Focus to use the following macro file. (Note: This is not needed if the macro file uses the .mcr extension). |
batch.mcr |
Macro file |
-y |
Tells Tecplot Focus to use the following export file |
psoutput.ps |
Export file |
batch.lay |
Layout file to use |
mydatafile |
Data file to use; overrides the file specified in the layout |
Multiple Data File Processing
In Batch Processing Using a Layout File, we set up Tecplot Focus to process a user-supplied data file (or files) and create a single output file. If the above procedure is to be repeated for a large number of input files (one at a time), you can do this by using a loop: either outside Tecplot Focus in the operating system using your shell’s looping constructs, or within Tecplot Focus using the flow-of-control commands in the Tecplot macro language.
Looping Outside Tecplot Focus
The following examples show the command files for launching Tecplot Focus in an operating system loop on two different operating systems. Tecplot Focus processes five data files named dnn.plt and creates ten output files named dnn.out where nn goes from 1 to 10.
Looping Inside Tecplot Focus
In Looping Outside Tecplot Focus we set up Tecplot Focus to process multiple data files using the shell to do the looping. There are two drawbacks to this procedure:
-
The shell languages are not portable between different operating systems.
-
Tecplot Focus must be repeatedly started and stopped to process each dataset.
A more efficient approach is to loop through the data files inside Tecplot Focus. Here, the layout file and the data files are all named within the macro. The command line in this example is simple, as follows:
tecfocus -b -p batch.mcr
Where the macro batch.mcr contains:
#!MC 1410 $!EXPORTSETUP EXPORTFORMAT = PS $!PRINTSETUP PALETTE = MONOCHROME $!LOOP 10 $!OPENLAYOUT "batch.lay" ALTDATALOADINSTRUCTIONS = "d|LOOP|.plt" $!EXPORTSETUP PRINTRENDERTYPE = VECTOR $!EXPORTSETUP EXPORTFNAME = "d|LOOP|.out" $!EXPORT EXPORTREGION = CURRENTFRAME $!ENDLOOP $!QUIT
The $!OPENLAYOUT
command loads in batch.lay
but replaces the data file referenced in the layout with the file names
in the ALTDATALOADINSTRUCTIONS
sub-command. The
$!EXPORTSETUP
command is used in two places. Initially it
is used to set the export format. Later it is used just to change the
name of the file to export to. The $!EXPORT
command does
the actual exporting.
If you want to make many different plots using the same dataset, stylesheets will be more efficient than layout files. |
Batch Processing Diagnostics
Each time Tecplot Focus is run in batch mode, it creates a file defined
by the name in the BATCHLOGFILE
environment variable, or,
if the environment variable is not defined, by a file named
batch.log in the directory where Tecplot Focus was
started. If the name given in the BATCHLOGFILE
environment
variable is a relative path, the directory name where Tecplot Focus was
started is prefixed. A running commentary on actions performed in
Tecplot Focus, as well as warning and error messages, are sent to
the batch.log file.