introduction to the school of earth sciences unix computer network kevin keay february 8 2010...

41
Introduction to the Introduction to the School of Earth Sciences School of Earth Sciences UNIX computer network UNIX computer network Kevin Keay Kevin Keay February 8 2010 February 8 2010 Presented by Presented by Ailie Gallant Ailie Gallant

Upload: chester-anthony

Post on 30-Dec-2015

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

Introduction to the School of Introduction to the School of Earth SciencesEarth Sciences

UNIX computer networkUNIX computer network

Kevin KeayKevin Keay

February 8 2010February 8 2010

Presented by Presented by

Ailie GallantAilie Gallant

Page 2: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

OutlineOutline

Course materialsCourse materials What is UNIX?What is UNIX? Our UNIX networkOur UNIX network A brief discussion of why we use UNIXA brief discussion of why we use UNIX A taste of UNIXA taste of UNIX A basic overviewA basic overview A typical UNIX taskA typical UNIX task The University of Surrey, The University of Surrey, UNIX Tutorial for UNIX Tutorial for

BeginnersBeginners: Selected topics: Selected topics An Introductory Tutorial on UNIX (a lab session)An Introductory Tutorial on UNIX (a lab session)

Page 3: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

Course materialsCourse materials Handout: Handout:

An Introductory Tutorial on UNIXAn Introductory Tutorial on UNIXwhich is also at:which is also at:

http://www.earthsci.unimelb.edu.au/~kevin/UNIX_Courshttp://www.earthsci.unimelb.edu.au/~kevin/UNIX_Course/e/An_Intro_Tute_on_UNIX_Feb-2009.pdfAn_Intro_Tute_on_UNIX_Feb-2009.pdf

Notes:Notes:Introduction to the School of Earth Sciences UNIX computer Introduction to the School of Earth Sciences UNIX computer networknetworkat:at:

http://www.earthsci.unimelb.edu.au/~kevin/UNIX_Courshttp://www.earthsci.unimelb.edu.au/~kevin/UNIX_Course/Intro_to_SES_UNIX_computer_network.pdfe/Intro_to_SES_UNIX_computer_network.pdf

A useful online resource from the University of Surrey, A useful online resource from the University of Surrey, UNIX UNIX Tutorial for BeginnersTutorial for Beginners,, is available at: is available at:http://http://www.ee.surrey.ac.ukwww.ee.surrey.ac.uk/Teaching/Unix//Teaching/Unix/

Page 4: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

What is UNIX?What is UNIX?

UNIX is a computer operating systemUNIX is a computer operating system Well suited to multi-tasking and multiple usersWell suited to multi-tasking and multiple users Powerful command-line and scripting Powerful command-line and scripting

capabilitiescapabilities Graphic user interface: X WindowsGraphic user interface: X Windows Easily accessed from Microsoft Windows (PC) Easily accessed from Microsoft Windows (PC)

or X Darwin (iMac) as well as a native UNIX or X Darwin (iMac) as well as a native UNIX machinemachine

Important: UNIX is case-sensitiveImportant: UNIX is case-sensitivee.g. e.g. neditnedit is different from is different from NEDITNEDIT or or NeditNedit

Page 5: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

What is UNIX?What is UNIX? (2)(2)

UNIX was developed initially by Bell Labs UNIX was developed initially by Bell Labs circa 1970 and has grown into an open circa 1970 and has grown into an open software project with many world-wide software project with many world-wide collaborators. A history is given at:collaborators. A history is given at:

http://www.bell-labs.com/history/unix/http://www.bell-labs.com/history/unix/ There are many variants e.g. Linux, Mac There are many variants e.g. Linux, Mac

OS X.OS X. Cygwin for Windows is a UNIX emulation Cygwin for Windows is a UNIX emulation

i.e. looks and feels just like UNIX.i.e. looks and feels just like UNIX.

Page 6: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

What is UNIX?What is UNIX? (3)(3)

