Menu

Minor bug in Wannier90 input parsing

2024-02-27
2024-03-05
  • Andrew Shyichuk

    Andrew Shyichuk - 2024-02-27

    Dear Developers,

    I've noticed that the xlwin=[xlwin,str] line in readinput.f90 does not work, at least with some compilers.
    The produced array of lines contains gibberish and the line read last that ends up in the first element.
    My compiler is Intel 2022.1.0 and Elk is 9.2.12.

    My fix is a primitive one that works :)
    I created the additional xxlwin in modw90.f90, and in readinput.f90 the respective case reads:

    case('xlwin','wannierExtra')
      if (allocated(xlwin)) deallocate(xlwin)
      if (allocated(xxlwin)) deallocate(xxlwin)
      allocate(xlwin(0))
      nxlwin=0
      do
        read(50,'(A)',err=20) str
        if (trim(str) == '') goto 10
        allocate(xxlwin(nxlwin))
        do i=1,nxlwin
          xxlwin(i) = xlwin(i)
        enddo
        deallocate(xlwin)
        nxlwin=nxlwin+1
        allocate(xlwin(nxlwin))
        xlwin(nxlwin)=str
        do i=1,nxlwin-1
          xlwin(i) = xxlwin(i)
        enddo
        deallocate(xxlwin)
        write(*,'("Info(readinput): read an xlwin line: ",A)') str
        do i=1,nxlwin
          write(*,'("  xlwin(i)    ",I8,A)') i,trim(xlwin(i))
        end do
        write(*,*)
      end do
    
     
  • J. K. Dewhurst

    J. K. Dewhurst - 2024-03-05

    Hi Andrew,

    This was fixed a couple of versions ago. It now reads:

      if (allocated(xlwin)) deallocate(xlwin)
      allocate(xlwin(0))
      nxlwin=0
      do
        read(50,'(A)',err=20) str
        if (trim(str) == '') goto 10
        nxlwin=nxlwin+1
        xlwin=[xlwin,str]
      end do
    

    ... and uses modern Fortran's ability to extend arrays while preserving the contents.

    Regards,
    Kay.

     

Log in to post a comment.