Introduction to Unix, DTDM, GrADS

37
Introduction to Unix, DTDM, GrADS http:// www.atmos.ucla.edu /~ fovell /AOSC115/

description

Introduction to Unix, DTDM, GrADS. http://www.atmos.ucla.edu/~fovell/AOSC115/. Some Unix basics (basis of Linux and Mac OS X). The command prompt is $ ( do not type it ) Unix commands presented in Courier font $ ls [lists your “ visible ” files] $ ls -a - PowerPoint PPT Presentation

Transcript of Introduction to Unix, DTDM, GrADS

Page 2: Introduction to Unix, DTDM, GrADS

Some Unix basics(basis of Linux and Mac OS X)

• The command prompt is $ (do not type it)• Unix commands presented in Courier font$ ls

[lists your “visible” files]$ ls -a

[lists all files, including invisible]$ ls -al

[lists all files, includes size & other info]$ pwd

[print working directory - shows your location]

Page 3: Introduction to Unix, DTDM, GrADS

Some Unix basics(continued)

$ mkdir TEST[makes a directory called “TEST”]

$ cd TEST[changes directory to “TEST”]

$ cd ..[moves UP in directory hierarchy]

$ cd TeST[command should FAIL… Unix is usually CASE SENSITIVE – though it isn’t on Mac]

Page 4: Introduction to Unix, DTDM, GrADS

Some Unix basics(continued)

$ touch crap.txt[makes an empty file]

$ gedit crap.txt[invoked Notepad-like text editor on Synoptic Lab machines][add some text, save file and exit]

$ ls -al crap.txt[see it’s there]

$ cp crap.txt crap.txt.backup[make a copy with cp]

$ rm crap.txt[the remove command. Asks for confirmation. Don’t type ‘y’]

$ \rm crap.txt[remove without confirmation. Think before hitting ENTER!]

Page 5: Introduction to Unix, DTDM, GrADS

Some Unix basics(continued)

$ mkdir BACKUP[makes a new directory]

$ cp crap.txt.backup BACKUP/.[type exactly as written - there is NO space before the period][the period means “keep the same name”]

$ ls -al BACKUP/[see a copy is in the new location]

$ mkdir BACKUP/more_backup[a new subdirectory in a directory]

$ cd BACKUP/more_backup[move to new subdirectory]

$ cd$ pwd

[cd by itself always takes you to your home directory]

Page 6: Introduction to Unix, DTDM, GrADS

Some Unix basics(continued)

$ cp /home/fovell/part* .[asterisk is wild card character. There IS a space before the period][copies all files matching text pattern to your directory]

$ ls part*[lists files matching pattern]

$ cat part1 part2 > both_parts[concatenates files][greater-than sign is output redirect]

$ more both_parts[more lists contents, one screen at a time][hit space bar for next screenfull, type “q” to quit]

Page 7: Introduction to Unix, DTDM, GrADS

Your Unix PATH

$ cp /home/fovell/execute_me .$ execute_me

- if you receive execute_me: command not found your PATH needs changing

- The PATH is an environment variable that tells Unix where to find stuff, and the order in which to look

$ ./execute_me

- this forces Unix to look in the current directory for the program to run

Page 8: Introduction to Unix, DTDM, GrADS

Fortran compiler

• Try this command$ which ifort

• If you get this… we definitely need to alter your Unix environment

$ ifort: Command not found

Page 9: Introduction to Unix, DTDM, GrADS

Preparation for new users[for users with bash shell ONLY]

$ cd$ mv .bash_profile .bash_profile_old

[mv is move command][.bash_profile is script file of commands, paths, etc., executed for every new terminal window]

$ cat .bash_profile_old /home/fovell/addon2014.sh > .bash_profile[type exactly as shown][greater-than sign is output redirect]

$ source .bash_profile[changes to script file in present window do not take effect until “sourced”]

$ which ifort[see: /opt/intel/composer_xe_2015.0.090/bin/intel64/ifort ]

