Energy Units and Conversion using FORTRAN
Energy Units and Conversion using FORTRAN
This is the Fortran 77 program for energy conversion. Convert energy from Hartree to eV, kJ/mol, kcal/mol, cm-1, and V.
Why FORTRAN?
FORTRAN, a low-level programming language, is
fast for scientific calculation. However, you would not see the difference in the speed of calculation between Fortran and other programming languages.
easy to list-directed formatting, editing is controlled by the types and lengths of the data being read or written.
able to run on any Linux distribution and any platform with a compiled application (binary file).
conv.f
c-----------------------------------------------
c Energy conversion
c Hartrees --> eV, kJ/mol, kcal/mol, cm-1, and V
c-----------------------------------------------
program convert_energy
real Har, eV, kJmol, kCmol, cm, V, K, Kb
character ARGV*10
c N=iargc()
call getarg(1,ARGV)
c RARGV will convert ARGV into floating-point integer.
read (ARGV,*) rargv
c Assign ARGV to Har
read (ARGV,*) Har
eV = Har * 27.211399
J = Har * 4359.7482e-21
kJmol = Har * 2625.5002
kCmol = Har * 627.5096080305927
cm = Har * 219474.63
V = Har * 27.211598534895728
write (6,'(/,a,/)') " === Energy Converter ==="
write (6,100) Har, "Hartree"
write (6,100) eV, "eV"
write (6,200) J, "J"
write (6,100) kJmol, "kJ/mol"
write (6,100) kCmol, "kCal/mol"
write (6,100) cm, "cm^-1"
write (6,100) V, "V for 1 e- transfer"
write (6,100)
100 format (f20.5,2x,a)
200 format (e20.5,2x,a)
stop
end
Compilation and Usage
1. Compile program
use GNU Fortran compiler
gfortran conv.f -o conv
use Intel Fortran compiler
ifort conv.f -o conv
2. Execute conv program with energy without Hartree unit
For example, 1.0 Hartree
./conv 1.0
Example of Output
=== Energy Converter ===
1.00000 Hartree
27.21140 eV
0.43597E-17 J
2625.50024 kJ/mol
627.50958 kCal/mol
219474.62500 cm^-1
27.21160 V for 1 e- transfer
Rangsiman Ketkaew