After three decades of use, the UNIX After three decades of use, the UNIX computer operating system from Bell Labs is computer operating system from Bell Labs is still regarded as one of the most powerful, still regarded as one of the most powerful, versatile, and flexible operating systems (OS) versatile, and flexible operating systems (OS) in the computer world. Its popularity is due to in the computer world. Its popularity is due to many factors, including its ability to run on a many factors, including its ability to run on a wide variety of machines, from PCs to wide variety of machines, from PCs to supercomputers, and its portability - all of supercomputers, and its portability - all of which led to its adoption by many which led to its adoption by many manufacturers.manufacturers.

Page 7: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

Our UNIX networkOur UNIX network (1) Solaris OS:(1) Solaris OS: atlas, mawson, orthus, rossbyatlas, mawson, orthus, rossby (2) Red Hat Linux OS:(2) Red Hat Linux OS: cove, gulf, gyre, tide, wavecove, gulf, gyre, tide, wave (3) Debian Linux OS:(3) Debian Linux OS: vislab01, vislab02, vislab03, vislab01, vislab02, vislab03,

vislab04vislab04 (4) Red Hat Enterprise(4) Red Hat Enterprise Linux OS:Linux OS: abyssabyss ((OSOS means means operating systemoperating system). The single machine ). The single machine

in group 4 (abyss) is the newest and fastest. in group 4 (abyss) is the newest and fastest. At this At this time abyss is the only machine you can access.time abyss is the only machine you can access. The The OS upgrade of the machines in group 3 to Ubuntu OS upgrade of the machines in group 3 to Ubuntu will occur soon. Groups 3-4 are recommended for will occur soon. Groups 3-4 are recommended for most uses. Apart from atlas and orthus, the group 1-most uses. Apart from atlas and orthus, the group 1-2 machines are relatively slow. So, 2 machines are relatively slow. So, normally you normally you would select a Linux machine in group 3 or 4would select a Linux machine in group 3 or 4 unless unless you need to use the Solaris OS. Also, see section 1.1 you need to use the Solaris OS. Also, see section 1.1 of the notes of the notes Introduction to the School of Earth Introduction to the School of Earth Sciences UNIX computer networkSciences UNIX computer network..

Page 8: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A brief discussion of why we use A brief discussion of why we use UNIXUNIX

UNIX machines are generally better at UNIX machines are generally better at multi-tasking than MS Windowsmulti-tasking than MS Windows

Very stable platform from a user Very stable platform from a user standpoint: difficult to crash!standpoint: difficult to crash!

Compilers (Fortran, C) allow the user to Compilers (Fortran, C) allow the user to development their own software or development their own software or implement programs written by othersimplement programs written by others

There are many sophisticated There are many sophisticated commercial packages available e.g. commercial packages available e.g. MatlabMatlab

Page 9: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A brief discussion of why we use UNIXA brief discussion of why we use UNIX(2)(2)

Scripts can be used to automate complex Scripts can be used to automate complex sequences of tasks: leads to efficiency and sequences of tasks: leads to efficiency and reduction of user errors reduction of user errors

Command-line arguments add flexibility and Command-line arguments add flexibility and are very useful in scripts e.g. C-shell scriptsare very useful in scripts e.g. C-shell scripts

There is a global resource of software There is a global resource of software designed to work under UNIX, much of it is designed to work under UNIX, much of it is freely available: you don’t have to develop freely available: you don’t have to develop everything from scratcheverything from scratch

Page 10: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A taste of UNIXA taste of UNIX

Imagine that you have connected to a UNIX Imagine that you have connected to a UNIX machine e.g. abyss, via machine e.g. abyss, via sshssh from a Cygwin from a Cygwin xtermxterm window:window:ssh –Y STUDENT\\user@abyssssh –Y STUDENT\\[email protected]. ssh –Y STUDENT\\[email protected]. ssh –Y STUDENT\\jsmith@abyss

NOTE: Your username NOTE: Your username mustmust be prefixed by the be prefixed by the text STUDENT\\text STUDENT\\

(For staff the prefix is UNIMELB\\ but this is (For staff the prefix is UNIMELB\\ but this is optional).optional).

