Skip to content

Commit

Permalink
second batch of documentation (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
neelravi authored Oct 2, 2024
1 parent 57008a1 commit 5f6a8ae
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 33 deletions.
32 changes: 28 additions & 4 deletions src/module/m_common.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -188,36 +188,60 @@ 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
public :: ecp_coef, ecp_exponent, necp_power, necp_term
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

Expand Down
11 changes: 11 additions & 0 deletions src/module/m_constant.f90
Original file line number Diff line number Diff line change
@@ -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
129 changes: 105 additions & 24 deletions src/module/m_control.f90
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -135,20 +223,15 @@ 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)
close (6)
if (wid) close (45)
end subroutine close_files

!> Subroutine to initialize the log file
subroutine init_logfile()
use mpiconf, only: wid

Expand All @@ -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
Expand All @@ -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))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand Down
Loading

0 comments on commit 5f6a8ae

Please sign in to comment.