CASEFAQ

Guidelines on using CASE computer
Users responsability and roles

Setting up CASE computers

A. Getting an account

B. File management and editing

C. Make files

D. Evaluating program performance

E. Automated tar-ing and zip-ing of files.

F. Graphics.

G. Printing files.

H. Tex stuff.

I. Running Background Processes

J. Linux Box Trouble Shooting.

B. File management and editing

How to create 9 files named 1.hpp, 2.hpp, .., 9.hpp in the current directory, each file containing the string 1.hpp, 2.hpp, .., 9.hpp:
theis{serre} 21: set a=1 

theis{serre} 22: while ($a<10) 

? echo $a.hpp > $a.hpp 

? @ a += 1 

? end 

theis{serre} 23: ls 

1.hpp 2.hpp 3.hpp 4.hpp 5.hpp 6.hpp 7.hpp 8.hpp 9.hpp 

theis{serre} 24: more 1.hpp 

1.hpp
Back to: A. File management and editing
How to rename each x.hpp file to x.h:
theis{serre} 25: foreach x (*.hpp) 

? mv $x $x:r.h 

?end 

theis{serre} 26: ls 

1.h 2.h 3.h 4.h 5.h 6.h 7.h 8.h 9.h
Back to: A. File management and editing
How to copy each x.h file to x.H and replace each instance of a "hpp" string with a "h" string:
theis{serre} 27: foreach x (*.h) 

? cat $x | sed -e 's/hpp/H/g' > $x:r.H 

? end 

theis{serre} 28: ls 

1.H 2.H 3.H 4.H 5.H 6.H 7.H 8.H 9.H 

1.h 2.h 3.h 4.h 5.h 6.h 7.h 8.h 9.h 

theis{serre} 29: more 1.H 

1.H
Back to: A. File management and editing
How to grab each instances of the string "hpp" in all the *.h files?
theis{serre} 30: grep hpp *.h 

1.h:1.hpp 

2.h:2.hpp 

3.h:3.hpp 

4.h:4.hpp 

5.h:5.hpp 

6.h:6.hpp 

7.h:7.hpp 

8.h:8.hpp 

9.h:9.hpp


Back to: A. File management and editing

How to find all the *.o files in all your directories ?
theis{serre} 31: find ~/. -name '*.o' 

/users/serre/./crap/marc.o
How to delete all *.o files from all your directories?
theis{serre} 32: rm `find ~ -name '*.o'`
Back to: A. File management and editing

C. Make files

What's a simple make file from Marc What's a simple make file (Example 1, simple, fairly reliable): What's a simple make file (Example 2):
makefile example 2 (from COMP121: Introduction to Data Structure)
What's another make file (Example 3):
makefile example 3 (from COMP121: Introduction to Data Structure)
What's another make file (Example 4, might not work):
makefile example 4 (from COMP121: Introduction to Data Structure)


Back to: B. Make files

D. Evaluating program performance

How to evaluate the performance of the program myprogram using hpm on Cray taking input from the data file mydata.dat and redirecting the output to a file outfile.out:
% hpm myprogram < mydata.dat > & outfile.out
How to clock different part of a program:
Use the clock() function in time.h. Here is a C++ example:
#include <time.h>

#include <iostream.h>
main() 

{

  int i,ni;

  clock_t t1,t2,t3;

  double tdiff1,tdiff2;

  ni=3456;

  cout << "calculating loop one: "<<endl;

  t1 = clock();

  for (i=0; i<ni; i++) {                         

    cout << (int)(100*i/(ni)) << "\%\r" << flush;

    //your calculation

  }

  t2 = clock();

  tdiff1 = double ( t2 - t1 ) / CLOCKS_PER_SEC ;

  cout << tdiff1 << " sec      " << endl;



  ni=4567;

  cout << "calculating loop two: " << endl;

  for (i=0; i<ni; i++) {                         

    cout << (int)(100*i/(ni)) << "\%\r" << flush;

    //your calculation

  }

  t3 = clock();

  tdiff2 = double( t3 - t2 ) / CLOCKS_PER_SEC ;

  cout << tdiff2 << " sec      " << endl;

}
To compile the above program, assuming that the above text is in a file called clockExample.C, just type:
theis{serre} 59: CC -o clockEx clockExample.C
The output of the above example would look like that:
theis{serre} 60: clockEx 

calculating loop one: 0.17 sec 

calculating loop two: 0.27 sec
For more advance techniques, check this web page by Phil Calvin about the Chronograph class, which does timing routine.
 

Back to: C. Evaluating program performance

E. Automated tar-ing and zip-ing of files.

How do I tar the directory dir_name and all its contents into the tar file dir_name.tar? Answer:
theis{serre} 10: ls -F