You will find yourself located in your UNIX home You will find yourself located in your UNIX home folder e.g. folder e.g. /home/keay/home/keay

Page 11: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

Change to another folderChange to another folder

cd /work/keay/Project1cd /work/keay/Project1 /work /work is another disk and the user is another disk and the user

keaykeay may create folders and files may create folders and files within itwithin it

Check that you are in the correct Check that you are in the correct location (optional!)location (optional!)

pwdpwd

/work/keay/Project1/work/keay/Project1

A taste of UNIX (2)A taste of UNIX (2)

Page 12: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A taste of UNIX (3)A taste of UNIX (3)

List the contents (files) of this folderList the contents (files) of this folder

lsls pmsl.cmp sortdata.f Test.dat test2.dat pmsl.cmp sortdata.f Test.dat test2.dat

X.datX.dat List the files with ‘.dat’ as part of the List the files with ‘.dat’ as part of the

filenamefilename

ls *.datls *.dat

Test.dat test2.dat X.datTest.dat test2.dat X.dat

Page 13: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A taste of UNIX (4)A taste of UNIX (4)

Edit the Fortran source file sortdata.f Edit the Fortran source file sortdata.f (we are making changes to the (we are making changes to the existing file)existing file)

nedit sortdata.fnedit sortdata.f

Page 14: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A taste of UNIX (5)A taste of UNIX (5)

Compile the Fortran source program to create Compile the Fortran source program to create an an executableexecutable i.e. a piece of software i.e. a piece of software

g77 –o sortdata sortdata.fg77 –o sortdata sortdata.f

Here the Here the –o–o optionoption expects an expects an argumentargument, in this , in this case the filename of the executable (an option case the filename of the executable (an option could be could be standalonestandalone e.g. e.g. –j–j ) )

Note: An option usually starts with a ‘Note: An option usually starts with a ‘--’’ List the files in the folder (sortdata is a new file)List the files in the folder (sortdata is a new file)

lsls

pmsl.cmp sortdata sortdata.f Test.dat test2.dat pmsl.cmp sortdata sortdata.f Test.dat test2.dat X.datX.dat

Page 15: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A taste of UNIX (6)A taste of UNIX (6)

Run the executable (software) that Run the executable (software) that you designed in Fortranyou designed in Fortran

sortdatasortdata

You might design your program to You might design your program to create an output data file or the create an output data file or the results of a computation, even an results of a computation, even an imageimage

Page 16: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A taste of UNIX (7)A taste of UNIX (7) Create a plot of a pressure fileCreate a plot of a pressure file

conmap –k iconkk –B pmsl.cmp < iconconmap –k iconkk –B pmsl.cmp < icon The items with ‘The items with ‘--’ are called ’ are called optionsoptions and and

control the program called control the program called conmapconmap. The . The –k–k option has an option has an argumentargument – a file called – a file called iconkk which contains some additional iconkk which contains some additional parametersparameters to control the program to control the program

Additional control comes from the Additional control comes from the instructioninstruction file called icon file called icon

The output of this command is a file called The output of this command is a file called gmeta that can be converted to a PNG gmeta that can be converted to a PNG imageimage

Page 17: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A taste of UNIX (7)A taste of UNIX (7)

Page 18: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A basic overviewA basic overview

When you connect to a remote UNIX machine on When you connect to a remote UNIX machine on our network you will be working in the our network you will be working in the C-shellC-shell (actually (actually tcshtcsh which is aliased to which is aliased to cshcsh))

C-shell scriptsC-shell scripts will begin with will begin with ## or or #!/bin/csh -f#!/bin/csh -f There are other kinds of script e.g. There are other kinds of script e.g. shsh (Bourne (Bourne

shell – shell – bashbash under Cygwin is a relative), under Cygwin is a relative), perlperl After connection you will be located in: After connection you will be located in:

/home/user/home/user where ‘user’ is your UNIX usernamewhere ‘user’ is your UNIX usernamee.g. e.g. /home/keay/home/keay

