Build molecular basis from geometry and basis file Only parses unique elements, then copies basis data to atoms
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | basis_string | |||
| character(len=*), | intent(in) | :: | element_names(:) |
Element for each atom in geometry order |
||
| type(molecular_basis_type), | intent(out) | :: | mol_basis | |||
| type(error_t), | intent(out) | :: | error |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | iatom | ||||
| integer, | private | :: | iunique | ||||
| integer, | private | :: | match_idx | ||||
| integer, | private | :: | natoms | ||||
| integer, | private | :: | nunique | ||||
| type(atomic_basis_type), | private, | allocatable | :: | unique_bases(:) | |||
| character(len=:), | private, | allocatable | :: | unique_elements(:) |
subroutine build_molecular_basis(basis_string, element_names, mol_basis, error) !! Build molecular basis from geometry and basis file !! Only parses unique elements, then copies basis data to atoms character(len=*), intent(in) :: basis_string character(len=*), intent(in) :: element_names(:) !! Element for each atom in geometry order type(molecular_basis_type), intent(out) :: mol_basis type(error_t), intent(out) :: error integer :: iatom, natoms, iunique, nunique character(len=:), allocatable :: unique_elements(:) type(atomic_basis_type), allocatable :: unique_bases(:) integer :: match_idx match_idx = 0 natoms = size(element_names) ! Find unique elements call find_unique_strings(element_names, unique_elements, nunique) print *, "Found ", nunique, " unique elements out of ", natoms, " atoms" ! Allocate for unique bases allocate (unique_bases(nunique)) ! Parse basis for each unique element do iunique = 1, nunique print *, "Parsing basis for: ", trim(unique_elements(iunique)) call parse_element_basis(basis_string, unique_elements(iunique), & unique_bases(iunique), error) if (error%has_error()) then ! Prepend context to error message call error%add_context("mqc_basis_reader:read_basis_from_string") call error%set(ERROR_PARSE, "Failed to parse basis for element "// & trim(unique_elements(iunique))//": "//error%get_message()) return end if end do ! Allocate molecular basis and assign to each atom call mol_basis%allocate_elements(natoms) do iatom = 1, natoms ! Find which unique element this atom corresponds to do iunique = 1, nunique if (strings_equal(element_names(iatom), unique_elements(iunique))) then match_idx = iunique exit end if end do ! Copy the basis data call copy_atomic_basis(unique_bases(match_idx), mol_basis%elements(iatom)) end do ! Clean up do iunique = 1, nunique call unique_bases(iunique)%destroy() end do end subroutine build_molecular_basis