TABLE OF CONTENTS


ABINIT/randac [ Functions ]

[ Top ] [ Functions ]

NAME

 randac

FUNCTION

 Random access to a wavefunction file : select the proper record in the wavefunction file.

COPYRIGHT

 Copyright (C) 1998-2018 ABINIT group (DCA, XG, GMR)
 This file is distributed under the terms of the
 GNU General Public License, see ~abinit/COPYING
 or http://www.gnu.org/copyleft/gpl.txt .

 This routine originally written by Zachary Levine

INPUTS

  debug=if > 0, prints debugging output
   without change the reading would begin at the wavefunction block ikptsp_prev+1 .
  headform1=format of the header of the wf file, also needed for reading the block
  ikpt=the k point at which data is desired
  isppol=spin channel
  nband(nkpt*nsppol)=number of bands at each k point and spin polarization
  nkpt=number of k points
  nsppol=number of spin channels
  wffinp=structured info for reading the wavefunction

OUTPUT

SIDE EFFECTS

  ikptsp_prev=at input:
     number of the previously read k point - spin polarisation; 0 if new file;
     without change the reading would begin at the wavefunction block ikptsp_prev+1 .
    at output: value of ikptsp computed from input ikpt and isppol.

NOTES

PARENTS

      newkpt

CHILDREN

      wffreadskiprec,wrtout

SOURCE

 46 #if defined HAVE_CONFIG_H
 47 #include "config.h"
 48 #endif
 49 
 50 #include "abi_common.h"
 51 
 52 
 53 subroutine randac(debug,headform1,ikptsp_prev,ikpt,isppol,nband,nkpt,nsppol,wffinp)
 54 
 55  use defs_basis
 56  use m_wffile
 57  use m_profiling_abi
 58 
 59 !This section has been created automatically by the script Abilint (TD).
 60 !Do not modify the following lines by hand.
 61 #undef ABI_FUNC
 62 #define ABI_FUNC 'randac'
 63  use interfaces_14_hidewrite
 64 !End of the abilint section
 65 
 66  implicit none
 67 
 68 !Arguments ------------------------------------
 69 !scalars
 70  integer,intent(in) :: debug,headform1,ikpt,isppol,nkpt,nsppol
 71  integer,intent(inout) :: ikptsp_prev
 72  type(wffile_type),intent(inout) :: wffinp
 73 !arrays
 74  integer,intent(in) :: nband(nkpt*nsppol)
 75 
 76 !Local variables-------------------------------
 77 !scalars
 78  integer :: ierr,ii,ikptsp,nline,nrec
 79  character(len=500) :: message
 80 
 81 ! *************************************************************************
 82 
 83  if (debug>0) then
 84    write(message, '(a,2i8)' )' randac : ikptsp_prev, ikpt=',ikptsp_prev,ikpt
 85    call wrtout(std_out,message,'PERS')
 86  end if
 87 
 88  if(headform1>=40 .or. headform1==0)then
 89    nline=3 ! npw,npspso,nband record, kg record and eigenvalue record
 90  else
 91    nline=2 ! npw,npspso,nband record and eigenvalue record
 92  end if
 93 
 94 !Arrange to skip forward in the data file or else
 95 !backspace as needed to reach the desired records
 96  ikptsp=ikpt+nkpt*(isppol-1)
 97  if (ikptsp_prev+1>ikptsp) then
 98 !  Need to backspace nrec records
 99    nrec=0
100    do ii=ikptsp,ikptsp_prev
101      nrec=nrec-nband(ii)-nline
102    end do
103    if (debug>0) then
104      write(message, '(a,i8)' )' randac skip back nrec=',-nrec
105      call wrtout(std_out,message,'PERS')
106    end if
107  else if (ikptsp_prev+1<ikptsp) then
108 !  Need to skip forward nrec records
109    nrec=0
110    do ii=ikptsp_prev+1,ikptsp-1
111 !    Need additional 3 again for npw,npspso,nband, kg and eigenvalue records
112      nrec=nrec+nband(ii)+nline
113    end do
114    if (debug>0) then
115      write(message, '(a,i8)' )' randac skip forwards nrec=',nrec
116      call wrtout(std_out,message,'PERS')
117    end if
118  else
119 !  Already pointed at desired record; no skipping
120    nrec=0
121  end if
122 
123 !DEBUG
124 !write(std_out,*)' randac : nrec,wfinp=',nrec,wffinp%unwff
125 !ENDDEBUG
126 
127 !Do the skipping (backward, forward, or not)
128  call WffReadSkipRec(ierr,nrec,wffinp)
129 
130  ikptsp_prev=ikptsp
131  if (debug>0) then
132    write(message, '(a,i5)' )' randac: updated ikptsp_prev=',ikptsp_prev
133    call wrtout(std_out,message,'PERS')
134  end if
135 
136 end subroutine randac