Remember: UNIX is Remember: UNIX is case-sensitivecase-sensitive

Page 19: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A basic overviewA basic overview (2)(2)

Under MS Windows files and folders Under MS Windows files and folders (directories) are usually relative to the C (directories) are usually relative to the C drive i.e. c:drive i.e. c:and under UNIX are relative to and under UNIX are relative to //Also Also \\ is used to denote the file tree is used to denote the file tree structure under Windows and structure under Windows and // under UNIX under UNIXHence:Hence:

c:\home\keay\test.dir\prog.fc:\home\keay\test.dir\prog.funder Windows would be:under Windows would be:

/home/keay/test.dir/prog.f/home/keay/test.dir/prog.funder UNIXunder UNIX

You will be working under You will be working under /home/home or or /work/worke.g. e.g. /home/keay/home/keay,, /work/keay /work/keay

Page 20: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A basic overviewA basic overview (3)(3)

lsls is used to list files in a folder is used to list files in a folder

e.g. e.g. ls readme.txtls readme.txt

ls –l pmsl.*.datls –l pmsl.*.dat Note that the ls command has many Note that the ls command has many

optionsoptions. See: . See: man lsman ls for more for more informationinformation

Page 21: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A basic overviewA basic overview (4)(4)

mkdirmkdir is used to create folders (directories) is used to create folders (directories)e.g. e.g. mkdir test.dirmkdir test.dir

rmdirrmdir is used to remove a folder is used to remove a foldere.g. e.g. rmdir test.dirrmdir test.dirNote: The folder must be empty i.e. use Note: The folder must be empty i.e. use rmrm first, first, thenthen rmdir rmdir

chmodchmod is used to change file access permissions is used to change file access permissions e.g. e.g. chmod 755 readcmpchmod 755 readcmp

oror chmod u+rwx,g+rx,o+rx readcmpchmod u+rwx,g+rx,o+rx readcmpwhere u is user, g is group and o is others.where u is user, g is group and o is others.

Page 22: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A basic overviewA basic overview (5)(5)

rmrm is used to remove (delete) files is used to remove (delete) filese.g. e.g. rm test.datrm test.datBy default rm will remove By default rm will remove withoutwithout warning. warning. Your initial setup will Your initial setup will aliasalias rm such that rm such that rm == rm –irm == rm –i i.e. you will be i.e. you will be promptedprompted to to continue with the removalcontinue with the removal

Prefixing with a Prefixing with a \ \ will will overrideoverride the alias the aliase.g. e.g. \rm –rf */*\rm –rf */* will will delete all of your filesdelete all of your files starting with the current folder – starting with the current folder – BEWARE!BEWARE!

Page 23: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A basic overviewA basic overview (6)(6)

cpcp is used to copy files to other is used to copy files to other locationslocations

e.g. e.g. cp readme.txt /work/keay/srccp readme.txt /work/keay/src mvmv is used to rename files is used to rename files

e.g. e.g. mv readme.txt Readme.txtmv readme.txt Readme.txt

Remember: UNIX is Remember: UNIX is case-sensitivecase-sensitive pwdpwd will tell you where you are i.e. will tell you where you are i.e.

your current location (folder)your current location (folder)

Page 24: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A basic overviewA basic overview (7)(7)

cdcd is used to change folders is used to change folders (directories)(directories)

Assume you are in: Assume you are in: /home/keay/home/keaycd test.dircd test.dir will change the folder will change the folder (directory) to test.dir i.e. you are now in:(directory) to test.dir i.e. you are now in:/home/keay/test.dir/home/keay/test.dir

cd ..cd .. will place you in the folder one level will place you in the folder one level aboveabove i.e. in this case: /home/keay i.e. in this case: /home/keay cd ~cd ~ will always take you ‘home’ i.e. will always take you ‘home’ i.e. to: /home/userto: /home/user

Page 25: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A basic overviewA basic overview (8)(8)

cd /home/keay/srccd /home/keay/src will place you will place you in the folder called srcin the folder called src

