1c
2c     reads BXSF file (BEGIN_BLOCK_BANDGRID3D section) and write
3c     ordinary XSF file with lattice vectors and BZ
4c
5      program fsReadBXSF
6      implicit none
7c
8c     Usage: fsreadBXSF input output
9c
10      character line*80, input*256, output*256
11      logical   finished
12      REAL*8    invvec(3,3), dir(3,3), vec(3,3), o1, o2, o3
13      integer   string_length, i, j, k, iband
14
15      finished=.false.
16
17      if (iargc().ne.2) then
18         write(*,*) 'Usage:  fsreadBXSF  input output'
19         stop
20      endif
21      call getarg(1,input)
22      call getarg(2,output)
23      open(unit=11, file=input,  status='old')
24      open(unit=12, file=output, status='unknown')
25
26      do while (.not.finished)
27         read(11,'(a20)') line
28         i = string_length(line)
29         if ( line(1:11) .eq. 'BANDGRID_3D'
30     $        .or. line(1:17) .eq. 'BEGIN_BANDGRID_3D' ) then
31            read(11,*) iband
32            read(11,*) i, j, k
33            read(11,*) o1, o2, o3
34            read(11,*) ((invvec(i,j),j=1,3),i=1,3)
35            finished=.true.
36         endif
37      enddo
38
39      call ZeroMat       (dir, 3, 3)
40      call InvertSqMat123 (invvec, dir, 3)
41      call MatTranspose  (dir, vec, 3, 3)
42
43      write(12,*) 'DIM-GROUP'
44      write(12,*) '3 1'
45      call WVec ('PRIMVEC', vec)
46      call WVec ('RECIP-PRIMVEC', invvec)
47      call WignerSeitz(invvec,  'BRILLOUIN-ZONE-PRIMCELL')
48
49      write(12,*) 'PRIMCOORD'
50      write(12,*) '1 1'
51      write(12,*) '1   0.0  0.0  0.0'
52
53      END
54