360 likes | 393 Views
Computers and Programming in Geosciences. SOEE 1160. Lectures Tuesday 10:00 to 11:00 SR B22 Practical Wednesday 09:00 to 11:00 EFC (Environment Building). Lecturer/Module Manager Sebastian Rost Demonstrator Kuishuang Feng. Rost Contact. Office: 8.15b Geophysics Corridor.
E N D
Computers and Programming in Geosciences SOEE 1160
Lectures • Tuesday 10:00 to 11:00 SR B22 • Practical • Wednesday 09:00 to 11:00 EFC (Environment Building)
Lecturer/Module Manager Sebastian Rost Demonstrator Kuishuang Feng
Rost Contact Office: 8.15b Geophysics Corridor Email: s.rost@leeds.ac.uk Web: http://earth.leeds.ac.uk/SOEE1160.html
Module Summary Computers are an important research tool in all geosciences. This course is designed to teach how computers can be used to solve problems in the geosciences. The students will get an introduction to the SEE computer system and will learn how to use a LINUX/UNIX operating system effectively. We will introduce two programming languages, FORTRAN and MATLAB and will learn how to use these languages in structured computer programs. This module is taught through lectures and practicals and will be assessed through practicals and a two-hour exam.
Syllabus 1. SEE computer system 2. UNIX filesystem structure3. Shells and UNIX commands, shell utilities and text editor 4. Structured programming5. Fortran program structure and compiling. 5.1 Declarations 5.2 Operators and internal functions 5.3 Input and output. 5.4 Conditional testing. 5.5 Loops. 5.6 Subroutines and external functions 6. Matlab programming 6.1 Array basics 6.2 Vector and matrices 6.3 Operators and array arithmetic 6.4 Input/Output 6.5 Flow control structure
Assessment 50% Marking of practicals. 50% unseen examination
Books UNIX System V: A Practical Guide Mark G. Sobell Addison Wesley; 3 edition (1994) ISBN: 080537566X Get it used! Fortran 90/95 for Scientists and Engineers (Paperback) Chapman Stephen J. McGraw Hill Higher Education ISBN: 0071232338
Fortran 77 Programming T. M. R. Ellis Addison-Wesley; 2 Sub edition ISBN: 0201416387 Getting Started with MATLAB 7: A Quick Introduction for Scientists and Engineers (Paperback) Rudra Pratap Oxford University Press ISBN: 0195179374
Computer Hardware Image courtesy of Wikipedia
Central Processing Unit CPU http://www.intel.com
CPU Components • Core • Branch predictor • Floating Point Unit • Level 1 Cache • Bus Interface Different Architectures RISC: SUN – Motorola CISC: Intel
RAM: Random Access Memory Random access memory (usually known by its acronym, RAM) is a type of computer data storage. It today takes the form of integrated circuits that allow the stored data to be accessed in any order, i.e. at random. The word random thus refers to the fact that any piece of data can be returned in a constant time, regardless of its physical location and whether or not it is related to the previous piece of data. (wikipedia) 110 MB Harddisk 6495 MB Images: Wikipedia Physics Nobel Prize 2007!
Operating Systems • Resource Manager • Balances software and resources • Kernel • direct control of hardware UNIX only in this module !
File Systems Windows
Unix Home Directory
Moving around in the filesystem cdlocation (change directory) cd (blank) change directory to your main home directory cd~ change directory to your main home directory – same as above cd~earsro change to rost’s main home directory (earsro is my login) cd~/HW change to a directory called “HW” just below your main home dir(.) cd../ go UP one level to the directory above you cd../../ go UP 2 directories (and so on …) cd../graphics go up one directory, then down into a directory called “graphics” cd/nfs/see-fs-01_t1 go to the networked file system see-fs-01_t1
Special Unix characters .The present (active) working directory .. The directory above the present working directory /A divider between hierarchal directories when listing paths *Awildcard that matches any sequence of characters ?Awildcard that matches any single character ; separates separate UNIX commands on one line ! Relates to history (past typed commands) ~ Location of a main home directory & Causes a command or program to run in the "background" | Routes standard output from a command to the next command ("pipe") > Routes standard output from a command to create a new specified file >! Same as above: however, if file already exists, replace it >> Routes standard output from a command to append to the specified file < Routes a specified file to be input to a command SPACE Yes, a space... spaces are important in UNIX, they act as field separators
What’s there? ls location and/of filename info (list) Some ls flag options ls –a list all entries, including those that begin with a dot (.) that are normally hidden ls –l list in long format, giving mode, ACL indication (see below) number of links, owner, group, size in bytes, and time of last modification for each file ls –s give size in blocks, including indirect blocks for each entry ls –sa combines the above flags –s and –a (you can combine as many flags as you wish)
Complete File Information (ls –l) type: d – directory, - - ordinary file, l – link permissions: rwx for 3 groups (ugo) links: number of links pointing to this file owner: group: size: length of file in bytes date: last modified (use –u to see date of last access) name: Name of file
ls examples ls ~ list what's in your main home directory ls ~/SOEE1160 list what's in your “SOEE1160“ directory, which is in your main home directory ls .. list what is in the directory directly above you ls ../.. list what's UP 2 directories ls ~earsro list what's in my main home directory
Copying and Moving files cppresent_location/present_name new_location/new_name (copy) mvpresent_location/present_name new_location/new_name (move) Creating new directories mkdirnewdirectory (make directory) Where are you? pwd (print working directory)
moving/copying examples mkdirtest First we will make a directory called "test", then we can copy files there cp~earsro/.cshrc ~/test/.cshrc_earsro Assuming you successfully created a directory called "test" in your main directory, you are copying the file ".cshrc" from rost’s main directory to your directory "test", and you are renaming the file to be ".cshrc_earsro". Thus, here you copied and renamed in one fell swoop. Now check to make sure it worked. Look at the contents of directory test with ls test mv ~/test/.cshrc_earsro ~/junk Now you are moving the file you just copied to the test directory to your present working directory, and renaming it "junk". You will notice that directory test is now empty. You can delete this directory with rmdir test.
The Shell • UNIX system command processor • part of the UNIX OS that deals with interpreting user input • liaison between you, the user, and all programs/processes/ • resources • C shell, Bourne shell and the Korn shell
Redirecting Output redirect output to a file by using the “>” symbol overwrite a possible existing file with “>!” append to an existing file using “>>”
command {arguments} > output_file command {arguments} >! output_file command {arguments} >> output_file Example using ls ls~earsro/BMP/* > images
Redirecting Input command < input_file
Combining Input and Output redirection command < input_file > output_file
Simple Shell scripts • A shell script always starts with #!/bin/csh • List of commands to be executed Example snoop: #!/bin/csh date >! sneaky who >> sneaky cal >> sneaky Making script executable (only once needed) – check with ls -l chmod+x snoop