get_module_kmesh Subroutine

private subroutine get_module_kmesh(moduleprefix, should_be_defined, module_kmesh, module_kmesh_spacing)

Uses

  • proc~~get_module_kmesh~~UsesGraph proc~get_module_kmesh get_module_kmesh module~w90_io w90_io proc~get_module_kmesh->module~w90_io module~w90_constants w90_constants module~w90_io->module~w90_constants

This function reads and sets the interpolation mesh variables needed by a given module

This function MUST be called after having read the global kmesh and kmesh_spacing!! if the user didn't provide an interpolation_mesh_spacing, it is set to -1, so that one can check in the code what the user asked for The function takes care also of setting the default value to the global one if no local keyword is defined

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: moduleprefix

The prefix that is appended before the name of the variables. In particular, if the prefix is for instance XXX, the two variables that are read from the input file are XXX_kmesh and XXX_kmesh_spacing.

logical, intent(in) :: should_be_defined

A logical flag: if it is true, at the end the code stops if no value is specified. Define it to .false. if no check should be performed. Often, you can simply pass the flag that activates the module itself.

integer, intent(out), dimension(3):: module_kmesh

the integer array (length 3) where the interpolation mesh will be saved

real(kind=dp), intent(out) :: module_kmesh_spacing

the real number on which the min mesh spacing is saved. -1 if it the user specifies in input the mesh and not the mesh_spacing


Calls

proc~~get_module_kmesh~~CallsGraph proc~get_module_kmesh get_module_kmesh proc~internal_set_kmesh internal_set_kmesh proc~get_module_kmesh->proc~internal_set_kmesh

Called by

proc~~get_module_kmesh~~CalledByGraph proc~get_module_kmesh get_module_kmesh proc~param_read param_read proc~param_read->proc~get_module_kmesh program~wannier wannier program~wannier->proc~param_read proc~wannier_run wannier_run proc~wannier_run->proc~param_read proc~wannier_setup wannier_setup proc~wannier_setup->proc~param_read program~postw90 postw90 program~postw90->proc~param_read

Contents

Source Code


Source Code

  subroutine get_module_kmesh(moduleprefix, should_be_defined, module_kmesh, module_kmesh_spacing)
    !! This function reads and sets the interpolation mesh variables needed by a given module
    !>
    !!  This function MUST be called after having read the global kmesh and kmesh_spacing!!
    !!  if the user didn't provide an interpolation_mesh_spacing, it is set to -1, so that
    !!       one can check in the code what the user asked for
    !!  The function takes care also of setting the default value to the global one if no local
    !!       keyword is defined
    use w90_io, only: io_error
    character(len=*), intent(in)       :: moduleprefix
    !!The prefix that is appended before the name of the variables. In particular,
    !!if the prefix is for instance XXX, the two variables that are read from the
    !!input file are XXX_kmesh and XXX_kmesh_spacing.
    logical, intent(in)                :: should_be_defined
    !! A logical flag: if it is true, at the end the code stops if no value is specified.
    !! Define it to .false. if no check should be performed.
    !! Often, you can simply pass the flag that activates the module itself.
    integer, dimension(3), intent(out) :: module_kmesh
    !! the integer array (length 3) where the interpolation mesh will be saved
    real(kind=dp), intent(out)         :: module_kmesh_spacing
    !! the real number on which the min mesh spacing is saved. -1 if it the
    !!user specifies in input the mesh and not the mesh_spacing

    logical :: found, found2
    integer :: i

    ! Default values
    module_kmesh_spacing = -1._dp
    module_kmesh = 0
    call param_get_keyword(trim(moduleprefix)//'_kmesh_spacing', found, r_value=module_kmesh_spacing)
    if (found) then
      if (module_kmesh_spacing .le. 0._dp) &
        call io_error('Error: '//trim(moduleprefix)//'_kmesh_spacing must be greater than zero')

      call internal_set_kmesh(module_kmesh_spacing, recip_lattice, module_kmesh)
    end if
    call param_get_vector_length(trim(moduleprefix)//'_kmesh', found2, length=i)
    if (found2) then
      if (found) &
        call io_error('Error: cannot set both '//trim(moduleprefix)//'_kmesh and ' &
                      //trim(moduleprefix)//'_kmesh_spacing')
      if (i .eq. 1) then
        call param_get_keyword_vector(trim(moduleprefix)//'_kmesh', found2, 1, i_value=module_kmesh)
        module_kmesh(2) = module_kmesh(1)
        module_kmesh(3) = module_kmesh(1)
      elseif (i .eq. 3) then
        call param_get_keyword_vector(trim(moduleprefix)//'_kmesh', found2, 3, i_value=module_kmesh)
      else
        call io_error('Error: '//trim(moduleprefix)// &
                      '_kmesh must be provided as either one integer or a vector of 3 integers')
      end if
      if (any(module_kmesh <= 0)) &
        call io_error('Error: '//trim(moduleprefix)//'_kmesh elements must be greater than zero')
    end if

    if ((found .eqv. .false.) .and. (found2 .eqv. .false.)) then
      ! This is the case where no  "local" interpolation k-mesh is provided in the input
      if (global_kmesh_set) then
        module_kmesh = kmesh
        ! I set also boltz_kmesh_spacing so that I can check if it is < 0 or not, and if it is
        ! > 0 I can print on output the mesh spacing that was chosen
        module_kmesh_spacing = kmesh_spacing
      else
        if (should_be_defined) &
          call io_error('Error: '//trim(moduleprefix)//' module required, but no interpolation mesh given.')
      end if
    end if
  end subroutine get_module_kmesh