Fills the atom data block during a library call
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(atom_data_type), | intent(inout) | :: | atom_data | |||
| character(len=*), | intent(in) | :: | atoms_label_tmp(:) |
Atom labels |
||
| real(kind=dp), | intent(in) | :: | atoms_pos_cart_tmp(3,atom_data%num_atoms) |
Atom positions, Cartesian, Angstrom |
||
| type(w90_error_type), | intent(out), | allocatable | :: | error | ||
| type(w90_comm_type), | intent(in) | :: | comm |
subroutine w90_readwrite_set_atoms(atom_data, atoms_label_tmp, atoms_pos_cart_tmp, error, comm) !================================================! ! !! Fills the atom data block during a library call ! !================================================! use w90_utility, only: utility_cart_to_frac, utility_inverse_mat, utility_lowercase use w90_error, only: w90_error_type, set_error_alloc implicit none type(atom_data_type), intent(inout) :: atom_data type(w90_error_type), allocatable, intent(out) :: error type(w90_comm_type), intent(in) :: comm character(len=*), intent(in) :: atoms_label_tmp(:) !! Atom labels real(kind=dp), intent(in) :: atoms_pos_cart_tmp(3, atom_data%num_atoms) !! Atom positions, Cartesian, Angstrom integer :: loop2, max_sites, ierr, ic, loop, counter character(len=maxlen) :: ctemp(atom_data%num_atoms) character(len=maxlen) :: tmp_string ! Now we sort the data into the proper structures atom_data%num_species = 1 ctemp(1) = atoms_label_tmp(1) do loop = 2, atom_data%num_atoms do loop2 = 1, loop - 1 if (trim(atoms_label_tmp(loop)) == trim(atoms_label_tmp(loop2))) exit if (loop2 == loop - 1) then atom_data%num_species = atom_data%num_species + 1 ctemp(atom_data%num_species) = atoms_label_tmp(loop) end if end do end do allocate (atom_data%species_num(atom_data%num_species), stat=ierr) if (ierr /= 0) then call set_error_alloc(error, 'Error allocating atoms_species_num in w90_readwrite_set_atoms', comm) return end if allocate (atom_data%label(atom_data%num_species), stat=ierr) if (ierr /= 0) then call set_error_alloc(error, 'Error allocating atoms_label in w90_readwrite__set_atoms', comm) return end if allocate (atom_data%symbol(atom_data%num_species), stat=ierr) if (ierr /= 0) then call set_error_alloc(error, 'Error allocating atoms_symbol in w90_readwrite_set_atoms', comm) return end if atom_data%species_num(:) = 0 do loop = 1, atom_data%num_species atom_data%label(loop) = ctemp(loop) do loop2 = 1, atom_data%num_atoms if (trim(atom_data%label(loop)) == trim(atoms_label_tmp(loop2))) then atom_data%species_num(loop) = atom_data%species_num(loop) + 1 end if end do end do max_sites = maxval(atom_data%species_num) allocate (atom_data%pos_cart(3, max_sites, atom_data%num_species), stat=ierr) if (ierr /= 0) then call set_error_alloc(error, 'Error allocating atoms_pos_cart in w90_readwrite_set_atoms', comm) return end if do loop = 1, atom_data%num_species counter = 0 do loop2 = 1, atom_data%num_atoms if (trim(atom_data%label(loop)) == trim(atoms_label_tmp(loop2))) then counter = counter + 1 atom_data%pos_cart(:, counter, loop) = atoms_pos_cart_tmp(:, loop2) end if end do end do ! Strip any numeric characters from atoms_label to get atoms_symbol do loop = 1, atom_data%num_species atom_data%symbol(loop) (1:2) = atom_data%label(loop) (1:2) ic = ichar(atom_data%symbol(loop) (2:2)) if ((ic .lt. ichar('a')) .or. (ic .gt. ichar('z'))) & atom_data%symbol(loop) (2:2) = ' ' tmp_string = trim(adjustl(utility_lowercase(atom_data%symbol(loop)))) atom_data%symbol(loop) (1:2) = tmp_string(1:2) tmp_string = trim(adjustl(utility_lowercase(atom_data%label(loop)))) atom_data%label(loop) (1:2) = tmp_string(1:2) ! Upper case the atom labels (eg, si --> Si) ic = ichar(atom_data%label(loop) (1:1)) if ((ic .ge. ichar('a')) .and. (ic .le. ichar('z'))) & atom_data%label(loop) (1:1) = char(ic + ichar('Z') - ichar('z')) end do end subroutine w90_readwrite_set_atoms