The following code
file=ARGS[1]
lines=readlines(file)
lenFile=length(lines)
l3=lines[3]
l4=lines[4]
l5=lines[5]
l6=lines[6]
sl3=split(l3)
NA=parse(Int64,sl3[1])
sl4=split(l4)
nx=parse(Int64,sl4[1])
sl5=split(l5)
ny=parse(Int64,sl5[1])
sl6=split(l6)
nz=parse(Int64,sl6[1])
npt=nxnynz
println(nx,ny,nz)
println(NA," ",npt)
istart=6+NA+1
vec=zeros(Float64,npt)
q=1
for i in istart:lenFile
println(q)
tmp=split(lines[i])
ll=length(tmp)
for j in 1:ll
vec[q+j-1]=parse(Float64,tmp[j])
end
q=q+ll
end
with the following file as argument
Cube file generated by NWChem
DENSITY
5 -6.000000 -6.000000 -6.000000
201 0.060000 0.000000 0.000000
201 0.000000 0.060000 0.000000
201 0.000000 0.000000 0.060000
6 6.000000 0.000000 0.000000 0.000000
1 1.000000 -1.185992 -1.185992 -1.185992
1 1.000000 1.185992 1.185992 -1.185992
1 1.000000 -1.185992 1.185992 1.185992
1 1.000000 1.185992 -1.185992 1.185992
0.38635E-08 0.42174E-08 0.45990E-08 0.50101E-08 0.54523E-08 0.59275E-08
0.64376E-08 0.69844E-08 0.75700E-08 0.81963E-08 0.88654E-08 0.95794E-08
0.10340E-07 0.11150E-07 0.12012E-07 0.12926E-07 0.13896E-07 0.14924E-07
0.16011E-07 0.17160E-07 0.18373E-07 0.19652E-07 0.20998E-07 0.22413E-07
0.23900E-07 0.25459E-07 0.27092E-07 0.28801E-07 0.30586E-07 0.32449E-07
0.34389E-07 0.36409E-07 0.38508E-07 0.40686E-07 0.42943E-07 0.45279E-07
0.47692E-07 0.50183E-07 0.52750E-07 0.55391E-07 0.58104E-07 0.60887E-07
0.63737E-07 0.66652E-07 0.69628E-07 0.72662E-07 0.75748E-07 0.78884E-07
0.82064E-07 0.85284E-07 0.88537E-07 0.91818E-07 0.95122E-07 0.98441E-07
produces the output
ERROR: LoadError: UndefVarError: q not defined
Stacktrace:
[1] top-level scope at /home/braunm/cubeReader/readCube.jl:23
[2] include at ./boot.jl:328 [inlined]
[3] include_relative(::Module, ::String) at ./loading.jl:1105
[4] include(::Module, ::String) at ./Base.jl:31
[5] exec_options(::Base.JLOptions) at ./client.jl:287
[6] _start() at ./client.jl:460
in expression starting at /home/braunm/cubeReader/readCube.jl:22
201201201
5 8120601
It is very strange, since q has been defined by q=1
It would have been much easier to report this
If I knew how to attach files!
Regards
Moritz
Regards
Moritz