200 likes | 473 Views
UNIX Utilities. Zion Wang, Gail Tonnesen UCR Regional Modeling Center Training January 16, 2002. UNIX Overview. The following is designed to provide CMAQ users with both an overview of the UNIX commands and utilities commonly used for a successful CMAQ simulation.
E N D
UNIX Utilities Zion Wang, Gail Tonnesen UCR Regional Modeling Center Training January 16, 2002
UNIX Overview • The following is designed to provide CMAQ users with both an overview of the UNIX commands and utilities commonly used for a successful CMAQ simulation. • The three main areas we will adress are: • Unix; • the CVS software; and • the make utility. University of California at Riverside, Regional Modeling Center (RMC)
UNIX System • An operating system (or “OS”) is a set of programs that controls a computer. It controls both the hardware and the software. • The UNIX operating system was invented almost 30 years ago for scientific and professional users who wanted powerful yet flexible OS. • It’s been under continuous and rapid development for all these years. There are many different versions of UNIX. • They include commercial versions such as SunOS, Solaris, HP/UX, AIX, ULTRIX and freely distributed versions such as Linux and FreeBSD. (“Learning the UNIX Operating System 4th Edition”, O’Reilly). University of California at Riverside, Regional Modeling Center (RMC)
UNIX Commands • Commonly used commands: • date: Get today’s date • who: List logged-in users • whoami: Find out who is at your terminal • man: Provides the correct syntax for entering a command or the particular features of a program • pwd: Prints the absolute pathname of your working directory • cd: Change directory • ls: List the entries in the directory • cat: Display contents of the file on the standard output (screen) University of California at Riverside, Regional Modeling Center (RMC)
UNIX Commands • mkdir: To create a new directory • rmdir: To remove a directory • cp: Copy a file • rm: To remove files or directories • mv: To rename a file or move file(s) from one location to another • find: To find a file • grep: Searches a file or files for lines that have a certain pattern • sort: Arranges lines of text alphabetically or numerically • ps: Check on the status of processes • kill: Aborts a command University of California at Riverside, Regional Modeling Center (RMC)
UNIX Commands • | : Pipe – join two or more commands together • & : If used at the end of a command, “&” sends the command to the background • > : Redirect output to a file • >> : Append output to an existing file • nedit: a text editor available on RMC machines • a2ps: command to print ascii files on RMC machines • For more information on UNIX commands, please refer to Appendix A of the User’s Guide. University of California at Riverside, Regional Modeling Center (RMC)
UNIX – CVS System • A source code control system is a MUST to manage the changes occurring to a software project during development. • Developers need a complete history of changes to backtrack to previous versions in case of any problems. • Due to the huge amount of time and money investigated in software development, it is very important to spend some time in safe-guarding the source code by using source code control systems like CVS and RCS. • CVS (Concurrent Version Control System) is a powerful tool which allows concurrent development of software by multiple users. • It uses RCS underneath and has an application layer interface as a wrapper on top of RCS. University of California at Riverside, Regional Modeling Center (RMC)
UNIX – CVS System • CVS can record the history of your files (usually, but not always, source code). • CVS only stores the differences between versions, instead of every version of every file you've ever created. • CVS also keeps a log of who, when and why changes occurred, among other aspects. • CVS is very helpful for managing releases and controlling the concurrent editing of source files among multiple authors. • Instead of providing version control for a collection of files in a single directory, CVS provides version control for a hierarchical collection of directories consisting of revision controlled files. • These directories and files can then be combined to form a software release. (“CVS-RCS – How-To Document for Linux (Source Code Control System)”) University of California at Riverside, Regional Modeling Center (RMC)
UNIX – CVS System • To use CVS, first you need to install the CVS package. • Please consult your system administrator regarding the installation of CVS on your system. • The CVSROOT environment variable would need to be setup prior to using CVS. • The following example shows how to setup CVSROOT on c-shell. setenv CVSROOT ~/rmc/models.linux/CMAQ/models/MCIP • For more information on CVS, please refer to Appendix B of the User’s Guide. University of California at Riverside, Regional Modeling Center (RMC)
UNIX – CVS System • CVS provides a rich variety of commands, each of which often has a wealth of options. • It is not necessary to master every detail to do useful work with CVS. • Actually, five commands are sufficient to use the source repository. They are: • checkout, • update, • add, • remove, and • commit. • Examples of CVS syntax are:cvs checkout MCIP cvs commit -m ‘Increase dimension to 200’ University of California at Riverside, Regional Modeling Center (RMC)
UNIX – CVS Commands • checkout: Creates your private copy of the source for modules. At least one subdirectory level is always created. • update: Execute this command form within your private source directory when you wish to update your copies of source files from changes that other developers have made to the source in the repository. • add: Enroll new files in CVS records of your working directory. The files will be added to the repository the next time “cvs commit” is run. • remove: “cvs remove” eliminates files from the repository. The command doesn’t take affect until you run “cvs commit”. • commit: Publishes your changes to other developers by incorporating them in the source repository. University of California at Riverside, Regional Modeling Center (RMC)
UNIX – make • The make command allows you to manage large programs or groups of programs. • As you begin to write larger programs, you will notice that re-compiling larger programs takes much longer than re-compiling short programs. • Moreover, you notice that you usually only work on a small section of the program (such as a single function that you are debugging), and much of the rest of the program remains unchanged. • The make program aids you in developing your large programs by keeping track of which portions of the entire program have been changed, compiling only those parts of the program which have changed since the last compile. • For more information on make, refer to Appendix C of the User’s Guide (or http://www.eng.hawaii.edu/Tutor/Make ). University of California at Riverside, Regional Modeling Center (RMC)
UNIX – Make • Simple Compilation: University of California at Riverside, Regional Modeling Center (RMC)
UNIX – make • Compilation with several files: University of California at Riverside, Regional Modeling Center (RMC)
UNIX – make • Separate Compilation Steps: University of California at Riverside, Regional Modeling Center (RMC)
UNIX – make • Dependency: University of California at Riverside, Regional Modeling Center (RMC)
UNIX – make • Dependency: University of California at Riverside, Regional Modeling Center (RMC)
UNIX – make • How does make do it? University of California at Riverside, Regional Modeling Center (RMC)
UNIX – make • Translating the Dependency Graph: University of California at Riverside, Regional Modeling Center (RMC)
UNIX – make • Sample (simple) Makefile: OBJECTS = data.o main.o io.o project1.x: $(OBJECTS) cc $(OBJECTS) -o project1.x data.o: data.c data.h cc -c data.c main.o: data.h io.h main.c cc -c main.c io.o: io.h io.c cc -c io.c University of California at Riverside, Regional Modeling Center (RMC)