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

Committing part of the stuff.

parent fe3cc00d
......@@ -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/Json \
$(MOD_FLAG)../Modules \
$(MOD_FLAG)../Tools \
$(MOD_FLAG)../FFT_kernel \
......@@ -26,7 +27,7 @@ wfreq_io.o \
wfreq_restart.o
PWOBJS = ../../PW/src/libpw.a
QEMODS = ../../Modules/libqemod.a ../../FFTXlib/libqefft.a ../../LAXlib/libqela.a
QEMODS = ../../Modules/libqemod.a ../../FFTXlib/libqefft.a ../../LAXlib/libqela.a ../Libraries/Json/libjson.a
TLDEPS= bindir mods libs pw
......
......@@ -14,9 +14,9 @@
MODULE pdep_db
!----------------------------------------------------------------------------
!
USE iotk_module
USE kinds, ONLY : DP
USE io_files, ONLY : tmp_dir
USE westcom, ONLY : wstat_save_dir
USE json_module, ONLY : json_file
!
IMPLICIT NONE
!
......@@ -32,14 +32,13 @@ MODULE pdep_db
SUBROUTINE pdep_db_write( )
!------------------------------------------------------------------------
!
USE xml_io_base, ONLY : create_directory
USE mp, ONLY : mp_bcast,mp_barrier
USE mp_world, ONLY : mpime,root,world_comm
USE mp_global, ONLY : my_image_id
USE io_global, ONLY : stdout
USE westcom, ONLY : wstat_calculation,n_pdep_times,n_pdep_eigen,n_pdep_maxiter,n_dfpt_maxiter, &
USE westcom, ONLY : n_pdep_eigen,n_dfpt_maxiter, &
& 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_dirname,trev_pdep_rel, &
& tr2_dfpt,l_deflate,l_kinetic_only,ev,dvg,west_prefix,wstat_save_dir,trev_pdep_rel, &
& l_minimize_exx_if_active,l_use_ecutrho
!USE eig_distribute, ONLY : local_npert,pdep_distr_l2g
USE pdep_io, ONLY : pdep_merge_and_write_G
......@@ -55,6 +54,7 @@ MODULE pdep_db
CHARACTER(20),EXTERNAL :: human_readable_time
INTEGER :: iunout,global_j,local_j
INTEGER :: ierr
TYPE(json_file) :: json
!
! MPI BARRIER
!
......@@ -64,72 +64,62 @@ MODULE pdep_db
!
CALL start_clock('pdep_db')
time_spent(1)=get_clock('pdep_db')
!
! 1) CREATE THE INPUT FILE
!
IF ( mpime == root ) THEN
!
! ... open XML descriptor
!
CALL iotk_free_unit( iunout, ierr )
CALL iotk_open_write( iunout, FILE = TRIM( wstat_dirname ) // '/' // TRIM("input-file.xml") , BINARY=.FALSE.,IERR=ierr )
!
END IF
!
CALL mp_bcast( ierr, root, world_comm )
CALL errore( 'pdep_db', 'cannot open input-file.xml for writing', ierr )
!
IF ( mpime == root ) THEN
!
CALL iotk_write_begin( iunout, "WSTAT_CONTROL" )
!
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_times" , n_pdep_times)
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_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_rel" , trev_pdep_rel)
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_minimize_exx_if_active" , l_minimize_exx_if_active)
CALL iotk_write_dat( iunout, "l_use_ecutrho" , l_use_ecutrho)
!
CALL iotk_write_end( iunout, "WSTAT_CONTROL" )
!
! ... close XML descriptor
!
CALL iotk_close_write( iunout )
!
END IF
!!
!! 1) CREATE THE INPUT FILE
!!
!IF ( mpime == root ) THEN
! !
! ! ... open XML descriptor
! !
! CALL iotk_free_unit( iunout, ierr )
! CALL iotk_open_write( iunout, FILE = TRIM( wstat_save_dir ) // '/' // TRIM("input-file.xml") , BINARY=.FALSE.,IERR=ierr )
! !
!END IF
!!
!CALL mp_bcast( ierr, root, world_comm )
!CALL errore( 'pdep_db', 'cannot open input-file.xml for writing', ierr )
!!
!IF ( mpime == root ) THEN
! !
! CALL iotk_write_begin( iunout, "WSTAT_CONTROL" )
! !
! 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_times" , n_pdep_times)
! 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_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_rel" , trev_pdep_rel)
! 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_minimize_exx_if_active" , l_minimize_exx_if_active)
! CALL iotk_write_dat( iunout, "l_use_ecutrho" , l_use_ecutrho)
! !
! CALL iotk_write_end( iunout, "WSTAT_CONTROL" )
! !
! ! ... close XML descriptor
! !
! CALL iotk_close_write( iunout )
! !
!END IF
!
! 2) CREATE THE EIGENVALUE FILE
!
IF ( mpime == root ) THEN
!
! ... open XML descriptor
!
CALL iotk_free_unit( iunout, ierr )
CALL iotk_open_write( iunout, FILE = TRIM( wstat_dirname ) // '/' // TRIM("dbs_eigenvalues.xml"),BINARY=.FALSE.,IERR=ierr)
!
END IF
IF( mpime == root ) THEN
!
CALL mp_bcast( ierr, root, world_comm )
CALL errore( 'pdep_db', 'cannot open dbs_eigenvalues.xml file for writing', ierr )
CALL json%initialize()
!
IF ( mpime == root ) THEN
CALL json%add('pdep.ndim', n_pdep_eigen )
CALL json%add('pdep.ev' , ev( 1:n_pdep_eigen ) )
!
CALL iotk_write_begin( iunout, "EIGENVALUES" )
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)
CALL json%print_file( 4000 )
CLOSE( 4000, IOSTAT=ierr )
!
! ... close XML descriptor
CALL json%destroy()
!
CALL iotk_close_write( iunout )
!
END IF
ENDIF
!
! 3) CREATE THE EIGENVECTOR FILES
!
......@@ -141,7 +131,7 @@ MODULE pdep_db
WRITE(my_label,'(i6.6)') global_j
IF(global_j>n_pdep_eigen) CYCLE
!
fname = TRIM( wstat_dirname ) // "/E"//TRIM(ADJUSTL(my_label))//".dat"
fname = TRIM( wstat_save_dir ) // "/E"//TRIM(ADJUSTL(my_label))//".dat"
CALL pdep_merge_and_write_G(fname,dvg(:,local_j))
!
ENDDO
......@@ -158,7 +148,7 @@ MODULE pdep_db
WRITE(stdout,'( 5x," ")')
CALL io_push_bar()
WRITE(stdout, "(5x, 'Database written in ',a20)") human_readable_time(time_spent(2)-time_spent(1))
WRITE(stdout, "(5x, 'In location : ',a)") TRIM( wstat_dirname )
WRITE(stdout, "(5x, 'In location : ',a)") TRIM( wstat_save_dir )
CALL io_push_bar()
!
END SUBROUTINE
......@@ -194,6 +184,7 @@ MODULE pdep_db
INTEGER :: tmp_n_pdep_eigen
INTEGER :: dime, iun, global_j, local_j
REAL(DP),ALLOCATABLE :: tmp_ev(:)
TYPE(json_file) :: json
!
! MPI BARRIER
!
......@@ -207,84 +198,122 @@ MODULE pdep_db
!
! ... the main db directory
!
dirname = TRIM( tmp_dir ) // TRIM( west_prefix ) // '.wstat.save'
!
! 1) READ THE INPUT FILE
!dirname = TRIM( tmp_dir ) // TRIM( west_prefix ) // '.wstat.save'
!
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" )
CALL json%initialize()
!
! ... close XML descriptor
CALL json%load_file(TRIM(ADJUSTL(wstat_save_dir))//"/pdep_db.json")
!
CALL iotk_close_read( iun )
CALL json%get('pdep.ndim', dime )
!
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
n_eigen_to_get = dime
n_pdep_eigen = dime
ELSE
n_eigen_to_get = MIN(tmp_n_pdep_eigen,nglob_to_be_read)
n_eigen_to_get = MIN(dime,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 )
CALL json%get('pdep.ev' , tmp_ev( 1:dime ) )
ev(1:nglob_to_be_read) = tmp_ev(1:nglob_to_be_read)
DEALLOCATE(tmp_ev)
!
CALL json%destroy()
!
ENDIF
!
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
!
IF(.NOT.ALLOCATED(dvg)) THEN
......
......@@ -30,7 +30,7 @@ MODULE write_xml
USE mp_world, ONLY : mpime,root,world_comm
USE io_global, ONLY : stdout
USE io_push, ONLY : io_push_bar
USE westcom, ONLY : wstat_dirname, l_is_wstat_converged, ev
USE westcom, ONLY : wstat_save_dir, l_is_wstat_converged, ev
USE westcom, ONLY : qe_prefix, west_prefix, outdir
USE westcom, ONLY : wstat_calculation, n_pdep_eigen, n_pdep_times, n_pdep_maxiter, n_dfpt_maxiter, &
& n_pdep_read_from_file, trev_pdep, trev_pdep_rel, tr2_dfpt, l_minimize_exx_if_active, &
......@@ -85,7 +85,7 @@ MODULE write_xml
!
CALL iotk_free_unit( iunout, ierr )
!
CALL iotk_open_write( iunout, FILE = TRIM( wstat_dirname ) // '/' // TRIM("wstat.xml") , &
CALL iotk_open_write( iunout, FILE = TRIM( wstat_save_dir ) // '/' // TRIM("wstat.xml") , &
& ROOT="wstat",BINARY=.FALSE.,SKIP_HEAD=.TRUE.,IERR=ierr )
!
END IF
......@@ -206,7 +206,7 @@ MODULE write_xml
WRITE(stdout,'( 5x," ")')
CALL io_push_bar()
WRITE(stdout, "(5x, 'wstat.xml file written in ',a20)") human_readable_time(time_spent(2)-time_spent(1))
WRITE(stdout, "(5x, 'In location : ',a)") TRIM( wstat_dirname )
WRITE(stdout, "(5x, 'In location : ',a)") TRIM( wstat_save_dir )
CALL io_push_bar()
!
END SUBROUTINE
......
......@@ -100,7 +100,10 @@ MODULE wstat_center
! Common workspace
!
COMPLEX(DP) :: alphapv_dfpt
CHARACTER(LEN=256) :: wstat_dirname
!CHARACTER(LEN=256) :: wstat_dirname
CHARACTER(LEN=256) :: wstat_save_dir
CHARACTER(LEN=256) :: wstat_output_dir
CHARACTER(LEN=256) :: wstat_restart_dir
LOGICAL :: l_is_wstat_converged
!
END MODULE
......
......@@ -15,6 +15,7 @@ exx_go.o \
exx_ungo.o \
report_dynamical_memory.o \
io_push.o \
set_dirs.o \
do_setup.o \
linear_algebra_kernel.o \
human_readable_time.o \
......
......@@ -49,6 +49,7 @@ SUBROUTINE do_setup
CALL init_pw_arrays(nbnd)
CALL set_iks_l2g()
!
CALL set_dirs()
!
IF ( lsda ) THEN
IF ( INT( nelup ) == 0 .AND. INT( neldw ) == 0 ) THEN
......
!
! Copyright (C) 2015-2016 M. Govoni
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
! This file is part of WEST.
!
! Contributors to this file:
! Marco Govoni
!
!-----------------------------------------------------------------------
SUBROUTINE set_dirs( )
!-----------------------------------------------------------------------
!
USE io_files, ONLY : tmp_dir
USE westcom, ONLY : west_prefix, wstat_save_dir, wstat_output_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
......@@ -1064,9 +1064,9 @@ END SUBROUTINE
!
SUBROUTINE output_a_report(iteration)
!
USE json_module
USE json_module, ONLY : json_file
USE kinds, ONLY : DP
USE westcom, ONLY : n_pdep_eigen,ev,conv
USE westcom, ONLY : n_pdep_eigen,ev,conv,wstat_output_dir
USE west_io , ONLY : serial_table_output
USE mp_world, ONLY : mpime,root
!
......@@ -1076,13 +1076,20 @@ SUBROUTINE output_a_report(iteration)
INTEGER,INTENT(IN) :: iteration
CHARACTER(LEN=9) :: pref
INTEGER :: ip, ierr
REAL(DP) :: out_tab(n_pdep_eigen,3)
!REAL(DP) :: out_tab(n_pdep_eigen,3)
!
INTEGER,ALLOCATABLE :: ipert(:), converged(:)
!
ALLOCATE( ipert(n_pdep_eigen), converged(n_pdep_eigen) )
!
converged = 0
DO ip=1,n_pdep_eigen
out_tab(ip,1) = REAL(ip,DP)
out_tab(ip,2) = ev(ip)
out_tab(ip,3) = 0._DP
IF(conv(ip)) out_tab(ip,3) = 1._DP
!out_tab(ip,1) = REAL(ip,DP)
ipert(ip) = ip
!out_tab(ip,2) = ev(ip)
!out_tab(ip,3) = 0._DP
!IF(conv(ip)) out_tab(ip,3) = 1._DP
IF(conv(ip)) converged(ip) = 1
ENDDO
IF(iteration>=0) THEN
WRITE(pref,"('itr_',i5.5)") iteration
......@@ -1095,11 +1102,11 @@ SUBROUTINE output_a_report(iteration)
!
CALL json%initialize()
!
CALL json%add('output.iprt', 1 )
CALL json%add('output.eigenvalue', 45.d0 )
CALL json%add('output.conv', 30.d0 )
CALL json%add('output.iprt', ipert ( 1:n_pdep_eigen ) )
CALL json%add('output.eigenvalue', ev ( 1:n_pdep_eigen ) )
CALL json%add('output.conv', converged ( 1:n_pdep_eigen ) )
!
OPEN(UNIT=4000,FILE="o-wstat."//TRIM(ADJUSTL(pref))//".tab",IOSTAT=ierr)
OPEN(UNIT=4000,FILE=TRIM(ADJUSTL(wstat_output_dir))//"/o-wstat."//TRIM(ADJUSTL(pref))//".json",IOSTAT=ierr)
CALL json%print_file( 4000 )
CLOSE( 4000, IOSTAT=ierr )
!
......@@ -1107,6 +1114,8 @@ SUBROUTINE output_a_report(iteration)
!
ENDIF
!
DEALLOCATE( ipert, converged )
!
END SUBROUTINE
!
! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......
......@@ -14,8 +14,9 @@
SUBROUTINE wstat_setup
!-----------------------------------------------------------------------
!
USE westcom, ONLY : alphapv_dfpt,npwq0,sqvc,wstat_dirname,west_prefix,&
& n_pdep_basis,n_pdep_eigen,n_pdep_times,isz,l_use_ecutrho
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
USE mp, ONLY : mp_max
USE mp_global, ONLY : intra_bgrp_comm
USE pwcom, ONLY : npw,npwx
......@@ -46,8 +47,10 @@ SUBROUTINE wstat_setup
!
CALL set_nbndocc()
!
wstat_dirname = TRIM( tmp_dir ) // TRIM( west_prefix ) // '.wstat.save'
CALL my_mkdir( wstat_dirname )
!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