Output DIP_P and read it with error for the large number of band

Run-time issues concerning Yambo that are not covered in the above forums.

Moderators: myrta gruning, andrea marini, Daniele Varsano, Conor Hogan

Post Reply
lyzhao
Posts: 40
Joined: Tue May 31, 2016 8:02 am

Output DIP_P and read it with error for the large number of band

Post by lyzhao » Mon Aug 29, 2022 6:04 am

Dear all,
Using the yambo-4.5.3, I output the DIP_P by adding the following code at the end of the file DIPOLE_driver.F.

Code: Select all

        enddo
        !
      enddo
    
    if (myid==0) then !lyzhao
      !~ write dip
      open(300,file='YBDIPP.BIN',form='UNFORMATTED',action='WRITE')
      write(300) Dip%ib(1),Dip%ib_lim(1),Dip%ib_lim(2),Dip%ib(2)
      write(300) DIP_P
      close(300)
    endif
    
    !
   end subroutine DIPOLES_ppredux_and_symmetrize
   !
end subroutine
then in my own code, I write

Code: Select all

 .......
 complex(4), allocatable :: pmat(:,:,:,:,:)  ! use single precision, as the same as yambo
 integer  ib1,ib2,ib3,ib4
 .........
  if(allocated(pmat))   deallocate(pmat);   allocate(pmat(3,nbands,nbands,nkptr,1)); pmat=0.0
  open(50,file='YBDIPP.BIN',action='READ',form='UNFORMATTED',status='OLD',iostat=ios) 
  read(50) ib1,ib2,ib3,ib4
  read(50) pmat ! (:,ib,ib,ik,i_spin)
My code can read correctly the file YBDIPP.BIN for the small number of bands (e.g. nbands=10) to carry out other calculations,
but for the large number of bands (e.g. nbands=200), I got the following error :
At line 70 of file getpmat.f90 (unit = 50, file = 'YBDIPP.BIN')
Fortran runtime error: I/O past end of record on unformatted file

Note that "read(50) ib1,ib2,ib3,ib4" can run correctly for both nbands, error occurs at "read(50) pmat ! (:,ib,ib,ik,i_spin)".

Any help will be appreciated.
Youzhao Lan
College of Chemistry and Materials Science,
Zhejiang Normal University,
Jinhua, Zhejiang, China.
HomePage: http://blog.sciencenet.cn/u/lyzhao

lyzhao
Posts: 40
Joined: Tue May 31, 2016 8:02 am

Re: Output DIP_P and read it with error for the large number of band

Post by lyzhao » Mon Aug 29, 2022 8:08 am

more infos:
when nbands=10, I mean pmat(3,10,10,3,1)
when nbands=200, I mean pmat(3,200,200,91,1), which is not too large
System: CentOS x86_64. Linux
Youzhao Lan
College of Chemistry and Materials Science,
Zhejiang Normal University,
Jinhua, Zhejiang, China.
HomePage: http://blog.sciencenet.cn/u/lyzhao

User avatar
Daniele Varsano
Posts: 3773
Joined: Tue Mar 17, 2009 2:23 pm
Contact:

Re: Output DIP_P and read it with error for the large number of band

Post by Daniele Varsano » Mon Aug 29, 2022 8:46 am

Dear Youzhao,

my advise here is to update to a more recent version of the code (e.g. 5.1) and use the yambopy utility to extract the matrix elements you need.
This is explained here:

viewtopic.php?t=1889

Best,
Daniele
Dr. Daniele Varsano
S3-CNR Institute of Nanoscience and MaX Center, Italy
MaX - Materials design at the Exascale
http://www.nano.cnr.it
http://www.max-centre.eu/

lyzhao
Posts: 40
Joined: Tue May 31, 2016 8:02 am

Re: Output DIP_P and read it with error for the large number of band

Post by lyzhao » Tue Aug 30, 2022 4:25 am

Dear Prof. Daniele,
Great thanks for your quick help.
I know very little about python, so I still prefer to output the dips directly from the yambo program.
I have already known the cause of the problem above,
that is, in mpi parallel calculation, my code only outputs part of the dip when using the following code:

Code: Select all

if (myid==0) write(102) ... 

the dips calculated by other cpuids have not been output.
So, to output all the dips, could you tell me where I should add code in file DIPOLE_driver.F or other files?

Best regards.
Youzhao Lan
College of Chemistry and Materials Science,
Zhejiang Normal University,
Jinhua, Zhejiang, China.
HomePage: http://blog.sciencenet.cn/u/lyzhao

User avatar
Daniele Varsano
Posts: 3773
Joined: Tue Mar 17, 2009 2:23 pm
Contact:

Re: Output DIP_P and read it with error for the large number of band

Post by Daniele Varsano » Tue Aug 30, 2022 8:06 am

Dear Youzhao,

in general, there is no need to know much python to use yamopy, anyway you can modify your code by replacing the if condition with:

Code: Select all

write(102+myid) ..
,

in this way, each CPU will write its content in a different file, and then you can gather them with an external code.

Best,
Daniele
Dr. Daniele Varsano
S3-CNR Institute of Nanoscience and MaX Center, Italy
MaX - Materials design at the Exascale
http://www.nano.cnr.it
http://www.max-centre.eu/

lyzhao
Posts: 40
Joined: Tue May 31, 2016 8:02 am

Re: Output DIP_P and read it with error for the large number of band

Post by lyzhao » Tue Aug 30, 2022 8:46 am

Dear Dr. Daniele,
Great thanks for your quick help.

Best regards
Youzhao Lan
Youzhao Lan
College of Chemistry and Materials Science,
Zhejiang Normal University,
Jinhua, Zhejiang, China.
HomePage: http://blog.sciencenet.cn/u/lyzhao

Post Reply