Commit 7024fc76 authored by Marco Govoni's avatar Marco Govoni
Browse files

Merge branch 'develop' into 'doc_improvement'

# Conflicts:
#   IO_kernel/pdep_io.f90
#   Wfreq/solve_gfreq.f90
#   Wfreq/solve_wfreq.f90
parents 89215e18 0d29121a
......@@ -7,28 +7,28 @@
!
! This file is part of WEST.
!
! Contributors to this file:
! Contributors to this file:
! Marco Govoni
!
!-----------------------------------------------------------------------
MODULE pdep_io
!----------------------------------------------------------------------------
!
USE kinds, ONLY : DP
USE mp_global, ONLY : me_bgrp,root_bgrp,nproc_bgrp,intra_bgrp_comm,my_pool_id,my_bgrp_id,inter_bgrp_comm,inter_pool_comm,&
& intra_pool_comm
USE westcom, ONLY : npwq, npwq_g, npwqx, ngq, ngq_g, npwqx, igq_q !, igq_l2g_kdip
USE gvect, ONLY : ig_l2g
USE json_module, ONLY : json_file
USE control_flags, ONLY : gamma_only
USE base64_module
USE kinds, ONLY : DP
USE mp_global, ONLY : me_bgrp,root_bgrp,nproc_bgrp,intra_bgrp_comm,my_pool_id,&
& my_bgrp_id,inter_bgrp_comm,inter_pool_comm,intra_pool_comm
USE westcom, ONLY : npwq,npwq_g,npwqx,ngq,ngq_g,igq_q
USE gvect, ONLY : ig_l2g
USE json_module, ONLY : json_file
USE control_flags, ONLY : gamma_only
USE base64_module
!
IMPLICIT NONE
!
CONTAINS
!
! ******************************************
! WRITE IN G SPACE
! WRITE IN G SPACE
! wfc is passed distributed in G space
! then merged and written in R space
! ******************************************
......@@ -36,12 +36,12 @@ MODULE pdep_io
SUBROUTINE pdep_merge_and_write_G(fname,pdepg,iq)
!
USE mp_wave, ONLY : mergewf
USE mp, ONLY : mp_bcast, mp_max
USE mp, ONLY : mp_bcast,mp_max
!
IMPLICIT NONE
!
! I/O
!
!
CHARACTER(*), INTENT(IN) :: fname
COMPLEX(DP), INTENT(IN) :: pdepg(npwqx)
INTEGER, INTENT(IN), OPTIONAL :: iq
......@@ -49,24 +49,26 @@ MODULE pdep_io
! Workspace
!
COMPLEX(DP),ALLOCATABLE :: tmp_vec(:)
INTEGER :: iun,ierr,ig
INTEGER :: ig
CHARACTER(LEN=:),ALLOCATABLE :: charbase64
INTEGER :: nbytes, ndim, iunit, nlen
CHARACTER(LEN=30) :: endian
INTEGER :: npwqx_g
INTEGER :: npwqx_g
INTEGER, ALLOCATABLE :: igq_l2g_kdip(:), igq_l2g(:)
INTEGER, PARAMETER :: default_iq = 1
INTEGER :: iq_
INTEGER :: iq_
!
IF( PRESENT(iq) ) THEN
CALL start_clock('pdep_write')
!
IF( PRESENT(iq) ) THEN
iq_ = iq
ELSE
iq_ = default_iq
ENDIF
ENDIF
!
IF ( .NOT. gamma_only) THEN
!
! Resume all components
! Resume all components
!
ndim = ngq_g(iq_)
!
......@@ -84,40 +86,40 @@ MODULE pdep_io
DEALLOCATE( igq_l2g )
!
! </NEW>
!
! npwq_g = MAXVAL(igq_l2g_kdip(1:ndim,iq))
! CALL mp_max(npwq_g,intra_pool_comm)
! CALL mp_max(npwq_g,intra_bgrp_comm)
!
! npwq_g = MAXVAL(igq_l2g_kdip(1:ndim,iq))
! CALL mp_max(npwq_g,intra_pool_comm)
! CALL mp_max(npwq_g,intra_bgrp_comm)
!
ALLOCATE( tmp_vec(npwq_g) )
tmp_vec=0._DP
!
CALL mergewf( pdepg(:), tmp_vec, npwq, igq_l2g_kdip, me_bgrp, nproc_bgrp, root_bgrp, intra_bgrp_comm)
DEALLOCATE( igq_l2g_kdip )
DEALLOCATE( igq_l2g_kdip )
!
! ONLY ROOT W/IN BGRP WRITES
!
IF(me_bgrp==root_bgrp) THEN
IF(me_bgrp==root_bgrp) THEN
!
nbytes = SIZEOF(tmp_vec(1)) * ndim
nlen = lenbase64(nbytes)
ALLOCATE(CHARACTER(LEN=nlen) :: charbase64)
CALL base64_encode_complex(tmp_vec(1:ndim), ndim, charbase64)
CALL base64_encode_complex(tmp_vec(1:ndim), ndim, charbase64)
!
IF( islittleendian() ) THEN
IF( islittleendian() ) THEN
endian = '"islittleendian" : true'
ELSE
endian = '"islittleendian" : false'
ENDIF
ENDIF
!
OPEN( NEWUNIT=iunit, FILE = TRIM(fname) )
WRITE( iunit, '(a)' ) '{'
WRITE( iunit, '(a,i0,a)' ) '"meta" : { "name" : "eigenpotential", "type" : "complex double", "space" : "G",&
"ndim" : ', ndim, ', "encoding" : "base64", '//TRIM(endian)//' }'
WRITE( iunit, '(a)') ', "data" : '
WRITE( iunit, '(a)') ', "data" : '
WRITE( iunit, '(a)' ) '"'//charbase64//'"'
WRITE( iunit, '(a)' ) '}'
CLOSE( iunit )
CLOSE( iunit )
!
DEALLOCATE( charbase64 )
!
......@@ -127,37 +129,37 @@ MODULE pdep_io
!
ELSE
!
! Resume all components
! Resume all components
!
ALLOCATE( tmp_vec(npwq_g) )
tmp_vec=0._DP
!
CALL mergewf( pdepg(:), tmp_vec, npwq, ig_l2g(1:npwq), me_bgrp, nproc_bgrp, root_bgrp, intra_bgrp_comm)
CALL mergewf( pdepg(:), tmp_vec, npwq, ig_l2g(1:npwq), me_bgrp, nproc_bgrp, root_bgrp, intra_bgrp_comm)
!
! ONLY ROOT W/IN BGRP WRITES
!
IF(me_bgrp==root_bgrp) THEN
IF(me_bgrp==root_bgrp) THEN
!
ndim = npwq_g
nbytes = SIZEOF(tmp_vec(1)) * ndim
nlen = lenbase64(nbytes)
ALLOCATE(CHARACTER(LEN=nlen) :: charbase64)
CALL base64_encode_complex(tmp_vec(1:ndim), ndim, charbase64)
CALL base64_encode_complex(tmp_vec(1:ndim), ndim, charbase64)
!
IF( islittleendian() ) THEN
IF( islittleendian() ) THEN
endian = '"islittleendian" : true'
ELSE
endian = '"islittleendian" : false'
ENDIF
ENDIF
!
OPEN( NEWUNIT=iunit, FILE = TRIM(fname) )
WRITE( iunit, '(a)' ) '{'
WRITE( iunit, '(a,i0,a)' ) '"meta" : { "name" : "eigenpotential", "type" : "complex double", "space" : "G",&
"ndim" : ', ndim, ', "encoding" : "base64", '//TRIM(endian)//' }'
WRITE( iunit, '(a)') ', "data" : '
WRITE( iunit, '(a)') ', "data" : '
WRITE( iunit, '(a)' ) '"'//charbase64//'"'
WRITE( iunit, '(a)' ) '}'
CLOSE( iunit )
CLOSE( iunit )
!
DEALLOCATE( charbase64 )
!
......@@ -166,11 +168,13 @@ MODULE pdep_io
DEALLOCATE( tmp_vec )
!
ENDIF
!
!
CALL stop_clock('pdep_write')
!
END SUBROUTINE
!
! ******************************************
! READ IN G SPACE
! READ IN G SPACE
! wfc is read merged in G space
! then split in G space
! ******************************************
......@@ -185,7 +189,7 @@ MODULE pdep_io
IMPLICIT NONE
!
! I/O
!
!
CHARACTER(*), INTENT(IN) :: fname
COMPLEX(DP), INTENT(OUT) :: pdepg(npwqx)
INTEGER, INTENT(IN), OPTIONAL :: iq
......@@ -194,31 +198,33 @@ MODULE pdep_io
!
TYPE(json_file) :: json
COMPLEX(DP),ALLOCATABLE :: tmp_vec(:)
INTEGER :: iun,ierr,ig
INTEGER :: ig
CHARACTER(LEN=1000) :: line
CHARACTER(LEN=:),ALLOCATABLE :: charbase64
CHARACTER(LEN=:),ALLOCATABLE :: endian
INTEGER :: nbytes, ndim, iunit, nlen
LOGICAL :: found, isle
INTEGER :: npwqx_g
INTEGER, ALLOCATABLE :: igq_l2g_kdip(:), igq_l2g(:)
INTEGER, ALLOCATABLE :: igq_l2g_kdip(:), igq_l2g(:)
INTEGER, PARAMETER :: default_iq = 1
INTEGER :: iq_
INTEGER :: iq_
!
IF( PRESENT(iq) ) THEN
CALL start_clock('pdep_read')
!
IF( PRESENT(iq) ) THEN
iq_ = iq
ELSE
iq_ = default_iq
ENDIF
ENDIF
!
IF ( .NOT. gamma_only ) THEN
!
! Resume all components
! Resume all components
!
ndim = ngq_g(iq_)
! npwq_g = MAXVAL(igq_l2g_kdip(1:ndim,iq))
! CALL mp_max(npwq_g,intra_pool_comm)
! CALL mp_max(npwq_g,intra_bgrp_comm)
! npwq_g = MAXVAL(igq_l2g_kdip(1:ndim,iq))
! CALL mp_max(npwq_g,intra_pool_comm)
! CALL mp_max(npwq_g,intra_bgrp_comm)
!
ALLOCATE( tmp_vec(npwq_g) )
tmp_vec=0._DP
......@@ -231,17 +237,17 @@ MODULE pdep_io
nbytes = SIZEOF(tmp_vec(1)) * ndim
nlen = lenbase64(nbytes)
!
IF(me_bgrp==root_bgrp) THEN
IF(me_bgrp==root_bgrp) THEN
!
ALLOCATE(CHARACTER(LEN=(nlen+2)) :: charbase64)
!
OPEN( NEWUNIT=iunit, FILE = TRIM(fname) )
READ( iunit, * )
READ( iunit, '(a)' ) line
READ( iunit, * )
READ( iunit, * )
READ( iunit, '(a)' ) line
READ( iunit, * )
READ( iunit, '(a)' ) charbase64
CLOSE( iunit )
CALL base64_decode_complex(charbase64(2:(nlen+1)), ndim, tmp_vec(1:ndim))
CALL base64_decode_complex(charbase64(2:(nlen+1)), ndim, tmp_vec(1:ndim))
DEALLOCATE( charbase64 )
!
CALL json%load_from_string("{"//TRIM(line)//"}")
......@@ -267,9 +273,9 @@ MODULE pdep_io
DEALLOCATE( igq_l2g )
!
! </NEW>
!
CALL splitwf( pdepg, tmp_vec, npwq, igq_l2g_kdip, me_bgrp, nproc_bgrp, root_bgrp, intra_bgrp_comm)
DEALLOCATE( igq_l2g_kdip )
!
CALL splitwf( pdepg, tmp_vec, npwq, igq_l2g_kdip, me_bgrp, nproc_bgrp, root_bgrp, intra_bgrp_comm)
DEALLOCATE( igq_l2g_kdip )
!
ENDIF
!
......@@ -280,7 +286,7 @@ MODULE pdep_io
!
ELSE
!
! Resume all components
! Resume all components
!
ALLOCATE( tmp_vec(npwq_g) )
tmp_vec=0._DP
......@@ -294,17 +300,17 @@ MODULE pdep_io
nbytes = SIZEOF(tmp_vec(1)) * ndim
nlen = lenbase64(nbytes)
!
IF(me_bgrp==root_bgrp) THEN
IF(me_bgrp==root_bgrp) THEN
!
ALLOCATE(CHARACTER(LEN=(nlen+2)) :: charbase64)
!
OPEN( NEWUNIT=iunit, FILE = TRIM(fname) )
READ( iunit, * )
READ( iunit, '(a)' ) line
READ( iunit, * )
READ( iunit, * )
READ( iunit, '(a)' ) line
READ( iunit, * )
READ( iunit, '(a)' ) charbase64
CLOSE( iunit )
CALL base64_decode_complex(charbase64(2:(nlen+1)), ndim, tmp_vec(1:ndim))
CALL base64_decode_complex(charbase64(2:(nlen+1)), ndim, tmp_vec(1:ndim))
DEALLOCATE( charbase64 )
!
CALL json%load_from_string("{"//TRIM(line)//"}")
......@@ -315,7 +321,7 @@ MODULE pdep_io
!
END IF
!
CALL splitwf( pdepg, tmp_vec, npwq, ig_l2g(1:npwq), me_bgrp, nproc_bgrp, root_bgrp, intra_bgrp_comm)
CALL splitwf( pdepg, tmp_vec, npwq, ig_l2g(1:npwq), me_bgrp, nproc_bgrp, root_bgrp, intra_bgrp_comm)
!
ENDIF
!
......@@ -325,7 +331,9 @@ MODULE pdep_io
CALL mp_bcast(pdepg,0,inter_pool_comm)
!
ENDIF
!
!
CALL stop_clock('pdep_read')
!
END SUBROUTINE
!
END MODULE
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment