Commit 0eb18278 authored by Marco Govoni's avatar Marco Govoni
Browse files

Modularized fetch_input

parent 73ccb78b
...@@ -34,7 +34,7 @@ SUBROUTINE fetch_input( num_drivers, driver, verbose ) ...@@ -34,7 +34,7 @@ SUBROUTINE fetch_input( num_drivers, driver, verbose )
! !
! Workspace ! Workspace
! !
type(json_file) :: json TYPE(json_file) :: json
INTEGER :: i INTEGER :: i
INTEGER :: iiarg, nargs INTEGER :: iiarg, nargs
INTEGER :: numsp INTEGER :: numsp
...@@ -349,11 +349,6 @@ SUBROUTINE fetch_input( num_drivers, driver, verbose ) ...@@ -349,11 +349,6 @@ SUBROUTINE fetch_input( num_drivers, driver, verbose )
! REPORT ! REPORT
! !
IF ( verbose ) THEN IF ( verbose ) THEN
!
IF( mpime == root ) THEN
CALL json%initialize()
CALL json%load_file(filename=TRIM(logfile))
ENDIF
! !
IF ( ANY(driver(:)==1) ) THEN IF ( ANY(driver(:)==1) ) THEN
! !
...@@ -368,12 +363,6 @@ SUBROUTINE fetch_input( num_drivers, driver, verbose ) ...@@ -368,12 +363,6 @@ SUBROUTINE fetch_input( num_drivers, driver, verbose )
! !
CALL io_push_bar() CALL io_push_bar()
! !
IF( mpime == root ) THEN
CALL json%add('input.input_west.qe_prefix',TRIM(qe_prefix))
CALL json%add('input.input_west.west_prefix',TRIM(west_prefix))
CALL json%add('input.input_west.outdir',TRIM(outdir))
ENDIF
!
ENDIF ENDIF
! !
IF ( ANY(driver(:)==2) ) THEN IF ( ANY(driver(:)==2) ) THEN
...@@ -398,21 +387,6 @@ SUBROUTINE fetch_input( num_drivers, driver, verbose ) ...@@ -398,21 +387,6 @@ SUBROUTINE fetch_input( num_drivers, driver, verbose )
! !
CALL io_push_bar() CALL io_push_bar()
! !
IF( mpime == root ) THEN
CALL json%add('input.wstat_control.wstat_calculation',TRIM(wstat_calculation))
CALL json%add('input.wstat_control.n_pdep_eigen',n_pdep_eigen)
CALL json%add('input.wstat_control.n_pdep_times',n_pdep_times)
CALL json%add('input.wstat_control.n_pdep_maxiter',n_pdep_maxiter)
CALL json%add('input.wstat_control.n_dfpt_maxiter',n_dfpt_maxiter)
CALL json%add('input.wstat_control.n_pdep_read_from_file',n_pdep_read_from_file)
CALL json%add('input.wstat_control.trev_pdep',trev_pdep)
CALL json%add('input.wstat_control.trev_pdep_rel',trev_pdep_rel)
CALL json%add('input.wstat_control.tr2_dfpt',tr2_dfpt)
CALL json%add('input.wstat_control.l_kinetic_only',l_kinetic_only)
CALL json%add('input.wstat_control.l_minimize_exx_if_active',l_minimize_exx_if_active)
CALL json%add('input.wstat_control.l_use_ecutrho',l_use_ecutrho)
ENDIF
!
ENDIF ENDIF
! !
IF ( ANY(driver(:)==3) ) THEN IF ( ANY(driver(:)==3) ) THEN
...@@ -445,27 +419,6 @@ SUBROUTINE fetch_input( num_drivers, driver, verbose ) ...@@ -445,27 +419,6 @@ SUBROUTINE fetch_input( num_drivers, driver, verbose )
! !
CALL io_push_bar() CALL io_push_bar()
! !
IF( mpime == root ) THEN
CALL json%add('input.wfreq_control.wfreq_calculation',TRIM(wfreq_calculation))
CALL json%add('input.wfreq_control.n_pdep_eigen_to_use',n_pdep_eigen_to_use)
CALL json%add('input.wfreq_control.qp_bandrange',qp_bandrange)
CALL json%add('input.wfreq_control.macropol_calculation',macropol_calculation)
CALL json%add('input.wfreq_control.n_lanczos',n_lanczos)
CALL json%add('input.wfreq_control.n_imfreq',n_imfreq)
CALL json%add('input.wfreq_control.n_refreq',n_refreq)
CALL json%add('input.wfreq_control.ecut_imfreq',ecut_imfreq)
CALL json%add('input.wfreq_control.ecut_refreq',ecut_refreq)
CALL json%add('input.wfreq_control.wfreq_eta',wfreq_eta)
CALL json%add('input.wfreq_control.n_secant_maxiter',n_secant_maxiter)
CALL json%add('input.wfreq_control.trev_secant',trev_secant)
CALL json%add('input.wfreq_control.l_enable_lanczos',l_enable_lanczos)
CALL json%add('input.wfreq_control.l_enable_gwetot',l_enable_gwetot)
CALL json%add('input.wfreq_control.div_kind_hf',div_kind_hf)
CALL json%add('input.wfreq_control.o_restart_time',o_restart_time)
CALL json%add('input.wfreq_control.ecut_spectralf',ecut_spectralf)
CALL json%add('input.wfreq_control.n_spectralf',n_spectralf)
ENDIF
!
ENDIF ENDIF
! !
IF ( ANY(driver(:)==4) ) THEN IF ( ANY(driver(:)==4) ) THEN
...@@ -490,7 +443,101 @@ SUBROUTINE fetch_input( num_drivers, driver, verbose ) ...@@ -490,7 +443,101 @@ SUBROUTINE fetch_input( num_drivers, driver, verbose )
! !
CALL io_push_bar() CALL io_push_bar()
! !
ENDIF
!
IF( mpime == root ) THEN IF( mpime == root ) THEN
!
CALL json%initialize()
CALL json%load_file(filename=TRIM(logfile))
!
CALL add_intput_parameters_to_json_file( num_drivers, driver, json )
!
OPEN( NEWUNIT=iunit, FILE=TRIM(logfile) )
CALL json%print_file( iunit )
CLOSE( iunit )
CALL json%destroy()
ENDIF
!
ENDIF
!
CALL stop_clock('fetch_input')
!
END SUBROUTINE
!
!-----------------------------------------------------------------------
SUBROUTINE add_intput_parameters_to_json_file( num_drivers, driver, json )
!-----------------------------------------------------------------------
!
USE json_module, ONLY : json_file
USE pwcom
USE westcom
USE io_files, ONLY : tmp_dir, prefix
USE io_global, ONLY : stdout
USE mp, ONLY : mp_bcast
USE mp_world, ONLY : mpime,root,world_comm
USE mp_global, ONLY : nimage
USE io_push, ONLY : io_push_title,io_push_value,io_push_bar,io_push_es0,io_push_c256
!
IMPLICIT NONE
!
! I/O
!
INTEGER, INTENT(IN) :: num_drivers
INTEGER, INTENT(IN) :: driver(num_drivers)
TYPE(json_file), INTENT(INOUT) :: json
!
IF ( mpime == root ) THEN
!
IF ( ANY(driver(:)==1) ) THEN
!
CALL json%add('input.input_west.qe_prefix',TRIM(qe_prefix))
CALL json%add('input.input_west.west_prefix',TRIM(west_prefix))
CALL json%add('input.input_west.outdir',TRIM(outdir))
!
ENDIF
!
IF ( ANY(driver(:)==2) ) THEN
!
CALL json%add('input.wstat_control.wstat_calculation',TRIM(wstat_calculation))
CALL json%add('input.wstat_control.n_pdep_eigen',n_pdep_eigen)
CALL json%add('input.wstat_control.n_pdep_times',n_pdep_times)
CALL json%add('input.wstat_control.n_pdep_maxiter',n_pdep_maxiter)
CALL json%add('input.wstat_control.n_dfpt_maxiter',n_dfpt_maxiter)
CALL json%add('input.wstat_control.n_pdep_read_from_file',n_pdep_read_from_file)
CALL json%add('input.wstat_control.trev_pdep',trev_pdep)
CALL json%add('input.wstat_control.trev_pdep_rel',trev_pdep_rel)
CALL json%add('input.wstat_control.tr2_dfpt',tr2_dfpt)
CALL json%add('input.wstat_control.l_kinetic_only',l_kinetic_only)
CALL json%add('input.wstat_control.l_minimize_exx_if_active',l_minimize_exx_if_active)
CALL json%add('input.wstat_control.l_use_ecutrho',l_use_ecutrho)
!
ENDIF
!
IF ( ANY(driver(:)==3) ) THEN
!
CALL json%add('input.wfreq_control.wfreq_calculation',TRIM(wfreq_calculation))
CALL json%add('input.wfreq_control.n_pdep_eigen_to_use',n_pdep_eigen_to_use)
CALL json%add('input.wfreq_control.qp_bandrange',qp_bandrange)
CALL json%add('input.wfreq_control.macropol_calculation',macropol_calculation)
CALL json%add('input.wfreq_control.n_lanczos',n_lanczos)
CALL json%add('input.wfreq_control.n_imfreq',n_imfreq)
CALL json%add('input.wfreq_control.n_refreq',n_refreq)
CALL json%add('input.wfreq_control.ecut_imfreq',ecut_imfreq)
CALL json%add('input.wfreq_control.ecut_refreq',ecut_refreq)
CALL json%add('input.wfreq_control.wfreq_eta',wfreq_eta)
CALL json%add('input.wfreq_control.n_secant_maxiter',n_secant_maxiter)
CALL json%add('input.wfreq_control.trev_secant',trev_secant)
CALL json%add('input.wfreq_control.l_enable_lanczos',l_enable_lanczos)
CALL json%add('input.wfreq_control.l_enable_gwetot',l_enable_gwetot)
CALL json%add('input.wfreq_control.div_kind_hf',div_kind_hf)
CALL json%add('input.wfreq_control.o_restart_time',o_restart_time)
CALL json%add('input.wfreq_control.ecut_spectralf',ecut_spectralf)
CALL json%add('input.wfreq_control.n_spectralf',n_spectralf)
!
ENDIF
!
IF ( ANY(driver(:)==4) ) THEN
!
CALL json%add('input.westpp_control.westpp_calculation',TRIM(westpp_calculation)) CALL json%add('input.westpp_control.westpp_calculation',TRIM(westpp_calculation))
CALL json%add('input.westpp_control.westpp_range',westpp_range) CALL json%add('input.westpp_control.westpp_range',westpp_range)
CALL json%add('input.westpp_control.westpp_format',TRIM(westpp_format)) CALL json%add('input.westpp_control.westpp_format',TRIM(westpp_format))
...@@ -500,19 +547,9 @@ SUBROUTINE fetch_input( num_drivers, driver, verbose ) ...@@ -500,19 +547,9 @@ SUBROUTINE fetch_input( num_drivers, driver, verbose )
CALL json%add('input.westpp_control.westpp_nr',westpp_nr) CALL json%add('input.westpp_control.westpp_nr',westpp_nr)
CALL json%add('input.westpp_control.westpp_rmax',westpp_rmax) CALL json%add('input.westpp_control.westpp_rmax',westpp_rmax)
CALL json%add('input.westpp_control.westpp_epsinfty',westpp_epsinfty) CALL json%add('input.westpp_control.westpp_epsinfty',westpp_epsinfty)
ENDIF
! !
ENDIF ENDIF
! !
IF( mpime == root ) THEN
OPEN( NEWUNIT=iunit, FILE=TRIM(logfile) )
CALL json%print_file( iunit )
CLOSE( iunit )
CALL json%destroy()
ENDIF ENDIF
! !
ENDIF
!
CALL stop_clock('fetch_input')
!
END SUBROUTINE END SUBROUTINE
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