The Elk Code
writebfcr.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2025 Wenhan Chen, J. K. Dewhurst and S. Sharma.
3 ! This file is distributed under the terms of the GNU General Public License.
4 ! See the file COPYING for license details.
5 
6 subroutine writebfcr
7 use modmain
8 use modulr
9 implicit none
10 ! local variables
11 integer idm,i1,i2,i3,ir
12 real(8) v(3)
13 ! automatic arrays
14 real(8) bfcr(nqpt,ndmag)
15 complex(8) zfft(nfqrz)
16 ! Fourier transform external magnetic field from Q-space to real-space
17 do idm=1,ndmag
18  zfft(1:nfqrz)=bfcq(idm,1:nfqrz)
19  call rzfftifc(3,ngridq,1,bfcr(:,idm),zfft)
20 end do
21 ! write the real-space magnetic field in Cartesian coordinates to file
22 open(50,file='BFCR.OUT',form='FORMATTED')
23 write(50,'(3I6," : grid size")') ngridq
24 ir=0
25 do i3=1,ngridq(3)
26  do i2=1,ngridq(2)
27  do i1=1,ngridq(1)
28  ir=ir+1
29  if (ncmag) then
30  v(1:3)=bfcr(ir,1:3)
31  else
32  v(1:2)=0.d0
33  v(3)=bfcr(ir,1)
34  end if
35  write(50,'(3I6,3G18.10)') i1,i2,i3,v
36  end do
37  end do
38 end do
39 close(50)
40 end subroutine
41 
subroutine writebfcr
Definition: writebfcr.f90:7
integer, dimension(3) ngridq
Definition: modmain.f90:515
complex(8), dimension(:,:), allocatable bfcq
Definition: modulr.f90:71
subroutine rzfftifc(nd, n, sgn, r, z)
Definition: modulr.f90:6
logical ncmag
Definition: modmain.f90:240