dir_name/
theis{serre} 11: tar -cvf dir_name.tar dir_name
theis{serre} 12: ls -F

dir_name/     dir_name.tar
Back to: D. Automated tar-ing and zip-ing of files.
How do I untar the tar file dir_name.tar in some target directory? Answer:
theis{serre} 20: ls -F

dir_name.tar
theis{serre} 21: tar -xvf dir_name.tar
theis{serre} 22: ls -F

dir_name/     dir_name.tar
Back to: D. Automated tar-ing and zip-ing of files.
How do I tar and zip the directory dir_name and all its contents into the compressed tar file dir_name.tar.gz? Answer:
theis{serre} 10: ls -F

dir_name/
theis{serre} 11: tar -cvf - dir_name | gzip - > dir_name.tar.gz
theis{serre} 12: ls -F

dir_name/     dir_name.tar.gz
Back to: D. Automated tar-ing and zip-ing of files.
How do I untar and unzip the compressed tar file dir_name.tar.gz in some target directory without wihtout erasing dir_name.tar.gz? Answer:
theis{serre} 20: ls -F

dir_name.tar.gz
theis{serre} 21: gunzip -c dir_name.tar.gz | tar -xvf -
theis{serre} 22: ls -F

dir_name/     dir_name.tar.gz
Back to: D. Automated tar-ing and zip-ing of files.
How do I copy a directory and all its contents without changing the dates or the ownership? Answer:
geek{edhill} 29: tar -cvf - dir_name | ( cd some_other_dir ; tar -xvf - )
Back to: D. Automated tar-ing and zip-ing of files.
How to I tar and zip a bunch of subdirectories and send them to the magneto-optical disk without using temporary storage? Answer:
Note that this has to be done on boffin to put things onto the /mo disk. Please edit the date in the file name and the /mo/edhill directory to reflect your intended target.
boffin{edhill} 29: foreach x (*) 

? if (-d $x) tar -cvf - $x | (cd /mo/edhill2; gzip - > $x"_070396.tar.gz") 

? end
Back to: D. Automated tar-ing and zip-ing of files.

F. Graphics.

I have a cool picture on the screen. How do I save it in .gif or .jpg format? What's the most simple way of plotting an x-y curve?
Use xgraph!

The data to plot must be in a data file with x y rows. Two different curve must be separated with a blank line. Legend for each curve must start with a ". Here is an example:

theis{serre} 43: cat - >data.xg

"line 1

0 1

2 3



"line2

0 1.5

2 2.5

[Ctrl D to get out of cat and create the data.xg file]

theis{serre} 44: /usr/local/bin/xgraph data.xg
Back to: E. Pictures
What's a simple CAD program that lets me draw lines, circles and put text?
Use tgif!

tgif lets you draw line, polylines, circles, add text and color, and saves files in all kind of file formats, including .gif, .html, .latex, .eps, and many others! To start tgif, just type:

theis{serre} 45: /usr/local/bin/X11/tgif
Back to: E. Pictures
[Mac] I want to insert a Matlab plot into a Word document. What do I do?
Follow these simple steps:
1) Within Matlab, create a .eps file of your plot. The easiest way to do this is to issue a command like
>> print('-deps','filename.eps')
for the current plot. Type "help print" if interested in more options.

2) Tranfer the file from the AFS system to your Mac using some file transfer program.
CAUTION: If you use the "Fetch" software set *explicitly* the transfer mode to "Text" or Word will not be able to convert the .eps file properly.

3) Go to the Word 5.1 document where you wish to insert the plot. From the menu bar choose: "Insert"-"File" or "Insert"-"Picture" and pick your .eps file. For Word 98 choose instead: "Insert"-"Picture"-"From File".

4) When inserted, your figure may be exceeding the Word page limits. If this is the case, or if you just want to rescale the inserted figure, hold down the "Shift" button on your Mac while clicking on the figure frame and scale it as desired.

Back to: E. Pictures

G. Printing Files.

[lp]What's the simplest way to print a text file? [a2ps] How do I print a text file and save paper? [lp]How do I print a postcript file (extension .ps)? [ghostview] How do I view a postcript file? [dvips] How do I print a dvi file (extension .dvi)? [xdvi] How do I view a dvi file?
Use xdvi!
theis{serre} 55: xdvi filename.dvi
Back to: F. Printing Files
How do I print to the HP LaserJet 4?
As per email from Ed Hill on 18 Nov 1996:
A new 600dpi printer has been added to our network and the print 

quality is very nice.  You can access it using :



  HPs :

    print  .........  lp -dHP_4_PS FILE

    check queue  ...  lpstat

    kill job  ......  cancel JOB_NAME



  SGIs :

    print  .........  lp -dHP_4_PS FILE



