PHYS 686: Numerical Quantum Optics: Computer Resources

This document will be updated throughout the course.


Fortran 90/95 References

Why Fortran 90? Fortran 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 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 were hard to find, but this is changing now. There are even two 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 Fortran 95 compilers on the lab or cluster machines, use the command

f95

To test this, try typing

f95 -v

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

f95 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

f95 -O3 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.



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 preview the .dvi output file, assuming you have X Windows running, you would type

xdvi sample.dvi

If you are sitting at one of the iMacs, though, I would recommend compiling it the rest of the way to get a .pdf file, and then look at that. I do this this old-fashioned way. Convert the .dvi file to a postscript file by typing

dvips -o -Pcmz -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 in Preview.app by typing

open sample.pdf

Incidentally, under X Windows you can also look at the postscript file by typing

gs sample.ps

but in general the pdf file will render more nicely. 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