From 5f6a8aea1f1cdfcbce9fbc6a32463863dd5eafcb Mon Sep 17 00:00:00 2001 From: Ravindra Shinde Date: Wed, 2 Oct 2024 11:06:26 +0200 Subject: [PATCH] second batch of documentation (#297) --- src/module/m_common.f90 | 32 ++++++++-- src/module/m_constant.f90 | 11 ++++ src/module/m_control.f90 | 129 +++++++++++++++++++++++++++++++------- src/module/m_qmckl.F90 | 10 +++ src/module/m_timer.f90 | 21 +++++-- src/module/m_vmc.f90 | 52 ++++++++++++++- 6 files changed, 222 insertions(+), 33 deletions(-) diff --git a/src/module/m_common.f90 b/src/module/m_common.f90 index 0658f804..ec571e82 100644 --- a/src/module/m_common.f90 +++ b/src/module/m_common.f90 @@ -37,7 +37,7 @@ subroutine allocate_Bloc() if (.not. allocated(tildem)) allocate (tildem(nelec, norb_tot, 2, MSTATES)) if (.not. allocated(tildemkin)) allocate (tildemkin(nelec, norb_tot, 2, MSTATES)) if (.not. allocated(xmat)) allocate (xmat(nelec**2, 2, MSTATES)) - if (.not. allocated(xmatkin)) allocate (xmatkin(nelec**2, 2, MSTATES)) + if (.not. allocated(xmatkin)) allocate (xmatkin(nelec**2, 2, MSTATES)) if (.not. allocated(b_da)) allocate (b_da(3, nelec, norb_tot, ncent_tot)) if (.not. allocated(b_dj)) allocate (b_dj(norb_tot, nelec, nparmj, MSTATES)) @@ -127,7 +127,7 @@ subroutine deallocate_distance_mod() if (allocated(rvec_en)) deallocate (rvec_en) if (allocated(r_en)) deallocate (r_en) if (allocated(rvec_en)) deallocate (rvec_ee) - if (allocated(r_ee)) deallocate (r_ee) + if (allocated(r_ee)) deallocate (r_ee) end subroutine deallocate_distance_mod end module distance_mod @@ -188,16 +188,22 @@ module embed save end module embed +!> Module containing the pseudopotential or effective core potential information module gauss_ecp - !> only used in read_gauss .... - !> Arguments: ecp_coef, ecp_exponent, necp_power, necp_term use precision_kinds, only: dp implicit none + !> ECP coefficients real(dp), dimension(:, :, :), allocatable :: ecp_coef !(MGAUSS,MPS_L,MCTYPE) + + !> ECP exponents real(dp), dimension(:, :, :), allocatable :: ecp_exponent !(MGAUSS,MPS_L,MCTYPE) + + !> ECP power integer, dimension(:, :, :), allocatable :: necp_power !(MGAUSS,MPS_L,MCTYPE) + + !> ECP term integer, dimension(:, :), allocatable :: necp_term !(MPS_L,MCTYPE) private @@ -205,19 +211,37 @@ module gauss_ecp public :: allocate_gauss_ecp, deallocate_gauss_ecp save contains + !> Allocate the ECP arrays subroutine allocate_gauss_ecp() use pseudo_mod, only: MPS_L, MGAUSS use system, only: nctype_tot + + !> Allocate the ECP coefficients if (.not. allocated(ecp_coef)) allocate (ecp_coef(MGAUSS, MPS_L, nctype_tot)) + + !> Allocate the ECP exponents if (.not. allocated(ecp_exponent)) allocate (ecp_exponent(MGAUSS, MPS_L, nctype_tot)) + + !> Allocate the ECP power if (.not. allocated(necp_power)) allocate (necp_power(MGAUSS, MPS_L, nctype_tot), source=0) + + !> Allocate the ECP term if (.not. allocated(necp_term)) allocate (necp_term(MPS_L, nctype_tot), source=0) end subroutine allocate_gauss_ecp + !> Deallocate the ECP arrays subroutine deallocate_gauss_ecp() + + !> Deallocate the ECP term if (allocated(necp_term)) deallocate (necp_term) + + !> Deallocate the ECP power if (allocated(necp_power)) deallocate (necp_power) + + !> Deallocate the ECP exponents if (allocated(ecp_exponent)) deallocate (ecp_exponent) + + !> Deallocate the ECP coefficients if (allocated(ecp_coef)) deallocate (ecp_coef) end subroutine deallocate_gauss_ecp diff --git a/src/module/m_constant.f90 b/src/module/m_constant.f90 index f3ddbadb..1ba4a49a 100644 --- a/src/module/m_constant.f90 +++ b/src/module/m_constant.f90 @@ -1,19 +1,30 @@ + +!> Module containing esigma and esigmatrial module const use precision_kinds, only: dp implicit none + !> esigma real(dp) :: etrial + + !> esigmatrial real(dp) :: esigmatrial save end module const +!> Module containing physical constants module constants use precision_kinds, only: dp implicit none + !> Plank's constant real(dp), parameter :: hb = 0.5 + + !> Value of Pi real(dp), parameter :: pi = 4.0d0*datan(1.0d0) + + !> Value of 2*Pi real(dp), parameter :: twopi = 8.d0*datan(1.0d0) end module diff --git a/src/module/m_control.f90 b/src/module/m_control.f90 index 3dbdbe63..d876dc2a 100644 --- a/src/module/m_control.f90 +++ b/src/module/m_control.f90 @@ -1,10 +1,14 @@ +!> Module to control the flow of the program module control - !> Arguments: mode implicit none + !> mode of the program character(len=12) :: mode + + !> ipr flag; decides the verbosity of the output integer :: ipr + private public :: mode, ipr, init_control_mode save @@ -17,20 +21,51 @@ end subroutine init_control_mode end module control +!> Module to control the VMC calculation mode +!> @var vmc_idump: Whether to store the dump files at the end of the VMC calculation +!> @var vmc_irstar: Whether to restart the VMC calculation +!> @var vmc_isite: Whether to read the configuration from a file or generate it +!> @var vmc_nconf: Number of configurations to generate +!> @var vmc_nblk: Number of blocks to run +!> @var vmc_nblk_max: Maximum number of blocks to run +!> @var vmc_nblkeq: Number of blocks to equilibrate +!> @var vmc_nconf_new: Number of configurations to generate in the new block +!> @var vmc_nstep: Number of steps to run in a block +!> @var vmc_icharged_atom: Index of the charged atom +!> @var vmc_nblk_ci: Number of blocks to run in the CI calculation module control_vmc - !> Arguments: idump, irstar, isite, nconf, nblk, nblk_max, nblkeq, nconf_new, nstep, - !> icharged_atom, nblk_ci for vmc module + !> Whether to store the dump files at the end of the VMC calculation integer :: vmc_idump + + !> Whether to restart the VMC calculation integer :: vmc_irstar + + !> Whether to read the configuration from a file or generate it integer :: vmc_isite + + !> Number of configurations to generate integer :: vmc_nconf + + !> Number of blocks to run integer :: vmc_nblk + + !> Maximum number of blocks to run integer :: vmc_nblk_max + + !> Number of blocks to equilibrate integer :: vmc_nblkeq + + !> Number of configurations to generate in the new block integer :: vmc_nconf_new + + !> Number of steps to run in a block integer :: vmc_nstep + + !> Index of the charged atom integer :: vmc_icharged_atom + + !> Number of blocks to run in the CI calculation integer :: vmc_nblk_ci private @@ -39,16 +74,41 @@ module control_vmc save end module control_vmc + +!> Module to control the DMC calculation mode +!> @var dmc_idump: Whether to store the dump files at the end of the DMC calculation +!> @var dmc_irstar: Whether to restart the DMC calculation +!> @var dmc_isite: Whether to read the configuration from a file or generate it +!> @var dmc_nconf: Number of configurations to generate +!> @var dmc_nblk: Number of blocks to run +!> @var dmc_nblkeq: Number of blocks to equilibrate +!> @var dmc_nconf_new: Number of configurations to generate in the new block +!> @var dmc_nstep: Number of steps to run in a block + module control_dmc - !> Arguments: idump, irstar, isite, nconf, nblk, nblk_max, nblkeq, nconf_new, nstep, + !> Whether to store the dump files at the end of the DMC calculation integer :: dmc_idump + + !> Whether to restart the DMC calculation integer :: dmc_irstar + + !> Whether to read the configuration from a file or generate it integer :: dmc_isite + + !> Number of configurations to generate integer :: dmc_nconf + + !> Number of blocks to run integer :: dmc_nblk + + !> Number of blocks to equilibrate integer :: dmc_nblkeq + + !> Number of configurations to generate in the new block integer :: dmc_nconf_new + + !> Number of steps to run in a block integer :: dmc_nstep private @@ -57,12 +117,18 @@ module control_dmc save end module control_dmc +!> Module to control the periodic calculations +!> @var iperiodic: periodic boundary conditions +!> @var ibasis: the basis set module contrl_per - !> Arguments: iperiodic, ibasis implicit none - integer :: iperiodic, ibasis + !> periodic boundary conditions + integer :: iperiodic + + !> the basis set + integer :: ibasis private public :: iperiodic, ibasis @@ -109,16 +175,38 @@ end subroutine deallocate_contrldmc end module contrldmc + +!> Module to control the file handling module contrl_file #if defined(TREXIO_FOUND) use trexio, only: trexio_back_end_t #endif implicit none + !> Name of the log file character(20) :: log_filename + + !> Name of the proc file character(20) :: proc_filename - character(80) :: file_input, file_output, file_error - integer :: iunit, ounit, errunit + + !> Name of the input file + character(80) :: file_input + + !> Name of the output file + character(80) :: file_output + + !> Name of the error file + character(80) :: file_error + + !> Unit number for the input file + integer :: iunit + + !> Unit number for the output file + integer :: ounit + + !> Unit number for the error file + integer :: errunit + #if defined(TREXIO_FOUND) integer(trexio_back_end_t) :: backend #endif @@ -135,13 +223,7 @@ module contrl_file save contains -! Open all log/output files at once does not work because init_procfile -! needs to know the value of ipr flag from read_input.f. -! subroutine init_files() -! call init_logfile() -! call init_procfile() -! end subroutine init_files - + !> Subroutine to close the files subroutine close_files() use mpiconf, only: wid close (5) @@ -149,6 +231,7 @@ subroutine close_files() if (wid) close (45) end subroutine close_files + !> Subroutine to initialize the log file subroutine init_logfile() use mpiconf, only: wid @@ -161,11 +244,11 @@ subroutine init_logfile() close (6) open (6, file='/dev/null') endif - !open (45, file=log_filename, status='unknown') end subroutine init_logfile + !> Subroutine to initialize the file handling + !> @author Ravindra Shinde subroutine initialize() - ! Ravindra use mpiconf, only: wid ! logical :: true only for mpirank=0 use, intrinsic :: iso_fortran_env !, only: stdin=>input_unit, stdout=>output_unit, stderr=>error_unit @@ -189,7 +272,7 @@ subroutine initialize() ounit = output_unit errunit = error_unit ! Get all the command line arguments -! The next line is commented as all mpi processes read this information. old style + argcount = command_argument_count() if ( .not. allocated(arg)) allocate(arg(12)) @@ -221,11 +304,6 @@ subroutine initialize() write(error_unit,*) "input file should have an extention .in / .inp / .dat" stop endif -! write(output_unit, fmt=string_format) ' input file :: ', file_input -! if (wid) then -! open (newunit=iunit,file=file_input, iostat=iostat, action='read' ) -! if (iostat /= 0) error stop "error in opening input file" -! endif case ('-o', '-ou', '-out', '-output', '--output') file_output = arg(i+1) @@ -283,7 +361,7 @@ end subroutine print_help end subroutine initialize - + !> Subroutine to initialize the proc file subroutine init_procfile() use mpiconf, only: idtask use control, only: ipr @@ -300,8 +378,10 @@ end subroutine init_procfile end module contrl_file +!> Module to control the allocation and deallocation of the control modules module m_control contains +!> Subroutine to allocate the control modules subroutine allocate_m_control() use contrldmc, only: allocate_contrldmc @@ -311,6 +391,7 @@ subroutine allocate_m_control() end subroutine allocate_m_control +!> Subroutine to deallocate the control modules subroutine deallocate_m_control() use contrldmc, only: deallocate_contrldmc diff --git a/src/module/m_qmckl.F90 b/src/module/m_qmckl.F90 index ed51ddbe..16412fec 100644 --- a/src/module/m_qmckl.F90 +++ b/src/module/m_qmckl.F90 @@ -2,11 +2,16 @@ #include "qmckl_f.F90" #endif +!> Module that contains the qmckl context module qmckl_data #ifdef QMCKL_FOUND use qmckl + + !> QMCKL context integer(qmckl_context) :: qmckl_ctx + + !> Logical to check if QMCKL is used logical :: use_qmckl = .True. public :: qmckl_ctx, use_qmckl @@ -14,8 +19,13 @@ module qmckl_data #else + !> QMCKL context integer :: qmckl_ctx = 0 + + !> Logical to check if QMCKL is successfully linked integer :: QMCKL_SUCCESS = 0 + + !> Logical to check if QMCKL is used logical :: use_qmckl = .False. public :: qmckl_ctx, use_qmckl, QMCKL_SUCCESS diff --git a/src/module/m_timer.f90 b/src/module/m_timer.f90 index 99dd1812..9c32591b 100644 --- a/src/module/m_timer.f90 +++ b/src/module/m_timer.f90 @@ -1,13 +1,20 @@ +!> This module provides the walltime (obtained from MPI_Wtime for better precision) +!> @author Ravindra Shinde +!> @date June 23 2021 module mpitimer - !> This module provides the walltime (obtained from MPI_Wtime for better precision) - !! @author Ravindra Shinde - !! @date June 23 2021 - use precision_kinds, only: dp + use precision_kinds, only: dp + !> the starting time logged real(dp), save :: time_start + + !> the time at the last check1 real(dp), save :: time_check1 + + !> the time at the last check2 real(dp) :: time_check2 + + !> the final time logged real(dp), save :: time_final private @@ -18,16 +25,22 @@ module mpitimer public :: time, elapsed_time contains + !> Subroutine that uses MPI_Wtime to get the current time double precision function time() use mpi implicit None time = MPI_Wtime() end function time + !> Subroutine that logs the elapsed time between two points subroutine elapsed_time(message, iter) use contrl_file, only: ounit implicit None + + !> @param message :: the message to be printed character(len=*), intent(in) :: message + + !> @param iter :: the iteration number integer, intent(in), optional :: iter if (present(iter)) then diff --git a/src/module/m_vmc.f90 b/src/module/m_vmc.f90 index 6cdce184..229a69a5 100644 --- a/src/module/m_vmc.f90 +++ b/src/module/m_vmc.f90 @@ -1,3 +1,4 @@ +!> Module that contains VMC parameters module vmc_mod !> Arguments: use precision_kinds, only: dp @@ -23,34 +24,82 @@ module vmc_mod ! parameter(neqsx=2*(nordj-1),MTERMS=55) + !> nstoo integer, dimension(:), allocatable :: nstoo !(nwftypeorb) allocate later + + !> nstoj integer, dimension(:), allocatable :: nstoj !(nwftypejas) allocate later + + !> jtos integer, dimension(:, :), allocatable :: jtos !(nwftypejas,entry) allocate later + + !> otos integer, dimension(:, :), allocatable :: otos !(nwftypeorb,entry) allocate later + + !> stoj integer, dimension(:), allocatable :: stoj !(nstates) allocate later + + !> stoo integer, dimension(:), allocatable :: stoo !(nstates) allocate later + + !> stobjx integer, dimension(:), allocatable :: stobjx !(nstates) allocate later + + !> bjxtoo integer, dimension(:), allocatable :: bjxtoo !(nbjx) allocate later + + !> bjxtoj integer, dimension(:), allocatable :: bjxtoj !(nbjx) allocate later + !> norb_tot :: total number of orbitals integer :: norb_tot + + !> nctyp3x :: max(3, nctype_tot) integer :: nctyp3x - integer :: nmat_dim, nmat_dim2 + !> nmat_dim :: nup*nup + integer :: nmat_dim + + !> nmat_dim2 :: nelec*(nelec - 1)/2 + integer :: nmat_dim2 + + !> nwftypeorb integer :: nwftypeorb + + !> nwftypejas integer :: nwftypejas + + !> nstojmax integer :: nstojmax + + !> nstoomax integer :: nstoomax + + !> nbjx integer :: nbjx + + !> nstoo_tot integer :: nstoo_tot + + !> nstoj_tot integer :: nstoj_tot + + !> extraj integer :: extraj + + !> extrao integer :: extrao + !> mterms integer :: mterms + + !> ncent3 integer :: ncent3 + !> @param NCOEF :: 5 integer, parameter :: NCOEF = 5 + + !> @param MEXCIT :: 10 integer, parameter :: MEXCIT = 10 private @@ -65,6 +114,7 @@ module vmc_mod save contains + !> Subroutine that sets the size of the VMC arrays subroutine set_vmc_size use system, only: ncent_tot,nctype_tot,ndn,nelec,nup