where "FILE" is the name of a file and "JOB_NAME" is provided as a 

list by the "lpstat" command.  As always, make sure to send postscript 

files that have a ".ps" extension our you will probably print out a 

hundred or so pages of noise.
Back to: F. Printing Files
How do I print n pages of postcript per pages?
Use psnup!

As per email from Ed Hill on 20 Feb 1997:

The executable is located in "/usr/local/dbin/bin" and the man pages are located in "/usr/local/dbin/man" so you may want to make sure that these entries are included in your environment path and manpath variables, respectively. To turn "annrev96.ps" into a four-pages-per-page "annrev96_4.ps", use

psnup -n 4 annrev96.ps > annrev96_4.ps
also, you can filter whatever postscript files you want to send to the printer using
psnup -n 2 annrev96.ps | lp
If you want to run psnup on pamlico, you may choose between the version in "/usr/local/dbin" or a newer version in the "/opt" directory heirachy. If you have any questions or problems, see me or Phil. Enjoy! Ed

Back to: F. Printing Files

How do I print to the HP DeskJet1200C color inkjet printer?

H. Tex Stuff.

How do I generate a BibTex version of the Pro-Cite database?
Here's the process for making a new set of gwaternum.bib and gwatername.bib files (As per email from Phil Calvinl) :

1. On the PC (the P-120) in Room 105, do the following: Open the gwater.dat database in Procite. It should open up automatically as teh default when you start Procite. Choose View-Sort-by-Authors to get it in alphabetical order. Select all records and then "Mark" them. "Mark" refers to the box on the far left side, and marked records have 'X' in the box. Then select the top 50 or so records that have empty author fields and "Unmark" them. These won't work in bibtex, so they need to be excluded.

2. Choose "Print bibliography" to "word processor file". When the dialog boxes come up for options, check the following details:

-under "Reference," make sure the box to number references is blank. We don't want to number the references.

-under "Fields," choose yes to "show record numbers" and make sure nothing else is checked.

-under "Page," no page numbering Save the file in the "database" directory as a text-only file named "gwater.bib"

4. FTP "gwater.bib" as an ASCII file to /usr/local/TeX/lib/tex/bib on geek.

5. Telnet onto geek (or go log in on it) and do the following:

a) cd /usr/local/TeX/lib/tex/bib
b) make sure you have a copy of the bibtool resource file in your home directory. You can get one by copying it from the current directory, changing the name (from bibtoolrsc to .bibtoolrsc) in the process by doing the following
cp ./bibtoolrsc ~/.bibtoolrsc
c) Execute the following commands:
mv gwaternum.bib gwaternum.old 

mv gwatername.bib gwatername.old 

rm *.old.gz gzip *.old 

cp gwater.bib gwaternum.bib 

bibtool -F gwaternum.bib -o gwatername.bib
The last command takes a couple minutes to execute, and when working correctly, should give you response of about 20 lines, telling you how many of each type of entry were processed. For example:
--- STRING 0 read 0 written 

--- PREAMBLE 0 read 0 written 

--- COMMENT 0 read 0 written 

--- Article 9219 read 9219 written 

--- Book 394 read 394 written 

--- Booklet 0 read 0 written 

--- Conference 0 read 0 written 

--- InBook 0 read 0 written 

--- InCollection 337 read 337 written 

--- InProceedings 1502 read 1502 written 

--- Manual 0 read 0 written 

--- MastersThesis 10 read 10 written 

--- Misc 3 read 3 written 

--- PhDThesis 44 read 44 written 

--- Proceedings 0 read 0 written 

--- TechReport 207 read 207 written 

--- Unpublished 7 read 7 written
If you get anything except for this result (warnings or errors), please make a note of it, and tell Phil or Lara.

You should now have the two databases (gwatername.bib and gwaternum.bib) which are about 4.5 megabytes in size, and the older versions gzipped down to about 0.8-1.0 megabyte in size. If they are not there or are the wrong size, something went wrong! Call Lara, Phil, Clint, or someone to help you. If everything went well, you can now delete gwater.bib (the file you transferred from the PC): rm gwater.bib

6. If you were sucessful with the above steps, make sure Casey has the updated versions by ftp'ing the files (gwaternum.bib and gwatername.bib) to pavo.sph.unc.edu, putting them in the /bibliography/bibtex/ directory.

Back to: G. Tex Stuff

I. Running Background processes

How do I renice a background process ?

J. Linux Box Trouble Shooting.

I cannot log in to my Linux box using my user account. What to do ? We reinstalled Linux and my headphones do not work. What to do ?