Commit 22062212 authored by Govoni's avatar Govoni
Browse files

Updated json structure.

parent c41c01d3
......@@ -41,7 +41,6 @@ MODULE pdep_db
& n_steps_write_restart,n_pdep_restart_from_itr,n_pdep_read_from_file,trev_pdep, &
& tr2_dfpt,l_deflate,l_kinetic_only,ev,dvg,west_prefix,trev_pdep_rel, &
& l_minimize_exx_if_active,l_use_ecutrho,wstat_save_dir
!USE eig_distribute, ONLY : local_npert,pdep_distr_l2g
USE pdep_io, ONLY : pdep_merge_and_write_G
USE io_push, ONLY : io_push_bar
USE distribution_center, ONLY : pert
......@@ -56,7 +55,8 @@ MODULE pdep_db
CHARACTER(20),EXTERNAL :: human_readable_time
INTEGER :: iunout,global_j,local_j
INTEGER :: ierr
CHARACTER(12) :: eigenpot_filename(n_pdep_eigen)
!
TYPE(json_file) :: json
INTEGER :: iunit
!
......@@ -64,6 +64,13 @@ MODULE pdep_db
!
CALL mp_barrier(world_comm)
!
! SET FILENAMES
!
DO global_j = 1, n_pdep_eigen
WRITE(my_label,'(i6.6)') global_j
eigenpot_filename(global_j) = "E"//TRIM(ADJUSTL(my_label))//".json"
ENDDO
!
! TIMING
!
CALL start_clock('pdep_db')
......@@ -75,7 +82,8 @@ MODULE pdep_db
!
CALL add_intput_parameters_to_json_file( 2,(/1,2/) , json )
!
CALL json%add('eigenvalues.ev',ev(1:n_pdep_eigen))
CALL json%add('output.eigenval',ev(1:n_pdep_eigen))
CALL json%add('output.eigenpot',eigenpot_filename(1:n_pdep_eigen))
!
OPEN( NEWUNIT=iunit, FILE=TRIM( wstat_save_dir ) // '/' // TRIM('wstat-save.json') )
CALL json%print_file( iunit )
......@@ -91,10 +99,9 @@ MODULE pdep_db
! local -> global
!
global_j = pert%l2g(local_j)
WRITE(my_label,'(i6.6)') global_j
IF(global_j>n_pdep_eigen) CYCLE
!
fname = TRIM( wstat_save_dir ) // "/E"//TRIM(ADJUSTL(my_label))//".dat"
fname = TRIM( wstat_save_dir ) // "/"//TRIM(eigenpot_filename(global_j))
CALL pdep_merge_and_write_G(fname,dvg(:,local_j))
!
ENDDO
......@@ -133,7 +140,7 @@ MODULE pdep_db
USE pdep_io, ONLY : pdep_read_G_and_distribute
USE io_push, ONLY : io_push_bar
USE distribution_center, ONLY : pert
USE json_module, ONLY : json_file
USE json_module, ONLY : json_file
!
IMPLICIT NONE
!
......@@ -149,7 +156,8 @@ MODULE pdep_db
INTEGER :: dime, iun, global_j, local_j
REAL(DP),ALLOCATABLE :: tmp_ev(:)
LOGICAL :: found
TYPE(json_file) :: json
TYPE(json_file) :: json
CHARACTER(12),ALLOCATABLE :: eigenpot_filename(:)
!
! MPI BARRIER
!
......@@ -174,7 +182,8 @@ MODULE pdep_db
CALL json%load_file( filename = TRIM( dirname ) // '/' // TRIM('wstat-save.json') )
!
CALL json%get('input.wstat_control.n_pdep_eigen', tmp_n_pdep_eigen, found)
CALL json%get('eigenvalues.ev', tmp_ev, found)
CALL json%get('output.eigenval', tmp_ev, found)
CALL json%get('output.eigenpot', eigenpot_filename, found)
!
CALL json%destroy()
!
......@@ -195,6 +204,11 @@ MODULE pdep_db
IF ( mpime==root ) ev(1:nglob_to_be_read) = tmp_ev(1:nglob_to_be_read)
CALL mp_bcast( ev, root, world_comm )
!
IF( mpime /= root ) THEN
ALLOCATE( eigenpot_filename(1:tmp_n_pdep_eigen) )
ENDIF
CALL mp_bcast(eigenpot_filename,root,world_comm)
!
! 3) READ THE EIGENVECTOR FILES
!
IF(.NOT.ALLOCATED(dvg)) THEN
......@@ -207,10 +221,9 @@ MODULE pdep_db
! local -> global
!
global_j = pert%l2g(local_j)
WRITE(my_label,'(i6.6)') global_j
IF(global_j>n_eigen_to_get) CYCLE
!
fname = TRIM( dirname ) // "/E"//TRIM(ADJUSTL(my_label))//".dat"
fname = TRIM( dirname ) // "/"//TRIM(eigenpot_filename(global_j))
CALL pdep_read_G_and_distribute(fname,dvg(:,local_j))
!
ENDDO
......
......@@ -48,6 +48,7 @@ MODULE pdep_io
INTEGER :: iun,ierr
CHARACTER(LEN=:),ALLOCATABLE :: charbase64
INTEGER :: nbytes, ndim, iunit
CHARACTER(LEN=30) :: endian
!
!
IF(my_pool_id.NE.0) RETURN
......@@ -68,17 +69,19 @@ MODULE pdep_io
!
ndim = npwq0_g
nbytes = SIZEOF(tmp_vec(1)) * ndim
! CALL get_lenbase64( nbytes, lenbase64 )
ALLOCATE(CHARACTER(LEN=lenbase64(nbytes)) :: charbase64)
!IF (lbigendian) CALL base64_bytesswap_complex(nbytes,tmp_vec(1:ndim))
CALL base64_encode_complex(tmp_vec(1:ndim), ndim, charbase64)
!
OPEN( NEWUNIT=iunit, FILE = TRIM(fname) )
IF( isbigendian() ) THEN
WRITE( iunit, '(a,i0,a)' ) '{ "ndim" : ', ndim, ', "isbigendian" : true, "kind" : "complex", "array" :'
IF( islittleendian() ) THEN
endian = '"islittleendian" : true'
ELSE
WRITE( iunit, '(a,i0,a)' ) '{ "ndim" : ', ndim, ', "isbigendian" : false, "kind" : "complex", "array" :'
ENDIF
endian = '"islittleendian" : false'
ENDIF
!
OPEN( NEWUNIT=iunit, FILE = TRIM(fname) )
WRITE( iunit, '(a)' ) '{'
WRITE( iunit, '(a,i0,a)' ) '"meta" : { "readme" : "eigenpotential", "type" : "complex double", "space" : "G", "ndim" : ', &
ndim, ', "code" : "base64", '//TRIM(endian)//' }, "data" : '
WRITE( iunit, '(a)' ) '"'//charbase64//'"'
WRITE( iunit, '(a)' ) '}'
CLOSE( iunit )
......@@ -124,8 +127,9 @@ MODULE pdep_io
COMPLEX(DP),ALLOCATABLE :: tmp_vec(:)
INTEGER :: iun,ierr,ig
CHARACTER(LEN=:),ALLOCATABLE :: charbase64
CHARACTER(LEN=:),ALLOCATABLE :: endian
INTEGER :: nbytes, ndim, iunit
LOGICAL :: found, isbe
LOGICAL :: found, isle
!
! Resume all components
!
......@@ -147,8 +151,8 @@ MODULE pdep_io
CALL json%initialize()
CALL json%load_file( filename = TRIM(fname) )
!
CALL json%get('isbigendian', isbe, found)
CALL json%get('array', charbase64, found)
CALL json%get('meta.islittleendian', isle, found)
CALL json%get('data', charbase64, found)
!
! ... open XML descriptor
!
......@@ -162,7 +166,7 @@ MODULE pdep_io
CALL json%destroy()
!
CALL base64_decode_complex(charbase64, ndim, tmp_vec(1:ndim))
IF (isbigendian() .NEQV. isbe) CALL base64_byteswap_complex(nbytes,tmp_vec(1:ndim))
IF (islittleendian() .NEQV. isle) CALL base64_byteswap_complex(nbytes,tmp_vec(1:ndim))
DEALLOCATE( charbase64 )
!
END IF
......
......@@ -79,9 +79,9 @@ module base64_module
lenbase64 = ( ( nbytes + 2 ) / 3 ) * 4
END FUNCTION
!
LOGICAL FUNCTION isbigendian( )
LOGICAL FUNCTION islittleendian( )
IMPLICIT NONE
isbigendian = lbigendian
islittleendian = (.NOT.lbigendian)
END FUNCTION
!
END MODULE
......@@ -104,7 +104,6 @@ MODULE wstat_center
!
COMPLEX(DP) :: alphapv_dfpt
CHARACTER(LEN=256) :: wstat_save_dir
CHARACTER(LEN=256) :: wstat_output_dir
CHARACTER(LEN=256) :: wstat_restart_dir
LOGICAL :: l_is_wstat_converged
!
......
......@@ -15,12 +15,11 @@ SUBROUTINE set_dirs( )
!-----------------------------------------------------------------------
!
USE io_files, ONLY : tmp_dir
USE westcom, ONLY : west_prefix, wstat_save_dir, wstat_output_dir, wstat_restart_dir
USE westcom, ONLY : west_prefix, wstat_save_dir, wstat_restart_dir
!
IMPLICIT NONE
!
wstat_save_dir = TRIM( tmp_dir ) // TRIM( west_prefix ) // '.wstat.save'
wstat_output_dir = TRIM( tmp_dir ) // TRIM( west_prefix ) // '.wstat.output'
wstat_restart_dir = TRIM( tmp_dir ) // TRIM( west_prefix ) // '.wstat.restart'
!
END SUBROUTINE
......@@ -195,7 +195,7 @@ CONTAINS
USE west_version, ONLY : west_version_number, west_svn_revision
USE mp_world, ONLY : mpime,root
USE westcom, ONLY : logfile
USE base64_module, ONLY : isbigendian
USE base64_module, ONLY : islittleendian
!
! I/O
!
......@@ -229,10 +229,10 @@ CONTAINS
WRITE( stdout, '(/5X,"Based on the Quantum ESPRESSO v. ",A)') TRIM (version_number)
ENDIF
!
IF( isbigendian() ) THEN
WRITE( stdout, '(/5X,"I/O is Big Endian",A)') ""
IF( islittleendian() ) THEN
WRITE( stdout, '(/5X,"I/O is Little Endian",A)') ""
ELSE
WRITE( stdout, '(/5X,"I/O is Little Endian",A)') ""
WRITE( stdout, '(/5X,"I/O is Big Endian",A)') ""
ENDIF
!
IF( mpime == root ) THEN
......@@ -249,7 +249,7 @@ CONTAINS
CALL json%add('run.software.citation',"M. Govoni et al., J. Chem. Theory Comput. 11, 2680 (2015).")
CALL json%add('run.software.qeversion', TRIM(version_number) )
IF( TRIM (svn_revision) /= "unknown" ) CALL json%add('run.software.qesvn', TRIM(svn_revision) )
CALL json%add('run.io.isbigendian', isbigendian() )
CALL json%add('run.io.islittleendian', islittleendian() )
!
OPEN( NEWUNIT=iunit, FILE=TRIM(logfile) )
CALL json%print_file( iunit )
......
......@@ -211,7 +211,7 @@ SUBROUTINE solve_gfreq_gamma(l_read_restart)
! Exhume dbs eigenvalue
!
WRITE(my_label_b,'(i6.6)') glob_ip
fname = TRIM( wstat_dirname ) // "/E"//TRIM(ADJUSTL(my_label_b))//".dat"
fname = TRIM( wstat_dirname ) // "/E"//TRIM(ADJUSTL(my_label_b))//".json"
CALL pdep_read_G_and_distribute(fname,pertg)
!
! Multiply by sqvc
......@@ -516,7 +516,7 @@ SUBROUTINE solve_gfreq_k(l_read_restart)
! Exhume dbs eigenvalue
!
WRITE(my_label_b,'(i6.6)') glob_ip
fname = TRIM( wstat_dirname ) // "/E"//TRIM(ADJUSTL(my_label_b))//".dat"
fname = TRIM( wstat_dirname ) // "/E"//TRIM(ADJUSTL(my_label_b))//".json"
CALL pdep_read_G_and_distribute(fname,pertg)
!
! Multiply by sqvc
......
......@@ -29,7 +29,6 @@ SUBROUTINE solve_hf()
USE pwcom, ONLY : et,nks,current_spin,isk,xk,nbnd,lsda,g2kin,current_k
USE wavefunctions_module, ONLY : evc,psic,psic_nc
USE io_files, ONLY : tmp_dir
USE pdep_io, ONLY : pdep_read_G_and_distribute
USE io_push, ONLY : io_push_title,io_push_bar
USE noncollin_module, ONLY : noncolin,npol
USE constants, ONLY : rytoev
......
......@@ -300,7 +300,7 @@ SUBROUTINE solve_wfreq_gamma(l_read_restart,l_generate_plot)
! Exhume dbs eigenvalue
!
WRITE(my_label_b,'(i6.6)') glob_ip
fname = TRIM( wstat_dirname ) // "/E"//TRIM(ADJUSTL(my_label_b))//".dat"
fname = TRIM( wstat_dirname ) // "/E"//TRIM(ADJUSTL(my_label_b))//".json"
CALL pdep_read_G_and_distribute(fname,pertg)
!
! Multiply by sqvc
......@@ -876,7 +876,7 @@ SUBROUTINE solve_wfreq_k(l_read_restart,l_generate_plot)
! Exhume dbs eigenvalue
!
WRITE(my_label_b,'(i6.6)') glob_ip
fname = TRIM( wstat_dirname ) // "/E"//TRIM(ADJUSTL(my_label_b))//".dat"
fname = TRIM( wstat_dirname ) // "/E"//TRIM(ADJUSTL(my_label_b))//".json"
CALL pdep_read_G_and_distribute(fname,pertg)
!
! Multiply by sqvc
......
......@@ -213,9 +213,9 @@ MODULE wstat_restart
WRITE(my_label,'(i6.6)') global_j
IF(global_j>nbase) CYCLE
!
fname = TRIM( dirname ) // "/V"//TRIM(ADJUSTL(my_label))//".dat"
fname = TRIM( dirname ) // "/V"//TRIM(ADJUSTL(my_label))//".json"
CALL pdep_merge_and_write_G(fname,dvg(:,local_j))
fname = TRIM( dirname ) // "/N"//TRIM(ADJUSTL(my_label))//".dat"
fname = TRIM( dirname ) // "/N"//TRIM(ADJUSTL(my_label))//".json"
CALL pdep_merge_and_write_G(fname,dng(:,local_j))
!
ENDDO
......@@ -412,9 +412,9 @@ MODULE wstat_restart
WRITE(my_label,'(i6.6)') global_j
IF(global_j>nbase) CYCLE
!
fname = TRIM( dirname ) // "/V"//TRIM(ADJUSTL(my_label))//".dat"
fname = TRIM( dirname ) // "/V"//TRIM(ADJUSTL(my_label))//".json"
CALL pdep_merge_and_write_G(fname,dvg(:,local_j))
fname = TRIM( dirname ) // "/N"//TRIM(ADJUSTL(my_label))//".dat"
fname = TRIM( dirname ) // "/N"//TRIM(ADJUSTL(my_label))//".json"
CALL pdep_merge_and_write_G(fname,dng(:,local_j))
!
ENDDO
......@@ -468,9 +468,9 @@ MODULE wstat_restart
CALL delete_if_present( TRIM( dirname ) // '/' // TRIM( 'vr.dat' ) )
DO ip=1,n_pdep_basis
WRITE(my_label,'(i6.6)') ip
fname="V"//TRIM(ADJUSTL(my_label))//".dat"
fname="V"//TRIM(ADJUSTL(my_label))//".json"
CALL delete_if_present( TRIM( dirname ) // '/' // TRIM( fname ) )
fname="N"//TRIM(ADJUSTL(my_label))//".dat"
fname="N"//TRIM(ADJUSTL(my_label))//".json"
CALL delete_if_present( TRIM( dirname ) // '/' // TRIM( fname ) )
ENDDO
ierr = f_rmdir( TRIM( dirname ) )
......@@ -928,9 +928,9 @@ MODULE wstat_restart
WRITE(my_label,'(i6.6)') global_j
IF(global_j>nbase) CYCLE
!
fname = TRIM( dirname ) // "/V"//TRIM(ADJUSTL(my_label))//".dat"
fname = TRIM( dirname ) // "/V"//TRIM(ADJUSTL(my_label))//".json"
CALL pdep_read_G_and_distribute(fname,dvg(:,local_j))
fname = TRIM( dirname ) // "/N"//TRIM(ADJUSTL(my_label))//".dat"
fname = TRIM( dirname ) // "/N"//TRIM(ADJUSTL(my_label))//".json"
CALL pdep_read_G_and_distribute(fname,dng(:,local_j))
!
ENDDO
......
......@@ -16,7 +16,7 @@ SUBROUTINE wstat_setup
!
USE westcom, ONLY : alphapv_dfpt,npwq0,sqvc,west_prefix,&
& n_pdep_basis,n_pdep_eigen,n_pdep_times,isz,l_use_ecutrho,&
& wstat_save_dir, wstat_output_dir, wstat_restart_dir
& wstat_save_dir, wstat_restart_dir
USE mp, ONLY : mp_max
USE mp_global, ONLY : intra_bgrp_comm
USE pwcom, ONLY : npw,npwx
......@@ -49,8 +49,6 @@ SUBROUTINE wstat_setup
!
!wstat_dirname = TRIM( tmp_dir ) // TRIM( west_prefix ) // '.wstat.save'
CALL my_mkdir( wstat_save_dir )
CALL my_mkdir( wstat_output_dir )
!CALL my_mkdir( wstat_restart_dir )
!
n_pdep_basis = n_pdep_eigen * n_pdep_times
!
......
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