PHYS 610: Computational Physics (Spring 2011): Computer Resources

This document will be updated throughout the course.


Fortran 95 References

Why Fortran? Fortran, in its various incarnations, is the most important language developed specifically for scientific computation. Decisions in the Fortran standards were specifically chosen to benefit performance and stability, and Fortran programs produce fast, highly optimized, stable codes with a minimum of user effort, as compared to other languages. Some examples include:

Generally, arguments for switching to other languages has been based on experiences with the archaic and fairly primitive FORTRAN 77 language, and not on the modern Fortran implementations. Since Fortran 90 is a relatively subtle language from the compiler's point of view, until recently good compilers for Fortran 90/95/2003 were hard to find, but this is changing now. There are even decent open-source compilers out there. A nice argument for Fortran 90 over C++ is posted here.

As a supplement to Fortran, sometimes you want to prototype a code first quickly to make sure it works, or sometimes you just need a quick calculation. Octave (a free MATLAB clone, although its scripts are not entirely compatible with MATLAB) is an excellent language for this type of work. Its syntax is similar to Fortran 90, and has a similar focus on arrays as fundamental objects, but it has many high-quality numerical routines built in. Of course, a properly written Fortran code will run circles around the same calculation in Octave, but often it can save time. A tutorial on Octave is here.

To invoke the Intel Fortran (90/95) compilers on the cluster, use the command

ifort

To test this, try typing

ifort -v

to get version information about a compiler. Generally, you can compile a single file by typing

ifort file.f90

This command will generate a binary executable file “a.out”, which you can then run by typing

./a.out

To compile with agressive optimizations and to name the executable file “myexec”, you would type

ifort -O3 -static-intel -tune pn4 -xSP file.f90 -o myexec

The sample codes and the codes you will write for the assigned projects will be more complicated multi-file codes that need to be compiled in stages by the “make” utility. We'll deal with that in the sample codes.

Also, to run jobs on the cluster that take more than a few seconds, you should run things through the batch system. Read the qc batch tutorial, up through the “Interactive Jobs” section, to see how to start an interactive session on a computing node. Once you begin to run jobs that take more than a few minutes, you'll want to read the next section on “Batch Jobs” to see how to run unattended jobs.



Numerical Computing Resources



LaTeX Resources

LaTeX is a professional-quality typesetting system for scientific and mathematical documents, and is the standard in physics. LaTeX operates very much like a programming language, in that you write a text file with the text and commands, and then you compile it to produce the typeset document.

Many other tutorials and references can be found online via Google.

I have posted a sample LaTeX document that you can use to get started, and it may save time to use it as a template for your writeups. The source file is here, sample.tex, and the compiled pdf version of it is here, sample.pdf. To try it out, download it (or copy and paste it into a text editor, and save it as sample.tex). Then to compile it, you would type

latex sample.tex
latex sample.tex

That's not a typo, you should do it twice. During the first pass, LaTeX builds a list of all the references and citations that it has to number, and it actually puts them in during the second pass. If you modify anything that would change the numbering, you should always run LaTeX twice (the output will remind you to do this). When running, LaTeX will create the additional files sample.aux (with the info to do the numbering), sample.log (a copy of the output to the screen), and sample.dvi, which is the “device independent” output. Then, to view the .dvi output file, assuming you have X Windows running, you would type

xdvi sample.dvi

But .dvi files aren't really suitable for distribution, so you'll eventually need to compile it the rest of the way to get a .pdf file. I do this this old-fashioned way. Convert the .dvi file to a postscript file by typing

dvips -o -tletter sample

The options here tell dvips to output to the postscript file sample.ps (instead of the printer), to use postscript fonts, and to use US letter paper (instead of the default A4). Then use

ps2pdf sample.ps

This produces the file sample.pdf, which you can view by typing

acroread sample.pdf

or by copying it back to your computer. Go through this sample file; while rather brief, it covers many of the LaTeX features that you'll need for your writeups.



Getting Started in Unix



Getting Started with HTML