epsmat_merge problem

Submitted by jugeb on Tue, 05/30/2017 - 06:34


User questions

Hi everyone,

after successful DFT runs I ran epsilon.cplx.x. Since the calculation aborted after a few k-points, I split it into several runs. I am using the module at cori:
BerkeleyGW branch 1.2.x revision 7090
Epsilon code, Complex version, run on 26-May-2017 at 15:39:28 -0700

Running epsmat_merge.cplx.x gives the following error:
1 This routine should only be used on non-HDF5-based epsmat files.
2 If you built with HDF5 support (which is ideal), or otherwise
3 have HDF5-based epsmat files, you should use the routine
4 epsmat_hdf5_merge.py instead.

Since epsmat_hdf5_merge.py does not seem to come with the cori installation, I used the one from that can be downloaded (BGW-1.2.0.tar.gz). This gives the following output:
user@cori06:...> ./epsmat_hdf5_merge.py 1/epsmat.h5 2/epsmat.h5 3/epsmat.h5 4/epsmat.h5 5/epsmat.h5
Output file:
> epsmat_merged.h5

Input files:
< 1/epsmat.h5
< 2/epsmat.h5
< 3/epsmat.h5
< 4/epsmat.h5
< 5/epsmat.h5

Analyzing files and checking consistency against 1/epsmat.h5

Checking 2/epsmat.h5
Checking 3/epsmat.h5
Checking 4/epsmat.h5
Checking 5/epsmat.h5
All files are consistent!


Flavor: Complex
Frequency dependency: 0
Number of frequencies: 1
Number of G-vectors: 74051
Epsilon cutoff: 10.000000
Maximum rank of the merged epsilon matrix (nmtx): 841
Total number of q-points after merging: 215

Writing output parameters


Writing output matrices

Traceback (most recent call last):
File "./epsmat_hdf5_merge.py", line 146, in
for iq in xrange(nq):
NameError: name 'xrange' is not defined

I assume this is a bug.

I should mention that the used python version (also @ cori), has h5py and numpy installed.

Having a look at the script, the variable xrange in 146 is indeed not defined and occurs for the first time at this point. For me this looks like a simple typo, i.e., the build-in function range was supposed to be used here. Could you confirm that the intended line should just read?
146 for iq in range(nq):

With this change the script seems to run fine for me.

Thanks for having a look!

Submitted by babarker on Wed, 05/31/2017 - 14:14


xrange is a function in Python v2.7.13: https://docs.python.org/2/library/functions.html#xrange

Using "range" instead of "xrange" seems fine in this context. The main difference is that "range" creates a list and stores it in memory, but the size of that additional memory is likely not large at all. "xrange" does not require additional memory and is generally better practice.

I have not run this script in a month or so, but I'm surprised there was an issue.


Submitted by jugeb on Thu, 06/01/2017 - 06:06

Ah that's it. xrange was removed in python3 (which i am usually using and which is the default at cori). Thanks.

If intended as python2 script, one might consider changing
#!/usr/bin/env python
#!/usr/bin/env python2