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 @@
*.out
doc/_build/
Modules/west_version.f90
*/__pycache__
......@@ -26,7 +26,7 @@ stages:
- git clone -b 'qe-6.1.0' --single-branch --depth 1 https://gitlab.com/QEF/q-e.git QEDIR
- cd QEDIR
- git describe
- ./configure
- ./configure LD_LIBS="`python3-config --ldflags`"
- make -j pw
- ls bin
- git clone -b $CI_COMMIT_REF_NAME $CI_REPOSITORY_URL West
......@@ -41,7 +41,7 @@ stages:
- git clone -b 'qe-6.1.0' --single-branch --depth 1 https://gitlab.com/QEF/q-e.git QEDIR
- cd QEDIR
- git describe
- ./configure
- ./configure LD_LIBS="`python3-config --ldflags`"
- make -j pw
- ls bin
- git clone -b $CI_COMMIT_REF_NAME $CI_REPOSITORY_URL West
......
......@@ -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:
- Francois Gygi (University of California, Davis): for strategic discussions
- Ikutaro Hamada (Osaka University): for the first implementation of k-points
- Yuan Ping (University of California, Santa Cruz): for the first implementation of 2D cutoff
- Jonathan Skone (University of Chicago): hybrid functionals
- Tyler Smart (University of California, Santa Cruz): for the first implementation of 2D cutoff
- Aditya Tanikanti (University of Chicago): for improving deployment and testing
- Feng Wu (University of California, Santa Cruz): for the first implementation of 2D cutoff
- Francois Gygi (University of California, Davis)
- Ikutaro Hamada (Osaka University)
- Yuan Ping (University of California, Santa Cruz)
- Jonathan Skone (University of Chicago)
- Tyler Smart (University of California, Santa Cruz)
- Aditya Tanikanti (University of Chicago)
- 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.
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)
-------------------
......
......@@ -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.
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
USE io_push, ONLY : io_push_title
USE mp_world, ONLY : mpime,world_comm
USE types_bz_grid, ONLY : k_grid, q_grid, compute_phase
USE types_coulomb, ONLY : pot3D
!
IMPLICIT NONE
!
......@@ -68,7 +67,7 @@ MODULE dfpt_module
INTEGER :: npwkq
!
REAL(DP) :: g0(3)
REAL(DP) :: anorm, prod
REAL(DP) :: anorm
REAL(DP), ALLOCATABLE :: eprec(:)
!
COMPLEX(DP), ALLOCATABLE :: dvpsi(:,:),dpsi(:,:)
......@@ -171,14 +170,11 @@ MODULE dfpt_module
!
DO ipert = 1, m
!
ALLOCATE( aux_g(npwqx) )
ALLOCATE( aux_r(dffts%nnr) )
!
aux_g=0._DP
aux_r=0._DP
ALLOCATE( aux_g(npwqx) ); aux_g = 0._DP
ALLOCATE( aux_r(dffts%nnr) ); aux_r = 0._DP
!
DO ig = 1, npwq ! perturbation acts only on body
aux_g(ig) = dvg(ig,ipert) * pot3D%sqvc(ig)
DO CONCURRENT (ig = 1:npwq)
aux_g(ig) = dvg(ig,ipert)
ENDDO
!
! ... inverse Fourier transform of the perturbation: (q+)G ---> R
......@@ -200,7 +196,7 @@ MODULE dfpt_module
DO ibnd=1,nbndval-MOD(nbndval,2),2
!
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)
ENDDO
CALL double_fwfft_gamma(dffts,npw,npwx,psic,dvpsi(1,ibnd),dvpsi(1,ibnd+1),'Wave')
......@@ -212,7 +208,7 @@ MODULE dfpt_module
ibnd=nbndval
!
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)
ENDDO
CALL single_fwfft_gamma(dffts,npw,npwx,psic,dvpsi(1,ibnd),'Wave')
......@@ -230,7 +226,7 @@ MODULE dfpt_module
! ... construct right-hand-side term of Sternheimer equation:
! ... 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)
ENDDO
!
......@@ -248,7 +244,7 @@ MODULE dfpt_module
!
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)
ENDDO
!
......@@ -292,9 +288,8 @@ MODULE dfpt_module
DO ibnd=1,nbndval
!
CALL double_invfft_gamma(dffts,npw,npwx,evc(1,ibnd),dpsi(1,ibnd),psic,'Wave')
DO ir=1,dffts%nnr
prod = REAL( psic(ir),KIND=DP) * DIMAG( psic(ir))
aux_r(ir) = aux_r(ir) + CMPLX( prod, 0.0_DP, KIND=DP)
DO CONCURRENT (ir=1:dffts%nnr)
aux_r(ir) = aux_r(ir) + CMPLX( REAL( psic(ir),KIND=DP) * DIMAG( psic(ir)) , 0.0_DP, KIND=DP)
ENDDO
!
ENDDO
......@@ -313,7 +308,7 @@ MODULE dfpt_module
!
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)
ENDDO
!
......@@ -326,7 +321,7 @@ MODULE dfpt_module
!
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)
ENDDO
!
......@@ -347,8 +342,8 @@ MODULE dfpt_module
CALL single_fwfft_k(dffts,npwq,npwqx,aux_r,aux_g,'Wave',igq_q(1,iq))
ENDIF
!
DO 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
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) / omega
ENDDO
!
DEALLOCATE( aux_g )
......
......@@ -5,6 +5,7 @@ include ../../make.inc
# location of needed modules
MODFLAGS= $(MOD_FLAG)../../iotk/src $(MOD_FLAG)../../Modules $(MOD_FLAG)../../LAXlib \
$(MOD_FLAG)../../FFTXlib $(MOD_FLAG)../../PW/src \
$(MOD_FLAG)../Libraries/Forpy \
$(MOD_FLAG)../Libraries/Json \
$(MOD_FLAG)../Libraries/Base64 \
$(MOD_FLAG)../Modules \
......@@ -17,7 +18,6 @@ IFLAGS=
IO_KERNEL_OBJS = \
mpiio.o \
my_mkdir.o \
cubefile.o \
function3d.o \
pdep_io.o \
......@@ -28,7 +28,7 @@ wfreq_io.o \
wfreq_restart.o
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
......
......@@ -16,333 +16,228 @@ MODULE function3d
!
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
!
!-----------------------------------------------------------------
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 cell_base, ONLY : celldm, at
USE control_flags, ONLY : gamma_only
USE mp_bands, ONLY : me_bgrp
USE westcom, ONLY : fftdriver
USE scatter_mod, ONLY : gather_grid
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 fourier_interpolation, ONLY : set_nl, single_interp_invfft_gamma,&
&single_interp_invfft_k, single_interp_fwfft_gamma,&
&single_interp_fwfft_k
!
IMPLICIT NONE
!
! I/O
!
TYPE(fft_type_descriptor), INTENT(IN) :: dfft
CHARACTER(LEN=*),INTENT(IN) :: fname
CHARACTER(LEN=*),INTENT(IN) :: descriptor
INTEGER, INTENT(IN) :: ng, ngx, nmaps
COMPLEX(DP),INTENT(IN) :: funct3d_g(ngx)
INTEGER,INTENT(IN) :: nl(nmaps,ngx)
TYPE(fft_type_descriptor), INTENT(IN) :: dfft
REAL(DP),INTENT(IN) :: f_r(dfft%nnr)
!
! 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 :: 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) )
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
! Gather the function
!
ALLOCATE( funct3d_r_complex_gathered(dfft%nr1x*dfft%nr2x*dfft%nr3x) )
funct3d_r_complex_gathered = 0.0_DP
CALL gather_grid(dfft,funct3d_r_complex,funct3d_r_complex_gathered)
ALLOCATE(f_r_gathered(dfft%nr1x*dfft%nr2x*dfft%nr3x)); f_r_gathered = 0._DP
CALL gather_grid(dfft,f_r,f_r_gathered)
!
IF( me_bgrp == 0 ) THEN
!
! 2) Encode
!
IF( gamma_only ) THEN
ALLOCATE( funct3d_r_double( dfft%nr1x*dfft%nr2x*dfft%nr3x ) )
funct3d_r_double = REAL(funct3d_r_complex_gathered(:),KIND=DP)
DEALLOCATE(funct3d_r_complex_gathered)
ndim = dfft%nr1x*dfft%nr2x*dfft%nr3x
nbytes = SIZEOF(funct3d_r_double(1)) * ndim
nlen = lenbase64(nbytes)
ALLOCATE(CHARACTER(LEN=nlen) :: charbase64)
IF (.NOT. islittleendian()) CALL base64_byteswap_double(nbytes,funct3d_r_double(1:ndim))
CALL base64_encode_double(funct3d_r_double(1:ndim), ndim, charbase64)
DEALLOCATE(funct3d_r_double)
ctype = "double"
ELSE
ndim = dfft%nr1x*dfft%nr2x*dfft%nr3x
nbytes = SIZEOF(funct3d_r_complex_gathered(1)) * ndim
nlen = lenbase64(nbytes)
ALLOCATE(CHARACTER(LEN=nlen) :: charbase64)
IF (.NOT. islittleendian()) CALL base64_byteswap_complex(nbytes,funct3d_r_complex_gathered(1:ndim))
CALL base64_encode_complex(funct3d_r_complex_gathered(1:ndim), ndim, charbase64)
DEALLOCATE(funct3d_r_complex_gathered)
ctype = "complex"
ENDIF
!
! 3) Write
!
OPEN(NEWUNIT=iu,FILE=TRIM(ADJUSTL(fname)))
!
WRITE(iu,'(a)') '<?xml version="1.0" encoding="UTF-8"?>'
WRITE(iu,'(a)') '<fpmd:function3d xmlns:fpmd="http://www.quantum-simulation.org/ns/fpmd/fpmd-1.0"'
WRITE(iu,'(a)') 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
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>'
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)
!
! Encode
!
ndim = dfft%nr1*dfft%nr2*dfft%nr3
nbytes = SIZEOF(f_r_gathered_nopadded(1)) * ndim
nlen = lenbase64(nbytes)
ALLOCATE(CHARACTER(LEN=nlen) :: charbase64)
IF (.NOT. islittleendian()) CALL base64_byteswap_double(nbytes,f_r_gathered_nopadded(1:ndim))
CALL base64_encode_double(f_r_gathered_nopadded(1:ndim), ndim, charbase64)
DEALLOCATE(f_r_gathered_nopadded)
!
IERR = import_py(pymod, "west_function3d")
!
IERR = tuple_create(args, 1)
IERR = args%setitem(0, TRIM(ADJUSTL(fname)) )
IERR = dict_create(kwargs)
IERR = kwargs%setitem("name","delta_v")
IERR = kwargs%setitem("domain",'{'// &
& '"a":['//dtoa(celldm(1)*at(1,1))//","//dtoa(celldm(1)*at(2,1))//","//dtoa(celldm(1)*at(3,1))//'],'// &
& '"b":['//dtoa(celldm(1)*at(1,2))//","//dtoa(celldm(1)*at(2,2))//","//dtoa(celldm(1)*at(3,2))//'],'// &
& '"c":['//dtoa(celldm(1)*at(1,3))//","//dtoa(celldm(1)*at(2,3))//","//dtoa(celldm(1)*at(3,3))//'] }')
IERR = kwargs%setitem("grid","["//itoa(dfft%nr1)//","//itoa(dfft%nr2)//","//itoa(dfft%nr3)//"]" )
IERR = kwargs%setitem("grid_function",charbase64)
IERR = kwargs%setitem("dtype","double")
!
IERR = call_py_noret(pymod, "base64_to_function3D", args, kwargs)
!
CALL kwargs%destroy
CALL args%destroy
CALL pymod%destroy
!
CLOSE(iu)
!
DEALLOCATE(charbase64)
DEALLOCATE(ctype)
!
ELSE
DEALLOCATE( funct3d_r_complex )
ENDIF
ENDIF
!
DEALLOCATE(f_r_gathered)
!
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 cell_base, ONLY : celldm, at
USE control_flags, ONLY : gamma_only
USE mp, ONLY : mp_bcast
USE mp_bands, ONLY : me_bgrp, intra_bgrp_comm
USE fft_types, ONLY : fft_type_descriptor
USE mp_bands, ONLY : me_bgrp
USE scatter_mod, ONLY : scatter_grid
USE westcom, ONLY : fftdriver
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 base64_module
USE fourier_interpolation
!
IMPLICIT NONE
!
! I/O
!
TYPE(fft_type_descriptor), INTENT(IN) :: dfft
CHARACTER(LEN=*),INTENT(IN) :: fname
INTEGER,INTENT(IN) :: ng, ngx, nmaps
COMPLEX(DP),INTENT(OUT) :: funct3d_g(ngx)
INTEGER,INTENT(IN) :: nl(nmaps,ngx)
TYPE(fft_type_descriptor), INTENT(IN) :: dfft
REAL(DP),INTENT(OUT) :: f_r(dfft%nnr)
!
! Workspace
!
INTEGER :: iu, i, nlen, ndim, nbytes, nx, ny, nz
COMPLEX(DP),ALLOCATABLE :: funct3d_r_complex_gathered(:)
COMPLEX(DP),ALLOCATABLE :: funct3d_r_complex(:)
REAL(DP),ALLOCATABLE :: funct3d_r_double(:)
INTEGER :: nlines, j, is, ie, ios, nline_start, nline_end
CHARACTER(LEN=256) :: buffline
CHARACTER(LEN=:),ALLOCATABLE :: bufftag
CHARACTER(LEN=:),ALLOCATABLE :: buff2
CHARACTER(LEN=:),ALLOCATABLE :: charbase64
LOGICAL :: lread
CHARACTER(LEN=:),ALLOCATABLE :: ctype
REAL(DP),ALLOCATABLE :: f_r_gathered(:), f_r_gathered_nopadded(:)
INTEGER :: ndim, nbytes, nlen
TYPE(tuple) :: args
TYPE(dict) :: kwargs, return_dict
TYPE(module_py) :: pymod
TYPE(object) :: return_obj
INTEGER :: return_int
INTEGER :: IERR
!
ALLOCATE(f_r_gathered(dfft%nr1x*dfft%nr2x*dfft%nr3x)); f_r_gathered = 0._DP
!
IF( me_bgrp == 0 ) THEN
!
OPEN(NEWUNIT=iu,FILE=TRIM(ADJUSTL(fname)))
! Decode
!
DO
READ(iu,'(a)',IOSTAT=ios) buffline
IF( ios /=0 ) EXIT
IF( INDEX(buffline,"<grid_function ") /= 0 ) THEN
bufftag = TRIM(buffline)
EXIT
ENDIF
ENDDO
!
DO WHILE ( INDEX(bufftag,">") == 0 )
READ(iu,'(a)',IOSTAT=ios) buffline
IF( ios /=0 ) EXIT
bufftag = bufftag // TRIM(buffline)
ENDDO
IERR = import_py(pymod, "west_function3d")
!
IERR = tuple_create(args, 1)
IERR = args%setitem(0, TRIM(ADJUSTL(fname)) )
IERR = dict_create(kwargs)
!
IF( INDEX(bufftag,">") == 0 ) THEN
lread = .false.
ELSE
is = INDEX(bufftag,'nx="') + 4
buff2 = bufftag(is:)
ie = INDEX(buff2,'"') + is - 2
READ(bufftag(is:ie),*) nx
is = INDEX(bufftag,'ny="') + 4
buff2 = bufftag(is:)
ie = INDEX(buff2,'"') + is - 2
READ(bufftag(is:ie),*) ny
is = INDEX(bufftag,'nz="') + 4
buff2 = bufftag(is:)
ie = INDEX(buff2,'"') + is - 2
READ(bufftag(is:ie),*) nz
is = INDEX(bufftag,'type="') + 6
buff2 = bufftag(is:)
ie = INDEX(buff2,'"') + is - 2
ctype = bufftag(is:ie)
lread = .true.
ENDIF
IERR = call_py(return_obj,pymod, "function3D_to_base64", args, kwargs)
!
IF( lread ) THEN
ndim = nx*ny*nz