fortran95 - what does this piece of fortran mean? -
im trying go through little algorithm in fortran (im not fortran programmer unfortunately) need understand doing: here is,
omega = 0.d0 s = 1.d0 = 1 j = 2 k = 3 101 iperm = 1, 3 omega = omega + s * a1 (i) * a2 (j) * a3 (k) l = = j j = k k = l enddo = 2 j = 1 k = 3 s = - s if (s.lt.0.d0) goto 101 omega = abs (omega) * alat**3
a1,a2,a3
vectors (three elements each, real values, representing vectors in 3d space) s
unit integer (can 1 or -1 alternately) , i,j,k
integers while omega
(which need understand how arrived at) floating point value, alat
. going on there? iperm =1,3
part, vector being created? @ first thought iperm might fancy function/routine or iterator, after search think thats not case, whats purpose of iperm? there looping on iperm
between "do
" , "enddo
" ?
all you've got sequence of assignments loop thrown in fun. guess understand statement such as
lhs = rhs
evaluates rhs
, assigns result variable lhs
.
the line
101 iperm = 1, 3
starts do
loop. 101
statement label, it's used later. loop comprises statements line line enddo
. loop executed 3 times (once each of integers in sequence starting @ 1
, ending @ 3
). loop control variable iperm
assigned these values in turn. loop little unusual in loop variable not used inside loop. statement
omega = omega + s * a1 (i) * a2 (j) * a3 (k)
updates value of omega
. term a1(i)
(the space in original immaterial) means the i-th element of array a1
. et cetera
when line
if (s.lt.0.d0) goto 101
is executed if s
less 0
control goes bak line labelled 101
.
finally, term alat**3
calculates cube of alat
.
so piece of paper , figure out value omega
gets.
Comments
Post a Comment