Title: Computational Science I
1Computational Science I
- Lecture 15
- CAAM 420, Fall 2004
- Instructor Tim Warburton
2Nice List of Quick Sheets
- http//www.digilife.be/quickreferences/quickrefs.h
tm
3Building Code Components
- We have previously seen the basic components
needed for coding components of a project - developing a struct
- designing a set of interface functions to the
struct - implementing the struct, interface and functions
- debugging testing the interface
- interfacing with libraries (in particular fortran
libraries) - wrapping awkward library functions as part of
your interface.
4Big Picture
- Once a coding task is sufficiently complicated it
is wise to pay attention to the way the code is
structured. - A typical main function should contain not much
more than the following - include data.h
- main(int argc, char argv)
- data taskdata inputdata(argc, argv)
-
- compute(taskdata)
-
- outputdata(taskdata)
-
- Thus we have introduced the idea of a (user
defined) overarching data struct, which
represents all the input and output dat together
in one place. - This approach requires us to organize the input
and output data and clearly distinguishes between
the collection of input and output of data, and
the process required to compute the output data
using the input data. - Note we can certainly include other types of
structs (or pointers to structs) in the data
struct.
5Documenting Your Efforts
- We have at our disposal a powerful typesetting
program, LaTex, used for a large percentage of
all academic papers. - Nice notes at
- http//www.esm.psu.edu/courses/latex-course/lectur
es.html - I have uploaded a report template to the website.
Those of you who have previously used non-LaTex
type setting programs must start formatting their
project and assignments using LaTex.
6Using the Report Template
- Use emacs to edit the following files
- ReportTemplate/report.tex
- ReportTemplate/introduction.tex
- ReportTemplate/method.tex
- ReportTemplate/results.tex
- ReportTemplate/discussion.tex
- ReportTemplate/code.tex
- You can compile the LaTex project with
- latex report.tex
- dvips o report.ps report.dvi
- ps2pdf report.ps
7report.tex
LaTex extension packages
Set up for the left and right headers. Customize
by editing the text of arguments to lhead and
rhead
Creation of the title page, edit author and title
to customize.
This reads in the section files and the appendix
file.
8introduction.tex, method.tex, and discussion.tex
9results.tex
Here I use the verbatim environment to
allowunformatted text.
Here I use the figure environment to includean
eps formatted figure.
10code.tex
- In code.tex I use the verbatiminput command to
include a piece of C code. - I also used \hrule to put a line before and after
the piece of code and I set the fontsize to
be small.
11CVS (Concurrent Versions System)
- Online project
- https//www.cvshome.org/
- Each one of you is going to set up a CVS
repository. - Work through each step with me.
- FOR SOME REASON CVS IS NOT AVAILABLE ON ruf, SO
USE jungle.owlnet.rice.edu
12CVS (Concurrent Versions System)
- http//web.presby.edu/wasmith/courses/415/cvsChea
tSheet.htm - Suppose I arrange my code in the following way
- /cvstest
- /cvstest/Code
- /cvstest/Data
- Then I can create a CVS repository from the Code
directory (i.e. import the contents of Code, with
CVS annotation and control), into a CVS source
controlled directory - setenv CVSROOT /cvstest/Repository/
- cvs -d CVSROOT init
- cd /cvstest/Code
- cvs import -m "first comment" Code foo bah
13CVS Checkout
- mkdir /cvsworking
- cd /cvsworking
- cvs checkout Code/Make.opts
- U Code/Make.opts
- cvs checkout Code/Makefile
- U Code/Makefile
- cvs checkout Code/dmat.c Code/dmat.h
Code/lapack.h Code/mylapack.c Code/blas.h - U Code/dmat.c
- U Code/dmat.h
- U Code/lapack.h
- U Code/mylapack.c
- U Code/blas.h
14Using the Checked Out Files
i.e. we have successfully retrieved and compiled
the files NOTE we are using these files in
a working directory.
15Edit Checked Out Files
- Only edit files you have checked out, not the
files sitting in the CVS repository directory. - Once you have edited a checked out file, you
should commit the changes using CVS - cvs commit -m "changed dmatinput and dmatoutput
comments" Code/dmat.c - Checking in Code/dmat.c
- /home/timwar/cvstest/Repository/Code/dmat.c,v
- new revision 1.2 previous revision 1.1
- Done
- To give you an idea how these changes are stored
look at the ,v file.
16Adding an Extra File to the Repository
- cvs add foo.c
- cvs commit m initial version foo.c
17Removing a File From the Repository
- rm foo.c
- cvs remove foo.c
- cvs commit m bye bye foo.c