$ which grads[see /usr/bin/grads]

Page 10: Introduction to Unix, DTDM, GrADS

DTDM on our Synoptic Lab Linux computers

• Synoptic Lab computers open during business hours ONLY and printing is difficult

$ cp /home/fovell/DTDM_package_linux.tar . [note space and period!]

$ tar –xvf DTDM_package_linux.tar

$ cd DTDM

$ make [makes the dtdm executable file]

Page 11: Introduction to Unix, DTDM, GrADS

Using DTDM$ dtdm < input_thermal.txt [runs model, makes output] [less-than sign provides contents of txt file to the dtdm executable]

$ grads –l

[starts up GrADS; ga-> is GrADS prompt]

ga-> open thermal.anelasticga-> query file

Page 12: Introduction to Unix, DTDM, GrADS

Getting to know GrADS• Important commands

open [file] open my_experimentq or query q file, q dimsd or display d theta, d qvaporc or clear cset gxout contour, shaded, print,

scatterd u;v [plots vectorsset t 13 [sets to 13th timeset cint 1.5 [contour intervalset ccolor 4 [contour color blueprintim out.gif gif [makes a GIF plotset display color white [makes white background**quit [quits GrADS

**GrADS 2.1 and later ignores “color”, so ‘set display white’ suffices

http://grads.iges.org/grads/gadoc/gadocindex.html

Page 13: Introduction to Unix, DTDM, GrADS

Using DTDM (cont.)File 1 : DTDM demo simulation Descriptor: thermal.anelastic.ctl Binary: thermal.anelastic.dat Type = Gridded Xsize = 99 Ysize = 1 Zsize = 82 Tsize = 11 Number of Variables = 17 u 82 0 horizontal velocity up 82 0 pert horizontal velocity w 82 0 vertical velocity th 82 0 potential temperature thp 82 0 pert potential temperature pi 82 0 ndim pressure pip 82 0 pert ndim pressure ppmb 82 0 pert pressure in millibars pbyc 82 0 buoyancy pressure in millibars pdyn 82 0 dynamic pressure in millibars ptot 82 0 total pressure in millibars dudtd 82 0 U acceleration - dynamic dudtb 82 0 U acceleration - buoyancy dudtt 82 0 U acceleration - total dwdtd 82 0 W acceleration - dynamic dwdtb 82 0 W acceleration - buoyancy dwdtt 82 0 W acceleration - total

• running dtdm model created two new GrADS files:thermal.anelastic.ctlthermal.anelastic.dat

• contents of thermal.anelastic.ctlshown at left

Page 14: Introduction to Unix, DTDM, GrADS

ga-> set t 6ga-> start.gsga-> d thp

Page 15: Introduction to Unix, DTDM, GrADS

ga-> cga-> set black 0 0ga-> d thp

Page 16: Introduction to Unix, DTDM, GrADS

ga-> d ppmb[Note zero contour is back…]

Page 17: Introduction to Unix, DTDM, GrADS

ga-> cga-> set ccolor 1ga-> d pbyc

Page 18: Introduction to Unix, DTDM, GrADS

ga-> cga-> set ccolor 4ga-> d pdyn

Page 19: Introduction to Unix, DTDM, GrADS

GrADS default color sequence

http://grads.iges.org/grads/gadoc/gadocindex.html

Page 20: Introduction to Unix, DTDM, GrADS

ga-> cga-> set ccolor 2ga-> d w*100

Page 21: Introduction to Unix, DTDM, GrADS

ga-> cga-> set gxout shadedga-> d wga-> scripts/cbarn.gsga-> set gxout contourga-> set ccolor 1ga-> d dwdtt

dwdtt isLagrangiandw/dt, notEulerian∂w/∂t

Page 22: Introduction to Unix, DTDM, GrADS

ga-> set t 9ga-> cga-> d u;w

Page 23: Introduction to Unix, DTDM, GrADS

ga-> cga-> d skip(u,2,3);w

Control vector length withset arrscl 0.5 20.0[standard length set to 20 m/s]

Page 24: Introduction to Unix, DTDM, GrADS

ga-> cga-> q dimsga-> set x 30 70ga-> set xaxis 30 70 10ga-> d skip(u,2,3);w

Zoom in

Page 25: Introduction to Unix, DTDM, GrADS

ga-> draw xlab x (km)ga-> draw ylab height (km)ga-> draw title EXP01 uw t=9ga-> printim example01.gif gif

Outside of GrADS, can display images using display

Page 26: Introduction to Unix, DTDM, GrADS

scripts/thermal.gs'set mproj off''set display color white''clear''set grads off''scripts/rgbset.gs'* plot w'set x 30 70''set gxout shaded''set clevs -12.5 -10 -7.5 -5 -2.5 0 2.5 5 7.5 10 12.5''set ccols 49 47 45 43 41 0 61 62 63 65 67 69''d w''scripts/cbarn.gs''set gxout contour'

http://grads.iges.org/grads/gadoc/script.html#intro

Page 27: Introduction to Unix, DTDM, GrADS

ga-> set t 6ga-> scripts/thermal.gs

Page 28: Introduction to Unix, DTDM, GrADS

Three important commands

ga-> reset• resets GrADS environment to starting

conditions… Time dimension set to 1st time, gxout to contour, etc.. Does not close open files.

ga-> reinit• resets AND closes all open files. “All but

quit.”

ga-> quit

Page 29: Introduction to Unix, DTDM, GrADS

Running another case$ gedit [edit input_thermal.txt] [change casename, ianelastic, csnd]

&experiment casename = 'thermal.nonanelastic.30', $

&framework ipressure = 1, ianelastic = 0, csnd = 30., $

$ dtdm < input_thermal.txt

Page 30: Introduction to Unix, DTDM, GrADS

Multiple files with GrADS$ grads –l

ga-> open thermal.anelasticga-> open thermal.nonanelastic.30

When multiple files are open, append file number to variable name: e.g., d thp.2

Page 31: Introduction to Unix, DTDM, GrADS

ga-> start.gsga-> set t 11ga-> scripts/thermal.gsga-> set gxout contour ga-> set ccolor 1ga-> set cthick 8ga-> set cint 0.1ga-> d ppmb.1-ppmb.2

Page 32: Introduction to Unix, DTDM, GrADS

Animations made painless

ga-> step.gs thp 1 11 1.0

Plots field thp…for steps through times 1 through 11, inclusive…with contour interval 1.0…hit return to proceed to the next time

Page 33: Introduction to Unix, DTDM, GrADS

ga-> cga-> set x 50ga-> set z 1ga-> set t 1 11ga-> d max(w,z=1,z=82)ga-> set ccolor 4ga-> d max(w.2,z=1,z=82)

Time series plots

Page 34: Introduction to Unix, DTDM, GrADS

ga-> cga-> set x 50ga-> set z 1 82ga-> set t 1 11ga-> d thp

Hovmoller plots

Page 35: Introduction to Unix, DTDM, GrADS

More on GrADS image output

ga-> printim image01.pngga-> printim image01.jpg jpg

ga-> enable print image01.mga-> printga-> disable print

Once a *.m file is created, it can be converted (outside of GrADS) to a postscript or eps file

$ gxps –c –i image01.m –o image01.ps$ gxeps –c –i image01.m –o image01.eps

GrADS 2.1 simplifies all of this…

Page 36: Introduction to Unix, DTDM, GrADS

Final cautions

• Make backups

• This command runs the model$ dtdm < input_thermal.txt

• This command destroys the input file!$ dtdm > input_thermal.txt

Page 37: Introduction to Unix, DTDM, GrADS

Advice

• Don’t ask what’s the least you can do for me. Instead, ask what’s the most you can do for yourself.