## 8. Real programming: if's and do's

In addition to the vectors and matrices that plotdata manipulates as a whole, it knows about scalars, and, in fact, it knows how to divide up its vectors and matrices into their elements. In plotdata, one addresses say, the fifth element of a vector v as v[5] or v(5), and an element of a matrix m as, say, m[5,6] or m(5,6). Thus we have another way of creating the matrices of the previous section, by writing a short macro like this, and then executing it:

do j = 1,10
  do k = 1,10
    m[j,k]=(10*(j-6))**2*exp(-0.1*(k-6)**2)
  enddo
enddo
surface m

Please, pay attention to the spaces around the equal sign; they are mandatory here, at least in the current version of plotdata. An obscure error message will show up if you omit them.

You can see the immediate similarity with Fortran that was mentioned in the beginning. This similarity is, in fact, more extensive: plotdata macros can contain labels, logical ifthen statements, and goto's. These allow you to perform fairly complicated routines without leaving plotdata. There are many examples of such macros shown in the User's Guide. A word of caution: plotdata macros are interpreted line-by-line, and so an equivalent but pre-compiled Fortran program will run much faster. Thus you should reserve your plotdata programming for relatively simple things; when the computations get complicated and long it is best to leave plotdata; write, compile, and run a Fortran program; and then return to plotdata to look at the produced output data. Always use the tools that are appropriate to the task at hand!

Congratulations! - you have reached the end of our brief tutorial. It should have given you a taste of the capabilities of plotdata. For a more comprehensive discussion you are, as always, referred to the manuals.