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
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(settings_type), | intent(inout) | :: | settings | |||
| real(kind=dp), | intent(in) | :: | recip_lattice(3,3) | |||
| logical, | intent(in) | :: | global_kmesh_set | |||
| type(kmesh_spacing_type), | intent(in) | :: | global_kmesh | |||
| type(w90_error_type), | intent(out), | allocatable | :: | error | ||
| type(w90_comm_type), | intent(in) | :: | comm | |||
| 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. |
||
| type(kmesh_spacing_type), | intent(inout) | :: | module_kmesh |
the integer array (length 3) where the interpolation mesh will be saved, and 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 |
subroutine get_module_kmesh(settings, recip_lattice, global_kmesh_set, global_kmesh, error, & comm, moduleprefix, should_be_defined, module_kmesh) !================================================! !! 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_error, only: w90_error_type use w90_comms, only: w90_comm_type real(kind=dp), intent(in) :: recip_lattice(3, 3) 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. type(kmesh_spacing_type), intent(inout) :: module_kmesh !! the integer array (length 3) where the interpolation mesh will be saved, and !! 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, intent(in) :: global_kmesh_set type(kmesh_spacing_type), intent(in) :: global_kmesh type(w90_error_type), allocatable, intent(out) :: error type(w90_comm_type), intent(in) :: comm type(settings_type), intent(inout) :: settings logical :: found, found2 integer :: i ! Default values module_kmesh%spacing = -1._dp module_kmesh%mesh = 0 call w90_readwrite_get_keyword(settings, trim(moduleprefix)//'_kmesh_spacing', found, error, & comm, r_value=module_kmesh%spacing) if (allocated(error)) return if (found) then if (module_kmesh%spacing .le. 0._dp) then call set_error_input(error, 'Error: '//trim(moduleprefix)//'_kmesh_spacing must be greater than zero', comm) return end if call w90_readwrite_set_kmesh(module_kmesh%spacing, recip_lattice, module_kmesh%mesh) end if call w90_readwrite_get_vector_length(settings, trim(moduleprefix)//'_kmesh', found2, i, & error, comm) if (allocated(error)) return if (found2) then if (found) then call set_error_input(error, 'Error: cannot set both '//trim(moduleprefix)//'_kmesh and ' & //trim(moduleprefix)//'_kmesh_spacing', comm) return end if if (i .eq. 1) then call w90_readwrite_get_keyword_vector(settings, trim(moduleprefix)//'_kmesh', found2, & 1, error, comm, i_value=module_kmesh%mesh) if (allocated(error)) return module_kmesh%mesh(2) = module_kmesh%mesh(1) module_kmesh%mesh(3) = module_kmesh%mesh(1) elseif (i .eq. 3) then call w90_readwrite_get_keyword_vector(settings, trim(moduleprefix)//'_kmesh', found2, & 3, error, comm, i_value=module_kmesh%mesh) if (allocated(error)) return else call set_error_input(error, 'Error: '//trim(moduleprefix)// & '_kmesh must be provided as either one integer or a vector of 3 integers', & comm) return end if if (any(module_kmesh%mesh <= 0)) then call set_error_input(error, 'Error: '//trim(moduleprefix)//'_kmesh elements must be greater than zero', comm) return end if 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%mesh = global_kmesh%mesh ! 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 = global_kmesh%spacing else if (should_be_defined) then call set_error_input(error, 'Error: '//trim(moduleprefix)//' module required, but no interpolation mesh given.', comm) return end if end if end if end subroutine get_module_kmesh