37 character(*),
intent(in) :: filename
38 real(8),
intent(out) :: gdata(g_rh%nft(1),g_rh%nft(2),g_rh%nft(3))
40 integer :: itemp(3), fi = 10, iat
41 character(256) :: ctemp
42 real(8) :: avec0(3,3), &
43 & gdata0(g_rh%nft(1)+1,g_rh%nft(2)+1,g_rh%nft(3)+1)
45 open(fi, file = trim(filename))
49 read(fi,*) avec0(1:3,1:3)
50 avec0(1:3,1:3) = avec0(1:3,1:3) / 0.529177249d0
51 if(any(abs(avec0(1:3,1:3)-
avec(1:3,1:3)) > 1.0d-3))
then
52 write(*,*)
"Error in read_griddata"
53 write(*,*)
"Direct lattice vector is different."
54 stop
'error in read_griddata'
58 if(
nat /= itemp(1))
then
59 write(*,*)
"Error in read_griddata"
60 write(*,*)
"Number of atoms is different."
61 stop
'error in read_griddata'
64 read(fi,*) ctemp, avec0(1:3,1)
65 avec0(1:3,1) = avec0(1:3,1) / 0.529177249d0
66 avec0(1:3,1) = matmul(avec0(1:3,1),
bvec(1:3,1:3)) / (2.0d0*
pi)
67 if(any(abs(avec0(1:3,1)-
atm(iat)%pos(1:3)) > 1.0d-3))
then
68 write(*,*)
"Error in read_griddata"
69 write(*,*)
"Position of atom ", iat,
" is different."
70 stop
'error in read_griddata'
77 if(any(itemp(1:3) /= g_rh%nft(1:3)+1))
then
78 write(*,*)
"Error in read_griddata"
79 write(*,*)
"FFT grid is different."
80 stop
'error in read_griddata'
82 read(fi,*) avec0(1:3,1)
83 read(fi,*) avec0(1:3,1:3)
84 read(fi,*) gdata0(1:itemp(1),1:itemp(2),1:itemp(3))
88 gdata( 1:g_rh%nft(1),1:g_rh%nft(2),1:g_rh%nft(3)) &
89 & = gdata0(1:g_rh%nft(1),1:g_rh%nft(2),1:g_rh%nft(3))
101 character(*),
intent(in) :: filename
102 real(8),
intent(in) :: gdata(g_rh%nft(1),g_rh%nft(2),g_rh%nft(3))
104 integer :: fo = 20, iat, i1, i2, i3, ii1, ii2, ii3
105 real(8) :: gdata0(g_rh%nft(1)+1,g_rh%nft(2)+1,g_rh%nft(3)+1)
107 do i3 = 1, g_rh%nft(3)+1
108 ii3 = modulo(i3 - 1, g_rh%nft(3)) + 1
109 do i2 = 1, g_rh%nft(2)+1
110 ii2 = modulo(i2 - 1, g_rh%nft(2)) + 1
111 do i1 = 1, g_rh%nft(1)+1
112 ii1 = modulo(i1 - 1, g_rh%nft(1)) + 1
113 gdata0(i1, i2, i3) = gdata(ii1, ii2, ii3)
118 write(*,*)
" Output ", trim(filename)
119 open(fo, file = trim(filename))
121 write(fo,
'(a)')
"CRYSTAL"
122 write(fo,
'(a)')
"PRIMVEC"
124 write(fo,
'(a)')
"PRIMCOORD"
125 write(fo,
'(2(2x,i0))')
nat, 1
127 write(fo,
'(a,2x,3e20.10)') trim(
atm(iat)%elem), &
130 write(fo,
'(a)')
"BEGIN_BLOCK_DATAGRID_3D"
131 write(fo,
'(a)')
"3D_PWSCF"
132 write(fo,
'(a)')
"DATAGRID_3D_UNKNOWN"
133 write(fo,
'(3(2x,i0))') g_rh%nft(1:3)+1
134 write(fo,
'(3e20.10)') (/0.0d0, 0.0d0, 0.0d0/),
avec(1:3,1:3) *
bohr2ang
135 write(fo,
'(6e20.10)') gdata0(1:g_rh%nft(1)+1,1:g_rh%nft(2)+1,1:g_rh%nft(3)+1)
136 write(fo,
'(a)')
"END_DATAGRID_3D"
137 write(fo,
'(a)')
"END_BLOCK_DATAGRID_3D"