Commit e6687fee authored by Marco Govoni's avatar Marco Govoni
Browse files

Merge branch 'forpy2' into 'develop'

Forpy2

See merge request west-devel/West!21
parents 159328bf 95baadcf
...@@ -11,3 +11,4 @@ ...@@ -11,3 +11,4 @@
*.out *.out
doc/_build/ doc/_build/
Modules/west_version.f90 Modules/west_version.f90
*/__pycache__
...@@ -26,7 +26,7 @@ stages: ...@@ -26,7 +26,7 @@ stages:
- git clone -b 'qe-6.1.0' --single-branch --depth 1 https://gitlab.com/QEF/q-e.git QEDIR - git clone -b 'qe-6.1.0' --single-branch --depth 1 https://gitlab.com/QEF/q-e.git QEDIR
- cd QEDIR - cd QEDIR
- git describe - git describe
- ./configure - ./configure LD_LIBS="`python3-config --ldflags`"
- make -j pw - make -j pw
- ls bin - ls bin
- git clone -b $CI_COMMIT_REF_NAME $CI_REPOSITORY_URL West - git clone -b $CI_COMMIT_REF_NAME $CI_REPOSITORY_URL West
...@@ -41,7 +41,7 @@ stages: ...@@ -41,7 +41,7 @@ stages:
- git clone -b 'qe-6.1.0' --single-branch --depth 1 https://gitlab.com/QEF/q-e.git QEDIR - git clone -b 'qe-6.1.0' --single-branch --depth 1 https://gitlab.com/QEF/q-e.git QEDIR
- cd QEDIR - cd QEDIR
- git describe - git describe
- ./configure - ./configure LD_LIBS="`python3-config --ldflags`"
- make -j pw - make -j pw
- ls bin - ls bin
- git clone -b $CI_COMMIT_REF_NAME $CI_REPOSITORY_URL West - git clone -b $CI_COMMIT_REF_NAME $CI_REPOSITORY_URL West
......
...@@ -29,12 +29,12 @@ The former list of developers, in alphabetical order: ...@@ -29,12 +29,12 @@ The former list of developers, in alphabetical order:
We would like to thank the following people for their contibution (beside generic comments and bugfixes), in alphabetical order: We would like to thank the following people for their contibution (beside generic comments and bugfixes), in alphabetical order:
- Francois Gygi (University of California, Davis): for strategic discussions - Francois Gygi (University of California, Davis)
- Ikutaro Hamada (Osaka University): for the first implementation of k-points - Ikutaro Hamada (Osaka University)
- Yuan Ping (University of California, Santa Cruz): for the first implementation of 2D cutoff - Yuan Ping (University of California, Santa Cruz)
- Jonathan Skone (University of Chicago): hybrid functionals - Jonathan Skone (University of Chicago)
- Tyler Smart (University of California, Santa Cruz): for the first implementation of 2D cutoff - Tyler Smart (University of California, Santa Cruz)
- Aditya Tanikanti (University of Chicago): for improving deployment and testing - Aditya Tanikanti (University of Chicago)
- Feng Wu (University of California, Santa Cruz): for the first implementation of 2D cutoff - Feng Wu (University of California, Santa Cruz)
Please, don't hesitate to contact us if you see that information is wrong or missing in this file. Please, don't hesitate to contact us if you see that information is wrong or missing in this file.
Change Log Change Log
========== ==========
v4.0.0 (2019/09/30)
-------------------
- Added client/server mode
- Added coupling to Qbox code (http://qbox-code.org)
- Added python3 interface
- Simplified the input format (now accepting both JSON and YAML formats)
- Expanded documentation
v3.1.1 (2018/09/19) v3.1.1 (2018/09/19)
------------------- -------------------
......
...@@ -28,3 +28,79 @@ We use [semantic versioning](https://semver.org/), i.e. version labels have the ...@@ -28,3 +28,79 @@ We use [semantic versioning](https://semver.org/), i.e. version labels have the
Comment complex sections of code so that other developers can understand them. Comment complex sections of code so that other developers can understand them.
Add demonstrations of new functionality, e.g. using Jupyter notebooks. Add demonstrations of new functionality, e.g. using Jupyter notebooks.
---
# Developer's workflow
1. Clone the repository to your local machine
```bash
$ git clone <http-git-repo>
```
2. Use the following to see all the available branches and which branch you are on:
```bash
$ git branch -a
```
3. Create a branch for the feature you are going to work on. Internal users should branch from the `develop` branch.
```bash
$ git checkout -b <myfeature>
```
4. Make changes to the repository:
```bash
$ touch <file>
```
5. Check which files have been changed in your local directory by
```bash
$ git status
```
6. Commit your changes and push to the remote repository:
```bash
$ git add <file>
$ git commit -m "explain your modification"
$ git push origin <myfeature>
```
7. (Optional) Check commit history by
```bash
$ git log
```
8. Then create a merge request on the gitlab website that hosts the remote repository:
9. You can do one of the following after the merge request has been approved:
- Delete the branch `myfeature`
- Keep the original branch and keep working on it
## Often-countered scenarios
1. When you want to add another feature, create a new branch for the new feature, e.g. `another_feature`, branching from the latest `develop` branch.
First switch to the `develop` branch:
```bash
$ git checkout develop
```
Then update the local `develop` branch to include changes to the remote:
```bash
$ git pull origin develop
```
Then create your new branch:
```bash
$ git branch -b <another_feature>
```
Then repeat #4-#9 above.
2. Suppose you are working on your feature branch and other people have changed the `develop` branch in the remote repository after you created your `myfeature` branch, you need to merge the `develop` branch into your `myfeature` branch before submitting a merge request.
To merge the `develop` branch into your `myfeature` branch, you need checkout your `myfeature` branch.
```bash
$ git checkout <myfeature>
```
Then do the following to merge the `develop` branch into the branch you are on it
```bash
$ git pull origin develop
```
Then do #6-#9 above.
...@@ -48,7 +48,6 @@ MODULE dfpt_module ...@@ -48,7 +48,6 @@ MODULE dfpt_module
USE io_push, ONLY : io_push_title USE io_push, ONLY : io_push_title
USE mp_world, ONLY : mpime,world_comm USE mp_world, ONLY : mpime,world_comm
USE types_bz_grid, ONLY : k_grid, q_grid, compute_phase USE types_bz_grid, ONLY : k_grid, q_grid, compute_phase
USE types_coulomb, ONLY : pot3D
! !
IMPLICIT NONE IMPLICIT NONE
! !
...@@ -68,7 +67,7 @@ MODULE dfpt_module ...@@ -68,7 +67,7 @@ MODULE dfpt_module
INTEGER :: npwkq INTEGER :: npwkq
! !
REAL(DP) :: g0(3) REAL(DP) :: g0(3)
REAL(DP) :: anorm, prod REAL(DP) :: anorm
REAL(DP), ALLOCATABLE :: eprec(:) REAL(DP), ALLOCATABLE :: eprec(:)
! !
COMPLEX(DP), ALLOCATABLE :: dvpsi(:,:),dpsi(:,:) COMPLEX(DP), ALLOCATABLE :: dvpsi(:,:),dpsi(:,:)
...@@ -171,14 +170,11 @@ MODULE dfpt_module ...@@ -171,14 +170,11 @@ MODULE dfpt_module
! !
DO ipert = 1, m DO ipert = 1, m
! !
ALLOCATE( aux_g(npwqx) ) ALLOCATE( aux_g(npwqx) ); aux_g = 0._DP
ALLOCATE( aux_r(dffts%nnr) ) ALLOCATE( aux_r(dffts%nnr) ); aux_r = 0._DP
!
aux_g=0._DP
aux_r=0._DP
! !
DO ig = 1, npwq ! perturbation acts only on body DO CONCURRENT (ig = 1:npwq)
aux_g(ig) = dvg(ig,ipert) * pot3D%sqvc(ig) aux_g(ig) = dvg(ig,ipert)
ENDDO ENDDO
! !
! ... inverse Fourier transform of the perturbation: (q+)G ---> R ! ... inverse Fourier transform of the perturbation: (q+)G ---> R
...@@ -200,7 +196,7 @@ MODULE dfpt_module ...@@ -200,7 +196,7 @@ MODULE dfpt_module
DO ibnd=1,nbndval-MOD(nbndval,2),2 DO ibnd=1,nbndval-MOD(nbndval,2),2
! !
CALL double_invfft_gamma(dffts,npw,npwx,evc(1,ibnd),evc(1,ibnd+1),psic,'Wave') CALL double_invfft_gamma(dffts,npw,npwx,evc(1,ibnd),evc(1,ibnd+1),psic,'Wave')
DO ir=1,dffts%nnr DO CONCURRENT (ir=1:dffts%nnr)
psic(ir) = psic(ir) * REAL(aux_r(ir),KIND=DP) psic(ir) = psic(ir) * REAL(aux_r(ir),KIND=DP)
ENDDO ENDDO
CALL double_fwfft_gamma(dffts,npw,npwx,psic,dvpsi(1,ibnd),dvpsi(1,ibnd+1),'Wave') CALL double_fwfft_gamma(dffts,npw,npwx,psic,dvpsi(1,ibnd),dvpsi(1,ibnd+1),'Wave')
...@@ -212,7 +208,7 @@ MODULE dfpt_module ...@@ -212,7 +208,7 @@ MODULE dfpt_module
ibnd=nbndval ibnd=nbndval
! !
CALL single_invfft_gamma(dffts,npw,npwx,evc(1,ibnd),psic,'Wave') CALL single_invfft_gamma(dffts,npw,npwx,evc(1,ibnd),psic,'Wave')
DO ir=1,dffts%nnr DO CONCURRENT (ir=1:dffts%nnr)
psic(ir) = CMPLX( REAL(psic(ir),KIND=DP) * REAL(aux_r(ir),KIND=DP), 0._DP, KIND=DP) psic(ir) = CMPLX( REAL(psic(ir),KIND=DP) * REAL(aux_r(ir),KIND=DP), 0._DP, KIND=DP)
ENDDO ENDDO
CALL single_fwfft_gamma(dffts,npw,npwx,psic,dvpsi(1,ibnd),'Wave') CALL single_fwfft_gamma(dffts,npw,npwx,psic,dvpsi(1,ibnd),'Wave')
...@@ -230,7 +226,7 @@ MODULE dfpt_module ...@@ -230,7 +226,7 @@ MODULE dfpt_module
! ... construct right-hand-side term of Sternheimer equation: ! ... construct right-hand-side term of Sternheimer equation:
! ... product of wavefunction at [k-q], phase and perturbation in real space ! ... product of wavefunction at [k-q], phase and perturbation in real space
! !
DO ir = 1, dffts%nnr DO CONCURRENT (ir = 1:dffts%nnr)
psic(ir) = psic(ir) * phase(ir) * aux_r(ir) psic(ir) = psic(ir) * phase(ir) * aux_r(ir)
ENDDO ENDDO
! !
...@@ -248,7 +244,7 @@ MODULE dfpt_module ...@@ -248,7 +244,7 @@ MODULE dfpt_module
! !
CALL single_invfft_k(dffts,npwkq,npwx,evckmq(npwx+1,ibnd),psic,'Wave',igk_k(1,ikqs)) CALL single_invfft_k(dffts,npwkq,npwx,evckmq(npwx+1,ibnd),psic,'Wave',igk_k(1,ikqs))
! !
DO ir = 1, dffts%nnr DO CONCURRENT (ir = 1:dffts%nnr)
psic(ir) = psic(ir) * phase(ir) * aux_r(ir) psic(ir) = psic(ir) * phase(ir) * aux_r(ir)
ENDDO ENDDO
! !
...@@ -292,9 +288,8 @@ MODULE dfpt_module ...@@ -292,9 +288,8 @@ MODULE dfpt_module
DO ibnd=1,nbndval DO ibnd=1,nbndval
! !
CALL double_invfft_gamma(dffts,npw,npwx,evc(1,ibnd),dpsi(1,ibnd),psic,'Wave') CALL double_invfft_gamma(dffts,npw,npwx,evc(1,ibnd),dpsi(1,ibnd),psic,'Wave')
DO ir=1,dffts%nnr DO CONCURRENT (ir=1:dffts%nnr)
prod = REAL( psic(ir),KIND=DP) * DIMAG( psic(ir)) aux_r(ir) = aux_r(ir) + CMPLX( REAL( psic(ir),KIND=DP) * DIMAG( psic(ir)) , 0.0_DP, KIND=DP)
aux_r(ir) = aux_r(ir) + CMPLX( prod, 0.0_DP, KIND=DP)
ENDDO ENDDO
! !
ENDDO ENDDO
...@@ -313,7 +308,7 @@ MODULE dfpt_module ...@@ -313,7 +308,7 @@ MODULE dfpt_module
! !
CALL single_invfft_k(dffts,npw,npwx,dpsi(1,ibnd),dpsic,'Wave',igk_k(1,iks)) CALL single_invfft_k(dffts,npw,npwx,dpsi(1,ibnd),dpsic,'Wave',igk_k(1,iks))
! !
DO ir = 1, dffts%nnr DO CONCURRENT (ir = 1: dffts%nnr)
aux_r(ir) = aux_r(ir) + CONJG( psic(ir) * phase(ir) ) * dpsic(ir) aux_r(ir) = aux_r(ir) + CONJG( psic(ir) * phase(ir) ) * dpsic(ir)
ENDDO ENDDO
! !
...@@ -326,7 +321,7 @@ MODULE dfpt_module ...@@ -326,7 +321,7 @@ MODULE dfpt_module
! !
CALL single_invfft_k(dffts,npw,npwx,dpsi(npwx+1,ibnd),dpsic,'Wave',igk_k(1,iks)) CALL single_invfft_k(dffts,npw,npwx,dpsi(npwx+1,ibnd),dpsic,'Wave',igk_k(1,iks))
! !
DO ir = 1, dffts%nnr DO CONCURRENT (ir = 1: dffts%nnr)
aux_r(ir) = aux_r(ir) + CONJG( psic(ir) * phase(ir) ) * dpsic(ir) aux_r(ir) = aux_r(ir) + CONJG( psic(ir) * phase(ir) ) * dpsic(ir)
ENDDO ENDDO
! !
...@@ -347,8 +342,8 @@ MODULE dfpt_module ...@@ -347,8 +342,8 @@ MODULE dfpt_module
CALL single_fwfft_k(dffts,npwq,npwqx,aux_r,aux_g,'Wave',igq_q(1,iq)) CALL single_fwfft_k(dffts,npwq,npwqx,aux_r,aux_g,'Wave',igq_q(1,iq))
ENDIF ENDIF
! !
DO ig = 1, npwq ! pert acts only on body DO CONCURRENT( ig = 1: npwq) ! pert acts only on body
dng(ig,ipert) = dng(ig,ipert) + 2._DP * k_grid%weight(iks) * aux_g(ig) * pot3D%sqvc(ig) / omega dng(ig,ipert) = dng(ig,ipert) + 2._DP * k_grid%weight(iks) * aux_g(ig) / omega
ENDDO ENDDO
! !
DEALLOCATE( aux_g ) DEALLOCATE( aux_g )
......
...@@ -5,6 +5,7 @@ include ../../make.inc ...@@ -5,6 +5,7 @@ include ../../make.inc
# location of needed modules # location of needed modules
MODFLAGS= $(MOD_FLAG)../../iotk/src $(MOD_FLAG)../../Modules $(MOD_FLAG)../../LAXlib \ MODFLAGS= $(MOD_FLAG)../../iotk/src $(MOD_FLAG)../../Modules $(MOD_FLAG)../../LAXlib \
$(MOD_FLAG)../../FFTXlib $(MOD_FLAG)../../PW/src \ $(MOD_FLAG)../../FFTXlib $(MOD_FLAG)../../PW/src \
$(MOD_FLAG)../Libraries/Forpy \
$(MOD_FLAG)../Libraries/Json \ $(MOD_FLAG)../Libraries/Json \
$(MOD_FLAG)../Libraries/Base64 \ $(MOD_FLAG)../Libraries/Base64 \
$(MOD_FLAG)../Modules \ $(MOD_FLAG)../Modules \
...@@ -17,7 +18,6 @@ IFLAGS= ...@@ -17,7 +18,6 @@ IFLAGS=
IO_KERNEL_OBJS = \ IO_KERNEL_OBJS = \
mpiio.o \ mpiio.o \
my_mkdir.o \
cubefile.o \ cubefile.o \
function3d.o \ function3d.o \
pdep_io.o \ pdep_io.o \
...@@ -28,7 +28,7 @@ wfreq_io.o \ ...@@ -28,7 +28,7 @@ wfreq_io.o \
wfreq_restart.o wfreq_restart.o
PWOBJS = ../../PW/src/libpw.a PWOBJS = ../../PW/src/libpw.a
QEMODS = ../../Modules/libqemod.a ../../FFTXlib/libqefft.a ../../LAXlib/libqela.a ../Libraries/Json/libjson.a ../Libraries/Base64/libbase64.a QEMODS = ../../Modules/libqemod.a ../../FFTXlib/libqefft.a ../../LAXlib/libqela.a ../Libraries/Forpy/libforpy.a ../Libraries/Json/libjson.a ../Libraries/Base64/libbase64.a
TLDEPS= bindir mods libs pw TLDEPS= bindir mods libs pw
......
...@@ -16,333 +16,228 @@ MODULE function3d ...@@ -16,333 +16,228 @@ MODULE function3d
! !
IMPLICIT NONE IMPLICIT NONE
! !
INTERFACE write_function3d
MODULE PROCEDURE write_function3d_real !, write_function3d_complex
END INTERFACE
!
INTERFACE read_function3d
MODULE PROCEDURE read_function3d_real !, read_function3d_complex
END INTERFACE
!
CONTAINS CONTAINS
! !
!----------------------------------------------------------------- !-----------------------------------------------------------------
SUBROUTINE write_function3d ( dfft, fname, descriptor, ng, ngx, funct3d_g, nmaps, nl ) SUBROUTINE write_function3d_real ( fname, f_r, dfft )
! ----------------------------------------------------------------- ! -----------------------------------------------------------------
! !
USE kinds, ONLY : DP USE kinds, ONLY : DP
USE cell_base, ONLY : celldm, at USE cell_base, ONLY : celldm, at
USE control_flags, ONLY : gamma_only USE control_flags, ONLY : gamma_only
USE mp_bands, ONLY : me_bgrp USE mp_bands, ONLY : me_bgrp
USE westcom, ONLY : fftdriver
USE scatter_mod, ONLY : gather_grid USE scatter_mod, ONLY : gather_grid
USE fft_types, ONLY : fft_type_descriptor USE fft_types, ONLY : fft_type_descriptor
USE forpy_mod, ONLY: call_py, call_py_noret, import_py, module_py
USE forpy_mod, ONLY: tuple, tuple_create
USE forpy_mod, ONLY: dict, dict_create
USE forpy_mod, ONLY: list, list_create
USE forpy_mod, ONLY: object, cast
USE forpy_mod, ONLY: exception_matches, KeyError, err_clear, err_print
USE conversions, ONLY : ltoa, itoa, dtoa
USE base64_module USE base64_module
USE fourier_interpolation, ONLY : set_nl, single_interp_invfft_gamma,&
&single_interp_invfft_k, single_interp_fwfft_gamma,&
&single_interp_fwfft_k
! !
IMPLICIT NONE IMPLICIT NONE
! !
! I/O ! I/O
! !
TYPE(fft_type_descriptor), INTENT(IN) :: dfft
CHARACTER(LEN=*),INTENT(IN) :: fname CHARACTER(LEN=*),INTENT(IN) :: fname
CHARACTER(LEN=*),INTENT(IN) :: descriptor TYPE(fft_type_descriptor), INTENT(IN) :: dfft
INTEGER, INTENT(IN) :: ng, ngx, nmaps REAL(DP),INTENT(IN) :: f_r(dfft%nnr)
COMPLEX(DP),INTENT(IN) :: funct3d_g(ngx)
INTEGER,INTENT(IN) :: nl(nmaps,ngx)
! !
! Workspace ! Workspace
! !
INTEGER :: iu, ndim, nbytes, nlen, i
COMPLEX(DP),ALLOCATABLE :: funct3d_r_complex(:)
COMPLEX(DP),ALLOCATABLE :: funct3d_r_complex_gathered(:)
REAL(DP),ALLOCATABLE :: funct3d_r_double(:)
CHARACTER(LEN=14) :: lab(3)
CHARACTER(LEN=:),ALLOCATABLE :: charbase64 CHARACTER(LEN=:),ALLOCATABLE :: charbase64
CHARACTER(LEN=:),ALLOCATABLE :: ctype REAL(DP),ALLOCATABLE :: f_r_gathered(:), f_r_gathered_nopadded(:)
INTEGER :: ndim, nbytes, nlen
TYPE(tuple) :: args
TYPE(dict) :: kwargs
TYPE(module_py) :: pymod
TYPE(object) :: return_obj
INTEGER :: return_int
INTEGER :: IERR
! !
ALLOCATE( funct3d_r_complex(dfft%nnr) ) ! Gather the function
IF ( gamma_only ) THEN
SELECT CASE(fftdriver)
CASE('Wave')
CALL single_interp_invfft_gamma(dfft,ng,ngx,funct3d_g,funct3d_r_complex,fftdriver,nl)
CASE('Dense')
CALL single_interp_invfft_k(dfft,ng,ngx,funct3d_g,funct3d_r_complex,fftdriver,nl)
END SELECT
ELSE
CALL single_interp_invfft_k(dfft,ng,ngx,funct3d_g,funct3d_r_complex,fftdriver,nl)
ENDIF
! !
ALLOCATE( funct3d_r_complex_gathered(dfft%nr1x*dfft%nr2x*dfft%nr3x) ) ALLOCATE(f_r_gathered(dfft%nr1x*dfft%nr2x*dfft%nr3x)); f_r_gathered = 0._DP
funct3d_r_complex_gathered = 0.0_DP CALL gather_grid(dfft,f_r,f_r_gathered)
CALL gather_grid(dfft,funct3d_r_complex,funct3d_r_complex_gathered)
! !
IF( me_bgrp == 0 ) THEN IF( me_bgrp == 0 ) THEN
! !
! 2) Encode ALLOCATE(f_r_gathered_nopadded(dfft%nr1*dfft%nr2*dfft%nr3)); f_r_gathered_nopadded = 0._DP
! CALL remove_padding_real(dfft,f_r_gathered,f_r_gathered_nopadded)
IF( gamma_only ) THEN !
ALLOCATE( funct3d_r_double( dfft%nr1x*dfft%nr2x*dfft%nr3x ) ) ! Encode
funct3d_r_double = REAL(funct3d_r_complex_gathered(:),KIND=DP) !
DEALLOCATE(funct3d_r_complex_gathered) ndim = dfft%nr1*dfft%nr2*dfft%nr3
ndim = dfft%nr1x*dfft%nr2x*dfft%nr3x nbytes = SIZEOF(f_r_gathered_nopadded(1)) * ndim
nbytes = SIZEOF(funct3d_r_double(1)) * ndim nlen = lenbase64(nbytes)
nlen = lenbase64(nbytes) ALLOCATE(CHARACTER(LEN=nlen) :: charbase64)
ALLOCATE(CHARACTER(LEN=nlen) :: charbase64) IF (.NOT. islittleendian()) CALL base64_byteswap_double(nbytes,f_r_gathered_nopadded(1:ndim))
IF (.NOT. islittleendian()) CALL base64_byteswap_double(nbytes,funct3d_r_double(1:ndim)) CALL base64_encode_double(f_r_gathered_nopadded(1:ndim), ndim, charbase64)
CALL base64_encode_double(funct3d_r_double(1:ndim), ndim, charbase64) DEALLOCATE(f_r_gathered_nopadded)
DEALLOCATE(funct3d_r_double) !
ctype = "double" IERR = import_py(pymod, "west_function3d")
ELSE !
ndim = dfft%nr1x*dfft%nr2x*dfft%nr3x IERR = tuple_create(args, 1)
nbytes = SIZEOF(funct3d_r_complex_gathered(1)) * ndim IERR = args%setitem(0, TRIM(ADJUSTL(fname)) )
nlen = lenbase64(nbytes) IERR = dict_create(kwargs)
ALLOCATE(CHARACTER(LEN=nlen) :: charbase64) IERR = kwargs%setitem("name","delta_v")
IF (.NOT. islittleendian()) CALL base64_byteswap_complex(nbytes,funct3d_r_complex_gathered(1:ndim)) IERR = kwargs%setitem("domain",'{'// &
CALL base64_encode_complex(funct3d_r_complex_gathered(1:ndim), ndim, charbase64) & '"a":['//dtoa(celldm(1)*at(1,1))//","//dtoa(celldm(1)*at(2,1))//","//dtoa(celldm(1)*at(3,1))//'],'// &
DEALLOCATE(funct3d_r_complex_gathered) & '"b":['//dtoa(celldm(1)*at(1,2))//","//dtoa(celldm(1)*at(2,2))//","//dtoa(celldm(1)*at(3,2))//'],'// &
ctype = "complex" & '"c":['//dtoa(celldm(1)*at(1,3))//","//dtoa(celldm(1)*at(2,3))//","//dtoa(celldm(1)*at(3,3))//'] }')
ENDIF IERR = kwargs%setitem("grid","["//itoa(dfft%nr1)//","//itoa(dfft%nr2)//","//itoa(dfft%nr3)//"]" )
! IERR = kwargs%setitem("grid_function",charbase64)
! 3) Write IERR = kwargs%setitem("dtype","double")
! !
OPEN(NEWUNIT=iu,FILE=TRIM(ADJUSTL(fname))) IERR = call_py_noret(pymod, "base64_to_function3D", args, kwargs)
! !
WRITE(iu,'(a)') '<?xml version="1.0" encoding="UTF-8"?>' CALL kwargs%destroy
WRITE(iu,'(a)') '<fpmd:function3d xmlns:fpmd="http://www.quantum-simulation.org/ns/fpmd/fpmd-1.0"' CALL args%destroy
WRITE(iu,'(a)') 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' CALL pymod%destroy
WRITE(iu,'(a)') 'xsi:schemaLocation="http://www.quantum-simulation.org/ns/fpmd/fpmd-1.0 function3d.xsd"'
WRITE(iu,'(a)') 'name="',TRIM(ADJUSTL(descriptor)),'">'
DO i = 1, 3
WRITE(lab(i),'(f14.6)') celldm(1) * at(i,1)
ENDDO
WRITE(iu,'(a)') '<domain a="'//TRIM(ADJUSTL(lab(1)))//" "//TRIM(ADJUSTL(lab(2)))//" "//TRIM(ADJUSTL(lab(3)))//'"'
DO i = 1, 3
WRITE(lab(i),'(f14.6)') celldm(1) * at(i,2)
ENDDO
WRITE(iu,'(a)') 'b="'//TRIM(ADJUSTL(lab(1)))//" "//TRIM(ADJUSTL(lab(2)))//" "//TRIM(ADJUSTL(lab(3)))//'"'
DO i = 1, 3
WRITE(lab(i),'(f14.6)') celldm(1) * at(i,3)
ENDDO
WRITE(iu,'(a)') 'c="'//TRIM(ADJUSTL(lab(1)))//" "//TRIM(ADJUSTL(lab(2)))//" "//TRIM(ADJUSTL(lab(3)))//'"/>'
WRITE(lab(1),'(i14)') dfft%nr1x
WRITE(lab(2),'(i14)') dfft%nr2x
WRITE(lab(3),'(i14)') dfft%nr3x
WRITE(iu,'(a)') '<grid nx="'//TRIM(ADJUSTL(lab(1)))//'" ny="'//TRIM(ADJUSTL(lab(2)))//'" nz="'//TRIM(ADJUSTL(lab(3)))//'"/>'
WRITE(iu,'(a)') '<grid_function type="'//ctype//'" nx="'//TRIM(ADJUSTL(lab(1)))//'" ny="'//TRIM(ADJUSTL(lab(2)))// &
&'" nz="'//TRIM(ADJUSTL(lab(3)))//'" encoding="base64">'
CALL write_long_string(iu,charbase64)
WRITE(iu,'(a)') '</grid_function>'
WRITE(iu,'(a)') '</fpmd:function3d>'
! !
CLOSE(iu) ENDIF
! !
DEALLOCATE(charbase64) DEALLOCATE(f_r_gathered)
DEALLOCATE(ctype)
!
ELSE
DEALLOCATE( funct3d_r_complex )
ENDIF
! !
END SUBROUTINE END SUBROUTINE
! !
!----------------------------------------------------------------- !-----------------------------------------------------------------
SUBROUTINE read_function3d ( dfft, fname, ng, ngx, funct3d_g, nmaps, nl) SUBROUTINE read_function3d_real ( fname, f_r, dfft )
! ----------------------------------------------------------------- ! -----------------------------------------------------------------
! !
USE kinds, ONLY : DP USE kinds, ONLY : DP
USE cell_base, ONLY : celldm, at
USE control_flags, ONLY : gamma_only USE control_flags, ONLY : gamma_only