cd /work/keay/src/readgrib.dircd /work/keay/src/readgrib.dir

will place you in the folder will place you in the folder readgrib.dir under /work/keay/srcreadgrib.dir under /work/keay/src

Combine Combine .... and and // to change folders to change folders

e.g. e.g. cd ../test2.dircd ../test2.dir

Page 26: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A basic overviewA basic overview (9)(9)

WildcardWildcard characters characters **,,??,,- - andand , , in in conjunction with various brackets conjunction with various brackets {}{} and and [][] are very useful in commands to are very useful in commands to represent complex sets of filenamesrepresent complex sets of filenames

e.g. e.g. cp pmsl.*.dat /work/keay/DATAcp pmsl.*.dat /work/keay/DATA

This will copy all files of this format This will copy all files of this format where the where the ** stands for stands for anythinganything in that in that part of the filename.part of the filename.

Page 27: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A basic overviewA basic overview (10)(10)

?? represents a represents a singlesingle character e.g. character e.g.cp pmsl.cp pmsl.{19[6-9]?,2000,2001}{19[6-9]?,2000,2001}.dat .dat /work/keay/DATA/work/keay/DATA

This will copy: This will copy: pmsl.1960.dat,pmsl.1961.dat,pmsl.1960.dat,pmsl.1961.dat,…, pmsl.1999.dat,pmsl.2000.dat, …, pmsl.1999.dat,pmsl.2000.dat, pmsl.2001.datpmsl.2001.dat

i.e. i.e. {19[6-9]?,2000,2001} {19[6-9]?,2000,2001} is is expandedexpanded to: to:

1960,1961,1962,…,1999,2000,20011960,1961,1962,…,1999,2000,2001

We could also use:We could also use:

pmsl.{19[6-9]?,200[0,1]}.datpmsl.{19[6-9]?,200[0,1]}.dat

Page 28: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

For text editing use For text editing use neditnedit on atlas or on atlas or orthus and orthus and neditnedit or or emacsemacs on the Linux on the Linux machinesmachinese.g. e.g. nedit prog.fnedit prog.f

To transfer files to and from a PC you can To transfer files to and from a PC you can use the utility use the utility SSH Secure File Transfer SSH Secure File Transfer ClientClient on the Windows desktop on the Windows desktop

You can also use You can also use scpscp under Cygwin – see under Cygwin – see Appendix A of the NotesAppendix A of the Notes

A basic overviewA basic overview (11)(11)

Page 29: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A basic overviewA basic overview (12)(12)

Some documentation is available Some documentation is available with with manman or or infoinfo, however it is often , however it is often crypticcryptic

e.g. e.g. man cshman csh Often a Often a GoogleGoogle web search will find web search will find

more helpful information, examples more helpful information, examples and tutorialsand tutorials

Page 30: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A basic overview (13)A basic overview (13)

SummarySummary

The basic UNIX The basic UNIX commandscommands to understand are: to understand are:

ls cd mkdir rmdir rm chmodls cd mkdir rmdir rm chmodcp mv pwd cshcp mv pwd csh

Learn how to use Learn how to use wildcardswildcards::

* ? - , [] {} * ? - , [] {}

Ensure that you can use a Ensure that you can use a text editortext editor::neditnedit (Solaris OS) (Solaris OS) neditnedit emacsemacs (Linux) (Linux)

SSH Secure File Transfer Client (Windows)SSH Secure File Transfer Client (Windows)is useful for is useful for transferring filestransferring files from a PC to a remote UNIX from a PC to a remote UNIX machinemachineAlso see: Also see: scpscp

Page 31: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A typical UNIX taskA typical UNIX task

Task: Prepare average geographical maps of Task: Prepare average geographical maps of mean sea level pressure (MSLP) for the mean sea level pressure (MSLP) for the months of Jan and Aug using NCEP months of Jan and Aug using NCEP Reanalysis data and plot the resultsReanalysis data and plot the results

The data is available in a widely-used format The data is available in a widely-used format called NetCDF from the NOAA web site – this called NetCDF from the NOAA web site – this site has interactive data selection featuressite has interactive data selection features

