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