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

Reset pdep_db.f90

parent cb77dcdf
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
MODULE pdep_db MODULE pdep_db
!---------------------------------------------------------------------------- !----------------------------------------------------------------------------
! !
USE kinds, ONLY : DP USE iotk_module
USE westcom, ONLY : wstat_save_dir USE kinds, ONLY : DP
USE json_module, ONLY : json_file USE io_files, ONLY : tmp_dir
! !
IMPLICIT NONE IMPLICIT NONE
! !
...@@ -32,14 +32,15 @@ MODULE pdep_db ...@@ -32,14 +32,15 @@ MODULE pdep_db
SUBROUTINE pdep_db_write( ) SUBROUTINE pdep_db_write( )
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! !
USE xml_io_base, ONLY : create_directory
USE mp, ONLY : mp_bcast,mp_barrier USE mp, ONLY : mp_bcast,mp_barrier
USE mp_world, ONLY : mpime,root,world_comm USE mp_world, ONLY : mpime,root,world_comm
USE mp_global, ONLY : my_image_id USE mp_global, ONLY : my_image_id
USE io_global, ONLY : stdout USE io_global, ONLY : stdout
USE westcom, ONLY : n_pdep_eigen,n_dfpt_maxiter, & USE westcom, ONLY : wstat_calculation,n_pdep_times,n_pdep_eigen,n_pdep_maxiter,n_dfpt_maxiter, &
& n_steps_write_restart,n_pdep_restart_from_itr,n_pdep_read_from_file,trev_pdep, & & 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,wstat_save_dir,trev_pdep_rel, & & tr2_dfpt,l_deflate,l_kinetic_only,ev,dvg,west_prefix,trev_pdep_rel, &
& l_minimize_exx_if_active,l_use_ecutrho & l_minimize_exx_if_active,l_use_ecutrho,wstat_save_dir
!USE eig_distribute, ONLY : local_npert,pdep_distr_l2g !USE eig_distribute, ONLY : local_npert,pdep_distr_l2g
USE pdep_io, ONLY : pdep_merge_and_write_G USE pdep_io, ONLY : pdep_merge_and_write_G
USE io_push, ONLY : io_push_bar USE io_push, ONLY : io_push_bar
...@@ -54,7 +55,6 @@ MODULE pdep_db ...@@ -54,7 +55,6 @@ MODULE pdep_db
CHARACTER(20),EXTERNAL :: human_readable_time CHARACTER(20),EXTERNAL :: human_readable_time
INTEGER :: iunout,global_j,local_j INTEGER :: iunout,global_j,local_j
INTEGER :: ierr INTEGER :: ierr
TYPE(json_file) :: json
! !
! MPI BARRIER ! MPI BARRIER
! !
...@@ -64,62 +64,72 @@ MODULE pdep_db ...@@ -64,62 +64,72 @@ MODULE pdep_db
! !
CALL start_clock('pdep_db') CALL start_clock('pdep_db')
time_spent(1)=get_clock('pdep_db') time_spent(1)=get_clock('pdep_db')
!! !
!! 1) CREATE THE INPUT FILE ! 1) CREATE THE INPUT FILE
!! !
!IF ( mpime == root ) THEN IF ( mpime == root ) THEN
! ! !
! ! ... open XML descriptor ! ... open XML descriptor
! ! !
! CALL iotk_free_unit( iunout, ierr ) CALL iotk_free_unit( iunout, ierr )
! CALL iotk_open_write( iunout, FILE = TRIM( wstat_save_dir ) // '/' // TRIM("input-file.xml") , BINARY=.FALSE.,IERR=ierr ) CALL iotk_open_write( iunout, FILE = TRIM( wstat_save_dir ) // '/' // TRIM("input-file.xml") , BINARY=.FALSE.,IERR=ierr )
! ! !
!END IF END IF
!! !
!CALL mp_bcast( ierr, root, world_comm ) CALL mp_bcast( ierr, root, world_comm )
!CALL errore( 'pdep_db', 'cannot open input-file.xml for writing', ierr ) CALL errore( 'pdep_db', 'cannot open input-file.xml for writing', ierr )
!! !
!IF ( mpime == root ) THEN IF ( mpime == root ) THEN
! ! !
! CALL iotk_write_begin( iunout, "WSTAT_CONTROL" ) CALL iotk_write_begin( iunout, "WSTAT_CONTROL" )
! ! !
! CALL iotk_write_dat( iunout, "wstat_calculation" , wstat_calculation) CALL iotk_write_dat( iunout, "wstat_calculation" , wstat_calculation)
! CALL iotk_write_dat( iunout, "n_pdep_eigen" , n_pdep_eigen) CALL iotk_write_dat( iunout, "n_pdep_eigen" , n_pdep_eigen)
! CALL iotk_write_dat( iunout, "n_pdep_times" , n_pdep_times) CALL iotk_write_dat( iunout, "n_pdep_times" , n_pdep_times)
! CALL iotk_write_dat( iunout, "n_pdep_maxiter" , n_pdep_maxiter) CALL iotk_write_dat( iunout, "n_pdep_maxiter" , n_pdep_maxiter)
! CALL iotk_write_dat( iunout, "n_dfpt_maxiter" , n_dfpt_maxiter) CALL iotk_write_dat( iunout, "n_dfpt_maxiter" , n_dfpt_maxiter)
! CALL iotk_write_dat( iunout, "n_pdep_read_from_file" , n_pdep_read_from_file) CALL iotk_write_dat( iunout, "n_pdep_read_from_file" , n_pdep_read_from_file)
! CALL iotk_write_dat( iunout, "trev_pdep" , trev_pdep) CALL iotk_write_dat( iunout, "trev_pdep" , trev_pdep)
! CALL iotk_write_dat( iunout, "trev_pdep_rel" , trev_pdep_rel) CALL iotk_write_dat( iunout, "trev_pdep_rel" , trev_pdep_rel)
! CALL iotk_write_dat( iunout, "tr2_dfpt" , tr2_dfpt) CALL iotk_write_dat( iunout, "tr2_dfpt" , tr2_dfpt)
! CALL iotk_write_dat( iunout, "l_kinetic_only" , l_kinetic_only) CALL iotk_write_dat( iunout, "l_kinetic_only" , l_kinetic_only)
! CALL iotk_write_dat( iunout, "l_minimize_exx_if_active" , l_minimize_exx_if_active) CALL iotk_write_dat( iunout, "l_minimize_exx_if_active" , l_minimize_exx_if_active)
! CALL iotk_write_dat( iunout, "l_use_ecutrho" , l_use_ecutrho) CALL iotk_write_dat( iunout, "l_use_ecutrho" , l_use_ecutrho)
! ! !
! CALL iotk_write_end( iunout, "WSTAT_CONTROL" ) CALL iotk_write_end( iunout, "WSTAT_CONTROL" )
! ! !
! ! ... close XML descriptor ! ... close XML descriptor
! ! !
! CALL iotk_close_write( iunout ) CALL iotk_close_write( iunout )
! ! !
!END IF END IF
! !
! 2) CREATE THE EIGENVALUE FILE ! 2) CREATE THE EIGENVALUE FILE
! !
IF( mpime == root ) THEN IF ( mpime == root ) THEN
!
! ... open XML descriptor
! !
CALL json%initialize() CALL iotk_free_unit( iunout, ierr )
CALL iotk_open_write( iunout, FILE = TRIM( wstat_save_dir ) // '/' // TRIM("dbs_eigenvalues.xml"),BINARY=.FALSE.,IERR=ierr)
!
END IF
!
CALL mp_bcast( ierr, root, world_comm )
CALL errore( 'pdep_db', 'cannot open dbs_eigenvalues.xml file for writing', ierr )
!
IF ( mpime == root ) THEN
! !
CALL json%add('pdep.ndim', n_pdep_eigen ) CALL iotk_write_begin( iunout, "EIGENVALUES" )
CALL json%add('pdep.ev' , ev( 1:n_pdep_eigen ) ) CALL iotk_write_dat( iunout, "ndim", n_pdep_eigen )
CALL iotk_write_dat( iunout, "ev", ev(1:n_pdep_eigen))
CALL iotk_write_end( iunout, "EIGENVALUES" )
! !
OPEN(UNIT=4000,FILE=TRIM(ADJUSTL(wstat_save_dir))//"/pdep_db.json",IOSTAT=ierr) ! ... close XML descriptor
CALL json%print_file( 4000 )
CLOSE( 4000, IOSTAT=ierr )
! !
CALL json%destroy() CALL iotk_close_write( iunout )
! !
ENDIF END IF
! !
! 3) CREATE THE EIGENVECTOR FILES ! 3) CREATE THE EIGENVECTOR FILES
! !
...@@ -184,7 +194,6 @@ MODULE pdep_db ...@@ -184,7 +194,6 @@ MODULE pdep_db
INTEGER :: tmp_n_pdep_eigen INTEGER :: tmp_n_pdep_eigen
INTEGER :: dime, iun, global_j, local_j INTEGER :: dime, iun, global_j, local_j
REAL(DP),ALLOCATABLE :: tmp_ev(:) REAL(DP),ALLOCATABLE :: tmp_ev(:)
TYPE(json_file) :: json
! !
! MPI BARRIER ! MPI BARRIER
! !
...@@ -198,122 +207,84 @@ MODULE pdep_db ...@@ -198,122 +207,84 @@ MODULE pdep_db
! !
! ... the main db directory ! ... the main db directory
! !
!dirname = TRIM( tmp_dir ) // TRIM( west_prefix ) // '.wstat.save' dirname = TRIM( tmp_dir ) // TRIM( west_prefix ) // '.wstat.save'
! !
ierr = 0 ! 1) READ THE INPUT FILE
!
ierr = 0
! !
IF ( mpime==root ) THEN IF ( mpime==root ) THEN
! !
CALL json%initialize() ! ... open XML descriptor
! !
CALL json%load_file(TRIM(ADJUSTL(wstat_save_dir))//"/pdep_db.json") CALL iotk_free_unit( iun, ierr )
CALL iotk_open_read( iun, FILE = TRIM( dirname ) // '/' // TRIM( 'input-file.xml' ), IERR = ierr )
! !
CALL json%get('pdep.ndim', dime ) ENDIF
!
CALL mp_bcast( ierr, root, world_comm )
IF ( ierr /=0 ) CALL errore( 'pdep_db', 'cannot open input-file.xml file for reading', ierr )
!
IF ( mpime==root ) THEN
! !
ENDIF CALL iotk_scan_begin( iun, "WSTAT_CONTROL" )
CALL iotk_scan_dat( iun, "n_pdep_eigen" , tmp_n_pdep_eigen)
CALL iotk_scan_end( iun, "WSTAT_CONTROL" )
!
! ... close XML descriptor
!
CALL iotk_close_read( iun )
!
ENDIF
!
CALL mp_bcast( tmp_n_pdep_eigen, root, world_comm )
! !
CALL mp_bcast( tmp_n_pdep_eigen, root, world_comm ) ! In case nglob_to_be_read is 0, overwrite it with the read value
! !
IF (nglob_to_be_read==0) THEN IF (nglob_to_be_read==0) THEN
n_eigen_to_get = dime n_eigen_to_get = tmp_n_pdep_eigen
n_pdep_eigen = dime n_pdep_eigen=tmp_n_pdep_eigen
ELSE ELSE
n_eigen_to_get = MIN(dime,nglob_to_be_read) n_eigen_to_get = MIN(tmp_n_pdep_eigen,nglob_to_be_read)
ENDIF ENDIF
! !
! 2) READ THE EIGENVALUES FILE
!
IF(.NOT.ALLOCATED(ev)) ALLOCATE(ev(n_eigen_to_get)) IF(.NOT.ALLOCATED(ev)) ALLOCATE(ev(n_eigen_to_get))
! !
ierr = 0
!
IF ( mpime==root ) THEN IF ( mpime==root ) THEN
! !
! ... open XML descriptor
!
CALL iotk_free_unit( iun, ierr )
CALL iotk_open_read( iun, FILE = TRIM( dirname ) // '/' // TRIM( 'dbs_eigenvalues.xml' ), IERR = ierr )
!
ENDIF
!
CALL mp_bcast( ierr, root, world_comm )
!
IF ( ierr /=0 ) CALL errore( 'pdep_db', 'cannot open dbs_eigenvalues.xml file for reading', ierr )
!
IF ( mpime==root ) THEN
!
CALL iotk_scan_begin( iun, "EIGENVALUES" )
CALL iotk_scan_dat( iun, "ndim" , dime)
ALLOCATE(tmp_ev(dime)) ALLOCATE(tmp_ev(dime))
CALL json%get('pdep.ev' , tmp_ev( 1:dime ) ) CALL iotk_scan_dat( iun, "ev" , tmp_ev)
CALL iotk_scan_end( iun, "EIGENVALUES" )
!
! ... close XML descriptor
!
CALL iotk_close_read( iun )
ev(1:nglob_to_be_read) = tmp_ev(1:nglob_to_be_read) ev(1:nglob_to_be_read) = tmp_ev(1:nglob_to_be_read)
DEALLOCATE(tmp_ev) DEALLOCATE(tmp_ev)
! !
CALL json%destroy()
!
ENDIF ENDIF
! !
CALL mp_bcast( ev, root, world_comm ) CALL mp_bcast( ev, root, world_comm )
! !
! !
! ! 1) READ THE INPUT FILE
! !
! ierr = 0
! !
! IF ( mpime==root ) THEN
! !
! ! ... open XML descriptor
! !
! CALL iotk_free_unit( iun, ierr )
! CALL iotk_open_read( iun, FILE = TRIM( dirname ) // '/' // TRIM( 'input-file.xml' ), IERR = ierr )
! !
! ENDIF
! !
! CALL mp_bcast( ierr, root, world_comm )
! IF ( ierr /=0 ) CALL errore( 'pdep_db', 'cannot open input-file.xml file for reading', ierr )
! !
! IF ( mpime==root ) THEN
! !
! CALL iotk_scan_begin( iun, "WSTAT_CONTROL" )
! CALL iotk_scan_dat( iun, "n_pdep_eigen" , tmp_n_pdep_eigen)
! CALL iotk_scan_end( iun, "WSTAT_CONTROL" )
! !
! ! ... close XML descriptor
! !
! CALL iotk_close_read( iun )
! !
! ENDIF
! !
! CALL mp_bcast( tmp_n_pdep_eigen, root, world_comm )
! !
! ! In case nglob_to_be_read is 0, overwrite it with the read value
! !
! IF (nglob_to_be_read==0) THEN
! n_eigen_to_get = tmp_n_pdep_eigen
! n_pdep_eigen=tmp_n_pdep_eigen
! ELSE
! n_eigen_to_get = MIN(tmp_n_pdep_eigen,nglob_to_be_read)
! ENDIF
! !
! ! 2) READ THE EIGENVALUES FILE
! !
! IF(.NOT.ALLOCATED(ev)) ALLOCATE(ev(n_eigen_to_get))
! !
! ierr = 0
! !
! IF ( mpime==root ) THEN
! !
! ! ... open XML descriptor
! !
! CALL iotk_free_unit( iun, ierr )
! CALL iotk_open_read( iun, FILE = TRIM( dirname ) // '/' // TRIM( 'dbs_eigenvalues.xml' ), IERR = ierr )
! !
! ENDIF
! !
! CALL mp_bcast( ierr, root, world_comm )
! !
! IF ( ierr /=0 ) CALL errore( 'pdep_db', 'cannot open dbs_eigenvalues.xml file for reading', ierr )
! !
! IF ( mpime==root ) THEN
! !
! CALL iotk_scan_begin( iun, "EIGENVALUES" )
! CALL iotk_scan_dat( iun, "ndim" , dime)
! ALLOCATE(tmp_ev(dime))
! CALL iotk_scan_dat( iun, "ev" , tmp_ev)
! CALL iotk_scan_end( iun, "EIGENVALUES" )
! !
! ! ... close XML descriptor
! !
! CALL iotk_close_read( iun )
! ev(1:nglob_to_be_read) = tmp_ev(1:nglob_to_be_read)
! DEALLOCATE(tmp_ev)
! !
! ENDIF
! !
! CALL mp_bcast( ev, root, world_comm )
!
! 3) READ THE EIGENVECTOR FILES ! 3) READ THE EIGENVECTOR FILES
! !
IF(.NOT.ALLOCATED(dvg)) THEN IF(.NOT.ALLOCATED(dvg)) THEN
......
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