Computers abound in the sciences and not knowing how to use them puts one at a great disadvantage these days. It is therefore important for you to develop at least a working knowledge if not an 'intuitive' sense of how things work with these machines. There will always be little problems that will confront you and it would be of great help to you and others to be able to at least attempt to solve them on your own. Isn't that why you are at a university in the first place ... to learn how to problem solve on your own?
Computers play a two major roles in modern nmr spectrometers. First, they are used to program and control the hardware. In other words, to acquire the spectrum the digitizer must be set to function at the appropriate rate, the interpulse delay must be set according to the user's wishes and a number of other hardware details must be attended to in order for a successful data acquisition to occur. These are generally set by the computer. One sets up a parameter table either by manually inputting values or by reading a saved parameter file into the table. When the acquire command is issued then the computer sets up and initializes the hardware and starts the acquisition. The second use of the computer is to manipulate the data in various ways, the most obvious being to Fourier transform from the time domain to the frequency domain. Here, as with the control of the spectrometer hardware, one can set up a table of values that will in some way control the data manipulation. The same applies to the plotting functions.
The Unix Operating System
Many years ago when computer programmers were first programming their machines it was recognized that there were many operations that were relatively common to all programs such as data output to a printer, input from a keyboard or punch card reader. It was decided that these operations should be separated from the application programs and put into a separate program that all application programs could call upon when needed to perform very basic functions. This would save the effort of writing these routines separately for each program and was a sort of 'core' program that ran on the machine and which loaded application program and provide services to them. This is now known as the operating system. There have been many systems developed over the years ... TOPS10, TOPS20, VMS, MULTICS, CP/M, MSDOS, MacOS, WINDOWS 95/98 and UNIX, to name a few.
Many nmr spectrometers are controlled by a computer running the unix operating system. This is a mature (25 years), robust, multitasking and networking operating system that is capable of performing almost any task that the user can think of. Under unix, the philosophy is that there is a central 'kernel' that does the very low level work ... that is, it deals directly with the hardware in the computer, serial input/output chips, printer circuitry and any of the other miscellaneous things that one might find inside the machine. Another important task of the kernel is to take care of file organization on the hard disk. It also takes care of security in the sense that a user's priviledges to run or not to run a program or to view or not view a file are checked here. The kernel also keeps track of all of the processes that are running concurrently. Under unix there are generally, at a minimum, several process running at once and frequently dozens. These are multitasked, that is, they share cpu time amongst each other and may have higher or lower cpu priority depending on the task being performed. On top of the kernel are the user programs. Generally, one types the name of the user program at the prompt (more on the prompt later) and the program runs (if you have permission to run it!). Some examples of common programs are:
ls - list files in a directory
rm - remove (delete) files or directories
df - print disk space usage
lp or lpr - print a file
grep - find an occurrence of a word in a file
wc - count words or lines in a file
cd - change directory
mv - move a file
ps - print task queue
The great utility of these programs is that they will compile and run on any unix machine. You will find these programs on almost all unix computers. If you know how to use it on one machine then you will know how to use it on the other. There is also the ability built into unix to 'pipe' program outputs together to build a large 'super' program. Using the '|' character one can feed the output of one program into the input of the next. For example, if I wish to list all of the files in a directory with the characters 'brown' in them I would type 'ls | grep brown'. This would have the effect of generating a list of all files in the current directory and then sifting through them for any that have the characters 'brown' in them and printing only those that satisfy this criterium.
The file structure of unix is built around the directory structure. There is a root directory, '/', which can be viewed as the top of an inverted treelike directory strucure. Below the root directory are various subdirectories. On the Bruker spectrometer some of these are:
Figure 1.
Each of these is considered a subdirectory which contains its own files, somewhat like a filing cabinet that holds file folders which individually hold files. The cabinet is the entire directory structure, the file folders are the subdirectories and the files are the files. In fact, some operating systems, notably the MacIntosh, uses the folders analogy to represent subdirectories. The newer versions of Microsoft Windows does the same thing.
To use the unix computer it is necessary to login with a username and (usually) a password. Most users will have priviledges only withing their special areas or group areas. Files and directories are arranged with user priviledges. For example, a partial listing of the bin directory shows us:
total 4231
drwxr-xr-x 18 root root 512 Jan 15 09:41 ..
drwxr-xr-x 2 bin bin 1648 Sep 5 1997 .
-rwxr-x--x 1 root root 291120 May 20 1997 bash
-rwxr-xr-x 1 root root 45208 Jun 24 1994 tar
-rwxrwxr-x 1 root root 66960 Jan 11 1994 tar_new
-rwxr-xr-x 1 bin bin 21924 Dec 6 1993 ls
-rwxr-xr-x 1 root bin 18280 Dec 6 1993 du
-rwxr-xr-x 1 root root 22464 Dec 6 1993 dd
-rwxr-xr-x 1 bin bin 19440 Dec 6 1993 tail
-rwxr-xr-x 1 bin bin 12732 Feb 4 1993 wc
-r-sr-sr-x 1 root root 30400 Jun 9 1992 ps
-rwxrwxr-x 3 bin bin 18944 Oct 31 1991 ln
-rwxrwxr-x 3 bin bin 18944 Oct 31 1991 mv
-rwxrwxr-x 3 bin bin 18944 Oct 31 1991 cp
Table 1.
Most of the files have the characters '-rwxr-xr-x' in the left column. These are the permission characters, grouped in threes. 'rwx' means read/write/execute and the 'd' in the first couple of lines refers to the files being subdirectories. Read means that the file can be read into, for example, a word processor or text editor. Write means that the file may be altered in some fashion, including deleted. Execute means that if the file is an executable program then it will be executed when the user types the filename at the prompt. The leftmost column of three is the user permissions, the middle column is the group permissions and the rightmost is the world permissions. In the case of the 'ls' program the permissions are '-rwxr-xr-x'. This means that the owner (root) has read, write and execute permission for this file. The group (bin) permission is r-x which is read and execute permission. Anyone belonging to the group 'bin' would be able to read and/or execute this file. Similarly, world (anyone) permissions are r-w or read-execute. This means that anyone at all has read-execute permission. There exists on all unix machines a very special user called the 'superuser' with username 'root'. This is normally the administrator of the computer system and has 'super' priviledges that allow her/him to anything necessary to keep the system operating, including erasing any files, whether or not they belong to him/her. The two columns with 'root' and 'bin' in them are the owner and group designations for the files, respectively. Therefore, the file 'du' is owned by root and belongs to the group bin. The file is executable by root and bin and also world (anyone)
Unix can be used with either a command line interface or a windowing interface. The command line system is similar to the msdos interface in which a text mode is presented to the user at login. The unix windowing system, called the X11 windowing system, is the unix version of the MacIntosh or Win98 windowing system. Here you might be presented, after login in, with a graphics screen having a few icons on it. To issue any commands you will need a 'shell', which is simply the program that takes your commands and passes them to the kernel to be interpreted and acted upon. If you are using a command line interface you will be presented with the shell prompt immediately after loggin in. In either case, when you start a shell you are presented with the system 'prompt', which is simply a visual cue to tell you that the computer is waiting for you to begin typing. You then type the name of the program that you wish to run. Most simple unix commands are issued this way.
At login you are always placed in a default subdirectory, determined by the system administrator and given a shell. On the Bruker spectrometer this is usually something like /u/username:
Figure 2.
To switch to another subdirectory, perhaps your data directory, you would use the 'cd' command ... 'cd /u/data/username/nmr'. This would place you in your data directory and you could then use the ls command to list all of your data files. Actually, with the Bruker spectrometer, these would not be files but other subdirectories containing your spectral data. So, if the ls command showed something like:
ptlc1-cjb99-6
ptlc3-cjb101-6
ptlc3-cjb89-6
these are subdirectories containing the data for each of these samples ie.
Figure 3.
Remember that the /nmr directory is itself a subdirectory below the username from Figure 2. The directory '/u/data/username/nmr/ptlc1-cjb99-6' contains two subdirectories, '/1' and '/2'. One might be a proton spectrum and one a carbon-13 spectrum, perhaps. '/ptlc1-cjb99-6/1' contains the raw data in the form of the digitized fid and acquisition parameter files. Below this is the '/pdata' subdirectory which contains further subdirectories that contain the transformed data and plotting information. The directory architecture is complex and time consuming to learn and not particularly useful to the casual user but it is still useful to know about its existence. It makes the Bruker data storage system easier to understand. If you look at Table 1. you will see two 'files' named '.' and '..'. These are special unix files that stand for 'here' and 'the above directory'. Therefore if you wanted to change directories to the one above you would simply type 'cd ../'.
Unix uses other special characters for various purposes. There are two 'wildcard' characters, '*' and '?'. Wildcard means that when these are used the operating system will substitute any characters for them. The '*' character is the multiple wildcard character and the '?' character is the single wildcard character. So, if you were to type 'ls' you might get an output looking like:
F4-cjb115-6
PTLC1-cjb99-6
jianhengs
paulos
ptlc1-cjb99-6
ptlc3-cjb101-6
ptlc3-cjb89-6
However, typing 'ls p*' would give any file beginning with 'p' (lowercase p, not uppercase ... unix is case sensitive) and matching any other characters after the 'p':
paulos:
4
ptlc1-cjb99-6:
1
ptlc3-cjb101-6:
1
2
ptlc3-cjb89-6:
1
2
Note that here, only the files starting with 'p' have been shown. Actually, in this case the 'files' are subdirectories and so the ls command shows us what is in the subdirectories as well as the name of the directory. There are many options available to the user for this and other commands. The 'man' command on the unix system will show a concise (sometimes very concise) summary of these options and their use. For ls you would type 'man ls' and get a description of all of the available options.
Other special characters are '/', '&', and '$'. These should not be used in file names! If you were to use the '/' character in a file name it would create an extra subdirectory somewhere in the Bruker directory hierarchy and the nmr program would not then be able to find your data! Also, unix has trouble deleting files with the characters '(', ')', '[', ']' and ''' in them. These files can be deleted but usually it requires that the superuser do so manually ... automated purge programs that delete files after a backup cannot deal with them. You are best to keep your file names to ones involving simple alphanumeric characters.
After logging in most users will immediately start the nmr program. On the Bruker this program is 'uxnmr' for the AMX spectrometer and 'xwinnmr' for the newer Avance spectrometers. The program will initialize and read its startup files and then present you with a graphical interface to the spectrometer. You will be able to acquire data, process it and plot it. The data will be stored in the previously mentioned subdirectories. When you are assigned a username you are also assigned to a group, usually the research group that you belong to. You will be able to read and alter anyone's files in your group but not other groups. This is a consequence of the permissions talked about earlier. Your files have user and group read/write/execute permissions but the world permissions are only read/execute.
Unix is extremely well suited to networking. This is probably because the modern network protocols were originally developed under unix and have had a long time to mature. There are many ways to interconnect unix computers to perform various tasks. For example, it is quite possible to have a program run on one machine and have its output appear on the screen of another, networked unix computer. Data transfer between machines is extremely easy and amenable to automation. Here in our labs, data backup is done from the AMX 300 spectrometer and the 500 MHz spectrometers to a PC runing Linux, a variant of the unix OS, by simply copying the entire subdirectory hierarchy of the Bruker file system between machines. Copying data from the spectrometer to an offline workstation is similarly easily done.
Spectrometer User Interfaces
Years ago the only interface available was the command-line interface and years before that, only punch cards and paper output. The command-line interface still exists on many computers, including the AMX 300. When you login with your username and password on the AMX 300 you are presented with a prompt that looks something like "asimov.brownk>". The "asimov" part is the name of the computer and the "brownk>" is the username followed by a ">". This is the computers way of telling you that it is ready for you to type something. In other words, it is prompting you to type a command. Commands are usually typed as one word and any modifiers are added after the command separated with spaces. For example, the unix command to list a directory's contents is "ls". You may want to modify this by having the directory's contents listed by reverse date order. You would do this by typing "ls -lt". Notice that the "-lt" is separated from the "ls" by a space. The computer program knows that the command to look for is "ls" and that it is being modified by "-lt". If the user had typed "ls-lt" as all one word then the computer would have tried to find and execute a program called "ls-lt" which is non-existent ... the computer would complain with an error message and return you to the prompt.
To start the nmr program you type "uxnmr" at the prompt. The computer looks for a program called "uxnmr" and executes it. Uxnmr has its own internal command line interface similar in operation to the unix command line interface. There is, however, no prompt. You simply start typing and a small command line opens up at the bottom of the screen to show what you are typing. The syntax rules here are similar if not identical to those of the host operating system, unix. A command is typed as one word and modifiers are added with separation by one or more spaces.
Many users will be familiar with the windowing interface, common on the MacIntosh and PC computer running Windows. In these cases the operating system allows the user to issue commands by simly pointing with a mouse cursor at an icon that represents the program and clicking on it. The program then runs and the user interacts with it by a combination of typing and mouse clicks. The uxnmr program is not a windowing program in the sense that those found on a PC or a MacIntosh are. The windows that appear in uxnmr are not movable and cannot be shrunk or iconized, only closed. Also, it is uxnmr itselt that is creating the windows, not the operating system as would be the case on the Mac or PC. The newer Bruker spectrometers are delivered with an updated version of uxnmr called xwinnmr which is a fully windowed program. In fact, on these newer computers the user is completely insulated from the command line interface ... everything is windowed, including the login exactly as on our SGI data processing computer.
Computer Programming
All digital computers use low level binary instruction sets to accomplish their tasks. Each type of computer has its own particular set of instructions that it can execute. The tasks that they perform are very similar from one machine to the next but the actual binary instructions are not compatible with each other. This is the reason that a program written for, say, a MacIntosh computer will not run on a PC.
It used to be that in order to write a program one had to learn the binary instruction set and input the instruction set to the computer using a set of toggle switches. This was a very slow way to program computers and also required fluency with binary numbers. It was also very prone to bugs in programs. Now, in order to program computers we use programs that translate high level 'languages' into low level binary instructions. The process of translation is called compiling. There have been many high level languages in the past ... FORTRAN, Algol, PL1, Pascal, BASIC and Prolog, to name but a few. The most commonly used languages today are C and C++. The unix operating system is written in C and every unix machine should have a C compiler included with it.
To write a program we invoke a text editor and, using the syntax rules of the language, write a program consisting of a series of instructions that we want the computer to carry out, in the proper order. The text file is then compiled into a binary executable file which the computer can load and run. An example of a classic simple C language program is:
#include <stdio.h>
void main()
{
printf( %s, "hello\n");
}
This program simply prints the text 'hello' to the standard output which is usually the screen that you are currently looking at. Of course, most programs that do anything useful are far more complex than this.
Another language that is native to the unix operating system is PERL. This language is extremely useful for manipulating text and is used in, for example, the automated booking system. Here is a small portion of the booking system program:
$password =~ tr/A-Z/a-z/;
$username =~ tr/A-Z/a-z/;
&ValidateUser( $username, $password );
This fragment, from the booking program, converts the user's password and username to lowercase and then validates the user's password.
More on programming in the uxnmr document.
Computer 'Bugs'
As a user of the spectrometer and the associated computer system you will have little problems to deal with, everyone does. Of this there is no question at all. Frequently, there will be nobody around to help. You must be able to handle yourself. Rule numbers one, two and three are all identical: if there is a problem it is your fault not the computer's. Computers simply don't make errors ... ever. They do exactly what they are told to do which may or may not be what you want them to do. Having said this there are two possibilities for little (or not so little) problems that occur. First, the people that wrote the computer program are not infallible. It is very possible and indeed, probable that they have made some programming errors that cause the program to not work as anticipated. These are the so-called 'bugs' that one hears about. In order to fix them the source of the bug must be found (sometimes not an easy task for the programmer) and the program recompiled. This will never happen for uxnmr since it is now out of production. We must live with any bugs that we find. Xwinnmr is still evolving and, hopefully, bugs are being found and squashed. The more complex a program is the harder it is to debug and it is a piece of programming folk wisdom that 'there is always one more bug'. This has been my experience.
The second, and much more common source of problems is the actions of the user. If he/she doesn't know what they are doing they may very well be pushing buttons and turning knobs blindly and suddenly are in some section of the program that they have never seen before or have changed something. The solution to this is to learn how to use the machine. I can't stress this enough. There are user manuals on the bench beside the spectrometer with lots of information in them and there is lot of information in the library. These are what I used to learn the program and you can too. The other thing that the user might do is not pay close attention to what he/she is doing. What happens here is that she/he thinks that they have pushed one button when in fact they have pushed another button (say, the left mouse button instead of the right one). This can make an enormous difference to what happens. Remember, the program does exactly what you tell it to do. For example, in the Bruker uxnmr integration routine if you mean to push the middle mouse button but actually push the left one, what you expect to happen is that the beginning of an integral will be marked but what actually will happen is that the mouse cursor gets 'unstuck' from the spectrum. Then, when you go to mark the end of the integral, you will get an unexpected error message. If you aren't paying attention to what you are doing this will appear to be a mysterious problem. Try to remember exactly what your last few actions were. If you can't remember then you're asleep ... go get some coffee and try again later.
Remember, computers are machines that interpret things absolutely literally. They are not intelligent and cannot guess what you want them to do. They are dumb, dumb, dumb. Like an airplane, you have to be the pilot and steer them in the direction that you want to go, if you don't ... you'll crash and burn (yes, I know about autopilots but computers don't have them). If you can develop the facility of thinking this way then you will be able to interact with them much more efficiently and effectively. Also, try to think from the perspective of the designers of the program. If there is something that you want to do then most likely the programmers have thought of it and built it into the program. You just have to find out how to do it. Use the manuals.