Dhrubaditya Mitra

only search my website

Lecture 0 : Preliminary Material

This is a short course, so you have to come prepared and keep pace with the course. To attend the first lecture you have to go through some prerequisites. These lectures are not for absolute beginners, e.g., those who have not seen a computer before. If you are not equipped with any of those listed below it will be difficult for you to follow what is going on.

  • A laptop with some form of Linux/Unix running in it. If you have a windows laptop you can install virtual box www.virtualbox.org in it and run Linux. Among different flavours of Linux I use ubuntu. You are welcome to use any as long as you know how to use it.
  • Your computer must have the following software, a fortran compiler (e.g., gfortran), the utility called \make", some software to plot, e.g., matlab/octave/gnuplot/matplotlib/IDL and you must know how to plot simple plots using that software.
  • Some knowledge of Unix/Linux, e.g., you must know how to open a file, edit it, what a \shell" is and elementary uses of it. How to compile a fortran code and how to run the executable.
  • Also elementary knowledge of computer programming, e.g., how to do simple arithmatic in fortran and simple input/output. To be concrete see that you understand and can run the fortran programs given below.

!*********************************! 
program hello
write(*,*)'hello world'
end program
!*********************************!

!*********************************!
program square
integer, parameter :: N=20
integer :: i,j
do i=1,N
j=i*i
write(*,*) i,j
enddo
end program
!*********************************!

Compile and run each of these two program in your laptop. In the first case you should see the text "hello world". In the second case two columns of integers. You can redirect the output from the second program to a file and the plot the two columns of the file in the software of you choice to see a parabola. Below is how I do it.


> gfortran square.f90
> ./a.out
41 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81
10 100
11 121
12 144
13 169
14 196
15 225
16 256
17 289
18 324
19 361
20 400

Then I want to write the output to a fie (redirect), and plot it. I am using a combination of numpy,scipy and matplotlib to do this. You can install them in your computer and use them. In ubuntu this can be done through synaptic. Otherwise you are welcome to use any other software you know of.


>./a.out >sq
> ipython --pylab
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
Type "copyright", "credits" or "license" for more information.
IPython 0.10 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
Welcome to pylab, a matplotlib-based Python environment.
For more information, type 'help(pylab)'.
In [2]: pp=numpy.loadtxt('sq')
In [4]: plot(pp[:,0],pp[:,1],'o-')
Out[4]: []

The output of the plot is in a separate window which is shown in Fig. 1

Last modified: Wed Apr 25 22:28:34 CEST 2012