I manually downloaded the relevant files I manually downloaded the relevant files using a web browser (using a web browser (MozillaMozilla) to my UNIX ) to my UNIX account e.g. /work/keay/mean_MSLP.diraccount e.g. /work/keay/mean_MSLP.dir

Page 32: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A typical UNIX taskA typical UNIX task (2)(2)

I have written a Fortran program I have written a Fortran program ((read_nc2cmpread_nc2cmp) to decode the NetCDF files to ) to decode the NetCDF files to our internal our internal conmapconmap format format

This program was based on an example from This program was based on an example from NCAR so I didn’t have to begin from scratchNCAR so I didn’t have to begin from scratch

The conmap files are then input to my Fortran The conmap files are then input to my Fortran program program statconmapstatconmap which produces the which produces the average mapsaverage maps

Note: The average is performed at each Note: The average is performed at each gridpoint of the map for the set of desired gridpoint of the map for the set of desired mapsmaps

Page 33: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A typical UNIX taskA typical UNIX task (3)(3)

The average maps (one for Jan, the other for Aug) The average maps (one for Jan, the other for Aug) may be plotted with various software e.g. NCAR may be plotted with various software e.g. NCAR Graphics, GrADS, MatlabGraphics, GrADS, Matlab

One method that is useful in scripts is:One method that is useful in scripts is:(1) run (1) run conmapconmap (NCAR Graphics) on an average (NCAR Graphics) on an average map; output is a file called gmeta map; output is a file called gmeta (2) Translate gmeta to a Postscript file using the (2) Translate gmeta to a Postscript file using the utility utility g2psg2ps(3) Use the utility (3) Use the utility convertconvert to transform the to transform the Postscript file to a PNG file – this may be pasted Postscript file to a PNG file – this may be pasted into a Word document into a Word document

Page 34: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A typical UNIX taskA typical UNIX task (4)(4)

In a UNIX C-shell window you can type commands In a UNIX C-shell window you can type commands directly e.g.directly e.g.

read_nc2cmp MSLP.*.Jan.nc out.cmpread_nc2cmp MSLP.*.Jan.nc out.cmp

statconmap out.cmp ave.Jan.cmp sd.cmp statconmap out.cmp ave.Jan.cmp sd.cmp var.cmpvar.cmp

conmap –G ave.Jan.cmpconmap –G ave.Jan.cmp

You can also place these commands in a C-shell scriptYou can also place these commands in a C-shell script

Page 35: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A typical UNIX task (5)#!/bin/csh –f # Required first line of a C-shell script or simply #set mons = (Jan Aug) # Array of months@ nmons = $#mons # No. of months, in this case it will be 2@ i = 1 # @ is used to define numbers as opposed to text (set)while ($i <= $nmons) # Perform loop (to end) while i <= 2 set m = $mons[$i] # m is mons(i) i.e. mons(1) = Jan => m = Jan# Decode NetCDF files for this month (m)# Note: out.cmp contains multiple maps read_nc2cmp MSLP.*.$m.nc out.cmp# Perform average of multiple conmap file out.cmp# Note: Outputs sd.cmp and var.cmp are not used but need to be

specified statconmap out.cmp ave.$m.cmp sd.cmp var.cmp# Create global geographical plot of average map e.g. ave.Jan.cmp conmap –G ave.$m.cmp # Output is gmeta# Convert gmeta file to Postscript; creates g.ps (a hardwired output) g2ps gmeta# Convert Postscript file to PNG e.g. MSLP.Jan.png convert –trim –density 120 g.ps MSLP.$m.png# @ i ++ # i -> i + 1endexit

Page 36: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

A typical UNIX taskA typical UNIX task (6)(6)

We won’t look in detail at scripts in this We won’t look in detail at scripts in this introduction but will re-visit them later in introduction but will re-visit them later in the semesterthe semester

The data processing and display sequence The data processing and display sequence is not unique. Depending on your project is not unique. Depending on your project you may use other tools e.g. GrADS, NCL, you may use other tools e.g. GrADS, NCL, PythonPython

