CH332 15jan
CH332 15jan
Computational Chemistry
Output:
A few widely used functions in FORTRAN
Note that some of these functions can only be applied to a certain type
of argument: For example, you can not use SQRT on an integer-type
variable
sqrt(float(a))
Input-output statement
v You can name your input file as you want and read that by the code
open (unit = number, file = "name”, status=“old”)
v write(*,*) a will display the value of open (unit = number, file = "name”, status=“new”)
“a” on the terminal
v Most of the codes written above or
display the result on the screen
v write(50,*) a will write the value of “a” in a file
named “fort.50”
A sample program to calculate the volume of an ideal gas
Calculate the volume in c.c. of 3 moles of an ideal gas at pressure 1 bar and temperature 298 K.
To make the code more general
We could ask the user to enter the value of pressure or the program can read it from a file
Arrays
real a(20) A real array of length 20, consists of 20 real numbers stored contiguously in
memory
Average of a set of numbers: You can read them individually
o Let’s say you have a series of numbers, and you want to calculate the mean.
1. One way is to define them with different variable 2. Or you may want to read it from a file
a= 2.0 real a,b,c,d,e,f,g,h,i
b= 4.0 read(10,*)a
c= 5.0 read(10,*)b
read(10,*)c
d= 1.0 read(10,*)d
e= 6.0 read(10,*)e
f= 12.0 read(10,*)f
g= 1.0 read(10,*)g
h= 5.0 read(10,*)h
read(10,*)i
i= 34.0
Mean= (a+b+c+d+e+f+g+h+i)/9
Or you can represent them in an Array
real a,b,c,d,e,f,g,h,i real a(9) consists of 9 real numbers: a(1), a(2), a(3)……a(9)
1 2 3
a11=2, a12=7, a13=-6
2 7 −6 1
a= 2×3 matrix a21=6, a23=3, a33=5
6 3 5 2 2 rows × 3 column
Let’s discuss ideal gas problem
The input file looks like
400
V(cc)
300
200
100
0
0 100 200 300 400 500
p(bar)
A FORTRAN code that takes volume as an array and output
pressure as an array
Vdata.dat
536
506
376
346
316
……. Volume is now represented as
……. an array
56
Process and Job-control
THANK YOU!