Error in anisotropic calculation

Hello,

I am trying to run an anisotropic Eliashberg calculation on a hydrogen phase. Although I’m able to run an isotropic calculation without an issue (epw3.in and epw3.out), the anisotropic calculation fails with the BAD TERMINATION error (epw4.in and epw4.out). The full error message is unfortunately not very descriptive either:

munmap_chunk(): invalid pointer
srun: error: r220: task 8: Broken pipe
srun: error: r263: task 11: Broken pipe
[mpiexec@r133.ib.bridges2.psc.edu] wait_proxies_to_terminate (../../../../../src/pm/i_hydra/mpiexec/intel/i_mpiexec.c:527): downstream from host r133 exited with status 141

I successfully ran anisotropic calculations in other crystal phases of this material with analogous input files, and changing the number of nodes hasn’t made a difference, so this is a total mystery to me.

All the files are available here: [https://www.dropbox.com/sh/a12q7198eiq7qxk/AAD6RGkEq6JL7tBdeZ0Yb06Ha?dl=0]

I appreciate any advice in advance.

Best,
Mehmet Dogan

Hi Mehmet,

This looks like a memory issue to me. Did you notice;

“Size of allocated memory per pool: ~= 1.8548 Gb”

This is even before reading *.ephmat files. I recommend using larger memory nodes if available or try running in more cores.

HappyEPWing,
Hari Paudyal

Dear Mehmet Dogan:

Could you show me make.inc you are using when building the code?

Sincerely,

H. Lee

Dear Hari and H. Lee,

I’m not sure I understand the memory allocation. I’m using 32 nodes with 128 GB memory each. Given that I specify 128 pools, that should mean that each pool has 32 GB of memory available. So, shouldn’t that be plenty?

I’ve also added the make.inc file to the Dropbox folder.

Thank you both very much!

Best,
Mehmet

Dear Mehmet Dogan:

I would suggest you the followings:
(1) Use of gcc environments instead of intel.
(2) Include “–enable-debug” in the options of configure like “./configure --enable-debug …”
(3) Run calculations again.

Sincerely,

H. Lee

Dear H. Lee,

Thank you for your suggestion! I recompiled and reran as you suggested, and the resulting error message was:

At line 522 of file supercond.f90
Fortran runtime error: Index '-332' of dimension 1 of array 'lambda_pairs' below lower bound of 1

Error termination. Backtrace:
#0  0x4f4035 in __supercond_MOD_evaluate_a2f_lambda
        at /jet/home/mdogan/qe-6.7-v2/EPW/src/supercond.f90:522
#1  0x425178 in eliashberg_eqs_
        at /jet/home/mdogan/qe-6.7-v2/EPW/src/eliashberg.f90:61
#2  0x406fdf in epw
        at /jet/home/mdogan/qe-6.7-v2/EPW/src/epw.f90:163
#3  0x406afc in main
        at /jet/home/mdogan/qe-6.7-v2/EPW/src/epw.f90:20
srun: error: r171: task 2: Broken pipe
[mpiexec@r120.ib.bridges2.psc.edu] wait_proxies_to_terminate (../../../../../src/pm/i_hydra/mpiexec/intel/i_mpiexec.c:527): downstream from host r120 exited with status 141

I also put the new output file and the error log in the shared folder. I guess the error is connected with not finding but I’m not sure how. Please let me know what you think.

Best,
Mehmet

  • I meant “I guess the error is connected with not finding lambda pairs but I’m not sure how.”

Dear Mehmet:

At line 522 of file supercond.f90
Fortran runtime error: Index ‘-332’ of dimension 1 of array ‘lambda_pairs’ below lower bound of 1

The error message above tells us that there is a out-of-bound error; the first dimension of the array ‘lambda_pairs’ is smaller than one; this should not happen.

Sincerely,

H. Lee

Dear H. Lee,

Thank you! Do you have any idea what may be causing this anomalous situation? As far as I can see, lambda_pairs is allocated in line 497 of supercond.f90 but I don’t see where its entries get populated.

Best,
Mehmet

Dear Mehmet:

Please look at this line (https://gitlab.com/QEF/q-e/-/blob/develop/EPW/src/supercond.f90#L520).
In your case, ibin has a negative value of -332.

Usually, dosef, wf, and g2 have non-negative values and the issue above doesn’t happen (I assume that you don’t set shortrange to .true. and eps_acustic>0).
You can find its origin by looking at the lines of supercond.f90 around the line of 520 and following relevant values which affect the ibin.

Sincerely,

H. Lee

Dear H. Lee,

Thank you for pointing these out. You may check my input file (epw4.in) in the Dropbox folder, I assume I’m only using standard inputs. From the source code, here’s what I have so far:

The line that sets ibin to -332 should be line 520, which is:

ibin = NINT(lambda_eph / dbin) + 1

This means lambda_eph / dbin = -333 (approximately). So, either lambda_eph or dbin is negative. lambda_eph seems to be set in lines 511-517:

lambda_eph = zero
DO imode = 1, nmodes
IF (wf(imode, iq0) > eps_acustic) THEN
    lambda_eph = lambda_eph + g2(ik, iq, ibnd, jbnd, imode) / wf(imode,iq0)
  ENDIF
ENDDO
lambda_eph = 2.d0 * lambda_eph * dosef

As you said, if dose, wf and g2 are nonnegative, lambda_eph should be as well.

dbin should be defined in lines 493-494:

nbin = NINT(1.1d0 * MAXVAL(lambda_max(:)) / eps2) + 1
dbin = 1.1d0 * MAXVAL(lambda_max(:)) / DBLE(nbin)

Combining these two expressions, I get dbin to be approximately equal to (lambda_max*eps2)/(lambda_max+eps2). From constants_epw.f90 it looks like eps2 = 1.0E-2. If my math is correct, for dbin to be negative, we’d have to have (approximately) -1.0E-2 < lambda_max < 0. Of course, since lambdas should be nonnegative, this also doesn’t make sense.

It seems to me there’s no obvious variable where the problem may creep in. Do you agree with that? In order to pin down where the negative numbers come from, I should print some of these variables during the run. But I’m not experienced with Fortran code editing. Could you give me an example of such a line to print a variable to the output file? For instance, if I wanted to print ibin after line 520, what line would I need to add? Thank you very much for all your help!

Best,
Mehmet

Dear Mehmet:

You need to find the origin in the following ways:

First, you need to print out the values of relevant variables on each MPI task.
To do this, please proceed as follows:
(1) Change the line of “MANUAL_DFLAGS =” in make.inc in the QE root directory with that of “MANUAL_DFLAGS = -DDEBUG”.
(2) Issue “make clean”.
(3) Build again the code; make … (you should not issue “./configure …” again).

Second, check the values of nbin and dbin.
(There might be some typos in the following modifications.)

(before)

    IF (iverbosity == 2) THEN
      nbin = NINT(1.1d0 * MAXVAL(lambda_max(:)) / eps2) + 1
      dbin = 1.1d0 * MAXVAL(lambda_max(:)) / DBLE(nbin)
      ALLOCATE(lambda_pairs(nbin), STAT = ierr)
      IF (ierr /= 0) CALL errore('evaluate_a2f_lambda', 'Error allocating lambda_pairs', 1)
      lambda_pairs(:) = zero
    ENDIF

(after)

    IF (iverbosity == 2) THEN
      nbin = NINT(1.1d0 * MAXVAL(lambda_max(:)) / eps2) + 1
      dbin = 1.1d0 * MAXVAL(lambda_max(:)) / DBLE(nbin)
      ALLOCATE(lambda_pairs(nbin), STAT = ierr)
      IF (ierr /= 0) CALL errore('evaluate_a2f_lambda', 'Error allocating lambda_pairs', 1)
      lambda_pairs(:) = zero
      IF (nbin < 0) WRITE(stdout, '(a)') 'WARNING: nbin is negative!'
      IF (dbin < 0.d0) WRITE(stdout, '(a)') 'WARNING: dbin is negative!'
    ENDIF

Third, do the same thing for g2, wf, and dosef:

(before)

                IF (iverbosity == 2) THEN
                  ibin = NINT(lambda_eph / dbin) + 1
                  weight2 =  w0g(ibnd, ik) * w0g(jbnd,ixkqf(ik, iq0))
                  lambda_pairs(ibin) = lambda_pairs(ibin) + weight2
                ENDIF

(after)

                 IF (iverbosity == 2) THEN
                  ibin = NINT(lambda_eph / dbin) + 1
                  IF (ibin < 0) THEN
		     WRITE(stdout, '(a)') 'WARNING: ibin is negative!'
	             WRITE(stdout, *) 'dosef=', dosef
	             WRITE(stdout, *) 'g2=', g2(ik, iq, ibnd, jbnd, 1:nmodes)
	             WRITE(stdout, *) 'wf=', wf(1:nmodes,iq0)
                  ENDIF
                  weight2 =  w0g(ibnd, ik) * w0g(jbnd,ixkqf(ik, iq0))
                  lambda_pairs(ibin) = lambda_pairs(ibin) + weight2
                ENDIF

Lastly, you need to check the main output of epw.out as well as out.* files.

Sincerely,

H. Lee

Dear H. Lee,

Thank you very much for your detailed guidance in debugging. Here is what happened. (Refer to the Dropbox folder [https://www.dropbox.com/sh/a12q7198eiq7qxk/AAD6RGkEq6JL7tBdeZ0Yb06Ha?dl=0] for the files.)

The output file looks the same (epw4.out3) but 127 out.0_* files were also created. Only one of them printed a warning message (out.0_32). The other 126 were identical to out.0_1.

As you can see in out.0_32, there are 3 negative elements of g2. Does everything else make sense? If so, the problem seems to be these negative elements of g2. Where do you think they might originate, and how can I pin that down? I greatly appreciate your help.

Best,
Mehmet

Dear Mehmet:

I think that something wrong happens in your case.

We need to get more information and we need the following modifications in the SUBROUTINE write_ephmat in io_eliashberg.f90.
(There might be some typos below.)

(before)
IF (ixkf(lower_bnd + ik - 1) > 0) THEN
IF (ixkqf(ixkf(lower_bnd + ik - 1), iq) > 0) THEN
DO imode = 1, nmodes ! phonon modes
wq = wf(imode, iq)
inv_wq = 1.0 / (two * wq)
!
DO ibnd = 1, nbndfst
IF (ABS(ekfs(ibnd, ixkf(lower_bnd + ik - 1)) - ef0) < fsthick) THEN
DO jbnd = 1, nbndfst
IF (ABS(ekfs(jbnd, ixkqf(ixkf(lower_bnd + ik - 1), iq)) - ef0) < fsthick) THEN
!
! here we take into account the zero-point DSQRT(hbar/2M\omega)
! with hbar = 1 and M already contained in the eigenmodes
! g2 is Ry^2, wkf must already account for the spin factor
!
IF (shortrange .AND. (ABS(xqf(1, iq)) > eps8 .OR. ABS(xqf(2, iq)) > eps8 &
.OR. ABS(xqf(3, iq)) > eps8 )) THEN
! SP: The abs has to be removed. Indeed the epf17 can be a pure imaginary
! number, in which case its square will be a negative number.
g2 = REAL((epf17(jbnd, ibnd, imode, ik)**two) * inv_wq)
ELSE
g2 = ABS(epf17(jbnd, ibnd, imode, ik))**two * inv_wq
ENDIF
ind(my_pool_id + 1) = ind(my_pool_id + 1) + 1
tmp_g2(ind(my_pool_id + 1)) = g2
ENDIF
ENDDO ! jbnd
ENDIF
ENDDO ! ibnd
ENDDO ! imode
ENDIF ! ixkqf
ENDIF ! ixkf

(after)
IF (ixkf(lower_bnd + ik - 1) > 0) THEN
IF (ixkqf(ixkf(lower_bnd + ik - 1), iq) > 0) THEN
DO imode = 1, nmodes ! phonon modes
wq = wf(imode, iq)
inv_wq = 1.0 / (two * wq)
!
DO ibnd = 1, nbndfst
IF (ABS(ekfs(ibnd, ixkf(lower_bnd + ik - 1)) - ef0) < fsthick) THEN
DO jbnd = 1, nbndfst
IF (ABS(ekfs(jbnd, ixkqf(ixkf(lower_bnd + ik - 1), iq)) - ef0) < fsthick) THEN
!
! here we take into account the zero-point DSQRT(hbar/2M\omega)
! with hbar = 1 and M already contained in the eigenmodes
! g2 is Ry^2, wkf must already account for the spin factor
!
IF (shortrange .AND. (ABS(xqf(1, iq)) > eps8 .OR. ABS(xqf(2, iq)) > eps8 &
.OR. ABS(xqf(3, iq)) > eps8 )) THEN
! SP: The abs has to be removed. Indeed the epf17 can be a pure imaginary
! number, in which case its square will be a negative number.
g2 = REAL((epf17(jbnd, ibnd, imode, ik)**two) * inv_wq)
ELSE
g2 = ABS(epf17(jbnd, ibnd, imode, ik))**two * inv_wq
ENDIF
!!!
IF (g2 < 0.d0) THEN
WRITE(stdout, *) ‘warning: g2 is negative. g2=’, g2
WRITE(stdout, *) ‘inv_wq=’, inv_wq
WRITE(stdout, *) ‘iq=’, iq
WRITE(stdout, *) ‘ik=’, ik
WRITE(stdout, *) ‘imode=’, imode
WRITE(stdout, *) ‘ibnd=’, ibnd
WRITE(stdout, *) ‘jbnd=’, jbnd
IF (shortrange) WRITE(stdout, *) ‘shortrange is .true.’
ENDIF
!!!
ind(my_pool_id + 1) = ind(my_pool_id + 1) + 1
tmp_g2(ind(my_pool_id + 1)) = g2
ENDIF
ENDDO ! jbnd
ENDIF
ENDDO ! ibnd
ENDDO ! imode
ENDIF ! ixkqf
ENDIF ! ixkf

You just need to focus on the region sandwiched by “!!!” and you need to rerun the evaluation of e-ph vertex on fine grids.

Sincerely,

H. Lee