Remember: Practice makes perfect!Remember: Practice makes perfect!Experiment … play with the commands Experiment … play with the commands and see if things make senseand see if things make sense

Page 37: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

The University of Surrey, The University of Surrey, UNIX UNIX Tutorial for BeginnersTutorial for Beginners: Selected : Selected

topicstopics

See:See:

http://www.ee.surrey.ac.uk/Teaching/Uhttp://www.ee.surrey.ac.uk/Teaching/Unix/nix/

Note: Tutorial 7 is a bit advanced for Note: Tutorial 7 is a bit advanced for this introductionthis introduction

Page 38: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

An Introductory Tutorial on An Introductory Tutorial on UNIXUNIX

Refer to the handoutRefer to the handout Also see:Also see:

Appendix CAppendix C

An Introductory Tutorial on UNIXAn Introductory Tutorial on UNIX

of the notesof the notes

Page 39: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

An Introductory Tutorial on UNIXAn Introductory Tutorial on UNIX(2)(2)

Direct connection to a UNIX machineDirect connection to a UNIX machine

From the console of a machine in the UNIX Lab or the VisLab:From the console of a machine in the UNIX Lab or the VisLab:(1) Log on with your UNIX username and password(1) Log on with your UNIX username and password

(2) You should be in the KDE desktop. Left-click on the Shell-Konsole (2) You should be in the KDE desktop. Left-click on the Shell-Konsole icon or Terminal Program icon in the toolbar at the bottom of the icon or Terminal Program icon in the toolbar at the bottom of the screen. This will activate a terminal window (xterm). You may now screen. This will activate a terminal window (xterm). You may now enter UNIX commands.enter UNIX commands.

Remote connection to a UNIX machine via CygwinRemote connection to a UNIX machine via Cygwin

From a PC in the PC Lab or elsewhere:From a PC in the PC Lab or elsewhere:(1) Log on with your University username and password(1) Log on with your University username and password(2) Click on the Cygwin desktop icon. This will open a bash shell (2) Click on the Cygwin desktop icon. This will open a bash shell window.window.(3) Within this window type: (3) Within this window type: startx &startx & This will open a terminal window This will open a terminal window (xterm).(xterm).(4) Within the terminal window type: (4) Within the terminal window type: xterm &xterm & to open a new window. to open a new window. From this From this newnew window type: window type: ssh –Y STUDENT\\user@machinessh –Y STUDENT\\user@machine Note for ‘machine’ choose from: Note for ‘machine’ choose from:

abyss,atlas,orthus,cove,gyre,tide,wave,vislab01,vislab02,vislab03abyss,atlas,orthus,cove,gyre,tide,wave,vislab01,vislab02,vislab03

Page 40: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

An Introductory Tutorial on UNIXAn Introductory Tutorial on UNIX(3)(3)

Initial setup of a UNIX accountInitial setup of a UNIX account

Connect to a remote UNIX machine – right Connect to a remote UNIX machine – right now you only have access to abyss:now you only have access to abyss:

ssh –Y STUDENT\\user@abyssssh –Y STUDENT\\user@abyss After logging on:After logging on:

% cp /home/keay/UNIX_Course/zunix_setup.zip % cp /home/keay/UNIX_Course/zunix_setup.zip ..- Note the dot- Note the dot% unzip zunix_setup.zip% unzip zunix_setup.zip% ls –l .cshrc.*% ls –l .cshrc.*% exit% exit

Page 41: Introduction to the School of Earth Sciences UNIX computer network Kevin Keay February 8 2010 Presented by Ailie Gallant

An Introductory Tutorial on UNIXAn Introductory Tutorial on UNIX(4)(4)

Owing to recent changes you can only Owing to recent changes you can only use abyss:use abyss:

e.g. e.g. ssh –Y STUDENT\\jsmith@abyssssh –Y STUDENT\\jsmith@abyss Hence run the tutorial on abyssHence run the tutorial on abyss