Using script files to control map3d has numerous advantages, for example:
A script files are simple programs written in the language of the Unix shell. There are actually several languages, one for each type of shell, and the user is free to select. At the CVRTI we have decided to use the Bourne shell for script programming (and the Korn shell for interactive use) and so all scripts will assume the associate language conventions. The shell script language is much simpler to use and learn than a complete, general purpose language such as C or Fortran, but is very well suited to executing Unix commands; in fact, the script files consist mostly of lists of commands as you might enter them at the Unix prompt. Even more simply, a script file can consist of nothing more than the list of commands you would need to type to execute the same task from the system prompt.
Script files are simple text files and so are usually created with an editor such as emacs. You can, however, also generate a script file from a program, or even another script. But all script files can be read and edited by emacs and this is the way most are composed.
To learn about the full range of possibilities in script files requires some study of a book such as ``Unix Shell Programming'' by Kochan and Wood but the skills needed to make map3d script files are much more modest; any book on Unix will contain enough information for this. The instructions and examples below may be enough for many users.
Here are some rules and tips that apply to script files:
map3d -f geomfilename.fac \ -p potfilename.tsdf \ -cl channelsfilename
Make sure that there are no characters (even blank spaces) after the continuation character!!! This has to be the most frequent error when the script file fails to run or stops abruptly.
chmod 755 script_filename
varname=2 varname="some text" varname=a_name
Do not leave any spaces around the ``='' sign or the command will fail and set the variable to an empty string.
Once defined, the variables can be used elsewhere in the script as follows:
geomdir=/u/macleod/torso/geom geomfile=datorso.fac datafile=dipole.tsdf map3d -f ${geomdir}/${geomfile} -p $datafile
The curly braces are required when the variable name is concatenated with other text of variable names but is optional otherwise. To concatenate text and variables you simply write them together (e.g., geomfile.pts concatenates the two variables with a ``/'' and the extension ``.pts''.
All the environment variables are available and can be set in the script. For example:
mydir=${HOME}sets the variable $mydir equal to the user's home directory. Likewise,
MAP3D_DATAPATH=/scratch/bt2feb93/ export MAP3D_DATAPATHdefines and ``exports'' the environment variable used by map3d to find .pak files.
Below are some sample scripts, from simple, to fairly complex:
map3d -f ${HOME}/torso/geom/dal/daltorso.fac \ -as 100 500 300 700 \ -p ${HOME}/maprodxn/andy3/10feb95/data/cooling.tsdf \ -s 1 1000
MAP3D=../map3d GEOM=../geom/tank DATA=../data/tank $MAP3D -nw -f ${GEOM}/25feb97_sock.fac \ -p ${DATA}/cool1-atdr_new.tsdf@1 -s 1 1000 \ -ch ${GEOM}/sock128.channels \ -f ${GEOM}/25feb97_sock_closed.geom \ -p ${DATA}/cool1-atdr_new.tsdf@2 -s 1 1000\ -ch ${GEOM}/sock128.channels
MAP3D=../map3d GEOM=../geom/tank DATA=../data/tank $MAP3D -nw -f ${GEOM}/25feb97_sock.fac \ -as 200 600 400 800 \ -p ${DATA}/cool1-atdr_new.tsdf@1 -s 1 476 \ -at 200 600 200 420 -t 9\ -ch ${GEOM}/sock128.channels \ -f ${GEOM}/25feb97_sock_closed.geom \ -as 590 990 400 800 \ -p ${DATA}/cool1-atdr_new.tsdf@2 -s 1 476 \ -at 590 990 200 420 -t 126 \ -ch ${GEOM}/sock128.channels
MAP3D=../map3d GEOM=../geom/torso DATA=../data/torso $MAP3D -f ${GEOM}/daltorso.geom -p ${DATA}/dipole2.tsdf -s 1 6
MAP3D=../map3d GEOM=../geom/torso DATA=../data/torso $MAP3D -f ${GEOM}/daltorsoepi.geom@1 \ -p ${DATA}/p2_3200_77_torso.tsdf -s 1 200 \ -f ${GEOM}/daltorsoepi.geom@2 \ -p ${DATA}/p2_3200_77_epi.tsdf -s 1 200
#!/bin/sh # A script for the spmag 1996 article # ###################################################################### map3d=/usr/local/bin/map3d map3d=${ROBHOME}/gl/map3d/map3d.sh MAP3D_DATAPATH=/scratch/bt26mar91pack/ export MAP3D_DATAPATH echo "MAP3D_DATAPATH = $MAP3D_DATAPATH" basedir=/u/macleod/maprodxn/plaque/26mar91 $map3d -b -nw \ -f $basedir/geom/525sock.geom \ -as 150 475 611 935 \ -at 150 475 485 610 -t 237 \ -p $basedir/data/pace-center.tsdf@1 \ -s 65 380 \ -f $basedir/geom/525sock.geom \ -as 476 800 611 935 \ -at 476 800 485 610 -t 237 \ -p $basedir/data/pace-center.tsdf@1 \ -s 65 380 \ -f $basedir/geom/525sock.geom \ -as 150 475 176 500 \ -at 150 475 50 175 -t 237 \ -p $basedir/data/pace-center.tsdf@1 \ -s 65 380 \ -f $basedir/geom/525sock.geom \ -as 476 800 176 500 \ -at 476 800 50 175 -t 237 \ -p $basedir/data/pace-center.tsdf@1 \ -s 65 380
Rob Macleod 2007-03-01