Introduction to SIO Computing Environment Peter Shearer pshearer@ucsd.edu x42260 Munk Lab, IGPP Web site: http://mahi.ucsd.edu/shearer/COMPCLASS/index.html This course is intended to help incoming students get up to speed on the various computing tools that will help them with their research and some of the homework assignments for other classes. My perspective is largely that of the Geophysics program at IGPP, but I hope that the course is general enough to be useful for other students as well. All students should have access to a Mac and an account on the IGPP Mac network. Please let me know if you do not already have an account. Most of the application programs are available on the Macs, but there is not yet a free F90 compiler for the Macs so this is why the network account is necessary. Geophysics students should have Mac laptops with X11, MatLab, GMT, TekShop and Bob Parker's programs already installed. However, you can also run these programs by logging onto the Barnyard Macs. We will spend a few weeks on MatLab, UNIX, GMT and other topics, but the bulk of the class will be an introduction to the Fortran90 programming language. If you are already experienced in C or Fortran, you probably don't need to take this class (although you may find some of the other material and the geophysical examples of interest). -----Overview of commonly used IGPP/SIO Hardware and Software----- PRE-2004 HARDWARE (and still the case outside IGPP) UNIX Workstations (e.g., Sun, HP, Silicon Graphics, etc.) Scientific programming Data storage General research (some work processing, graphics) PCs (mostly Mac) Word Processing Graphics Presentations (talks and posters) (some programming) CURRENT HARDWARE PLAN WITHIN IGPP Macs running UNIX Almost everything (programming, word processing, etc.) Some number crunching on G5s Suns Programs that still only work on Suns SGI Number crunching SOFTWARE (Items with * will be discussed in this class) Programming *FORTRAN (most SIO faculty use this, large library of existing code) C (more widely taught and used by computer scientists) C++ (extended version of C) Java (used a lot for web programming, has portability advantages) Python (lots of buzz, Lisa Tauxe likes it) *MatLab (but is also a commercial product) *HTML for web sites Community Programs *Bob Parker programs (plotxy, color, contour) *GMT for mapping (UNIX based) SAC for seismic analysis etc. Commercial Programs Word for word processing Powerpoint for presentations *TeX/LaTex (no single vendor, different implementations available, files are compatible, best option for papers & thesis) Adobe Illustrator (for graphics, mostly on PCs) IslandDraw (still used on some UNIX machines) PhotoShop Mathematica etc. -----Why you should learn a "real" language----- Many students arrive at SIO without much experience in FORTRAN or C, the two main scientific programming languages in use today. While it is possible to get by for most class assignments by using Matlab, you will likely be handicapped in your research at some point if you don't learn FORTRAN or C. Matlab is very convenient for quick results but has limited flexibility. Often this means that a simple FORTRAN or C program can be written that will perform a task far more cleanly and efficiently than Matlab, even if a complicated Matlab script can be kluged together to do the same thing. In addition, Matlab is a commercial product that does not have the long-term stability of other languages, including large libraries of existing code that are freely shared among researchers. Your research may involve processing data using a FORTRAN or C program. If you do not understand the program, you will not be able to modify it to do anything other than what it can already do. This will make it difficult to do anything original in your research. You may resort to elaborate kluges to get the program to do what you want, when a simple modification to the code would be much easier. Worse, you may drive your colleagues crazy by continually requesting that the original authors of the program make changes to accomodate your wishes. Finally, you will be in a more competitive position to get a job after you graduate if you have real programming experience. ----- FORTRAN vs. C ----- Several years ago when I first started teaching programming in this class, I had to decide whether to teach C or Fortran. Like most SIO faculty of my generation or older, I was experienced in FORTRAN but had little exposure to C. After talking to some people who know both FORTRAN and C, however, I decided to bite the bullet and learn enough C to teach this class. This was motivated in part by the fact that C is now one of the standard languages taught in computer science departments; many of our incoming students have C experience but few have Fortran experience. Here is my summary of the advantages and disadvantages of either choice: FORTRAN Advantages Large amount of existing code Preferred language of most SIO faculty Complex numbers are built in Choice of single or double precision math functions Disadvantages Column sensitive format in older versions Dead language in computer science departments C Advantages Large amount of existing code Preferred language of incoming students, some younger faculty Free format, not column sensitive More efficient I/O Easier to use pointers Disadvantages Less user-friendly than FORTRAN (I think so, but others may debate this) Fewer built in math functions (but easy to fix) No standard complex numbers (but easy to fix) Easier to use pointers With reasonable compilers, both languages are equally fast. Ultimately, there are fixes for both languages that permit them to assume the advantages of the other language. For example, you can use pointers in FORTRAN90 and you can define an add-on set of functions to do complex arithmetic in C. So I learned some C and wrote the C part of the notes that are on the website, which explain the language in the context of a series of example programs of increasing complexity. I can't say that I enjoyed the experience very much as I do not think C is a very user friendly language for those without programming experience. So in 2003 I switched to Fortran90, an improved version of Fortran77, that seems to combine the advantages of Fortran and C into a more user-friendly package. This has gone pretty well so I am going to teach F90 again this year. A complication to this plan is that there is currently no reliable free F90 compiler for the Macs, our platform of choice for this class. Single use licenses cost $400. We do have F90 installed on Mac "grunt" in the Barnyard. To do your F90 assignments, you will have to remotely login to this machine.