Variables and Control Structures

As of version 18, CPPTRAJ has limited support for “script” variables and ’for’ loops.

Script variables are referred to by a dollar sign (’$’) prefix and are replaced when they are processed. These are stored in the master data set list like other data and are assigned the type “string variable”. Note that to use script variables in CPPTRAJ input that is inside another script (e.g. a BASH script), they must be escaped with the ’\’ character, e.g.

cpptraj <<EOF
set topname=$TOP # TOP is a BASH script variable
parm \$topname # topname is a CPPTRAJ script variable

Note that regular CPPTRAJ 1D Data Sets that contain a single value can be used as script variables (if the Data Set contains more than 1 value only the first value will be used).

Command Description
for Create a ‘for’ loop.
set Set or update a script variable.
show Show all current script variables and their values.