w90_readwrite_get_centre_constraints Subroutine

public subroutine w90_readwrite_get_centre_constraints(settings, ccentres_cart, proj_site, num_wann, real_lattice, error, comm)

Uses

  • proc~~w90_readwrite_get_centre_constraints~~UsesGraph proc~w90_readwrite_get_centre_constraints w90_readwrite_get_centre_constraints module~w90_error w90_error proc~w90_readwrite_get_centre_constraints->module~w90_error module~w90_utility w90_utility proc~w90_readwrite_get_centre_constraints->module~w90_utility module~w90_comms w90_comms module~w90_error->module~w90_comms module~w90_error_base w90_error_base module~w90_error->module~w90_error_base module~w90_utility->module~w90_comms module~w90_constants w90_constants module~w90_utility->module~w90_constants module~w90_comms->module~w90_constants module~w90_comms->module~w90_error_base

assigns projection centres as default centre constraints and global Lagrange multiplier as individual Lagrange multipliers then reads the centre_constraints block for individual centre constraint parameters

Arguments

Type IntentOptional Attributes Name
type(settings_type), intent(inout) :: settings
real(kind=dp), intent(inout) :: ccentres_cart(:,:)
real(kind=dp), intent(in) :: proj_site(:,:)
integer, intent(in) :: num_wann
real(kind=dp), intent(in) :: real_lattice(3,3)
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~w90_readwrite_get_centre_constraints~~CallsGraph proc~w90_readwrite_get_centre_constraints w90_readwrite_get_centre_constraints proc~get_centre_constraint_from_column get_centre_constraint_from_column proc~w90_readwrite_get_centre_constraints->proc~get_centre_constraint_from_column proc~set_error_alloc set_error_alloc proc~w90_readwrite_get_centre_constraints->proc~set_error_alloc proc~set_error_dealloc set_error_dealloc proc~w90_readwrite_get_centre_constraints->proc~set_error_dealloc proc~set_error_input set_error_input proc~w90_readwrite_get_centre_constraints->proc~set_error_input proc~utility_frac_to_cart utility_frac_to_cart proc~w90_readwrite_get_centre_constraints->proc~utility_frac_to_cart proc~get_centre_constraint_from_column->proc~set_error_input proc~comms_sync_error comms_sync_error proc~set_error_alloc->proc~comms_sync_error proc~set_base_error set_base_error proc~set_error_alloc->proc~set_base_error proc~set_error_dealloc->proc~comms_sync_error proc~set_error_dealloc->proc~set_base_error proc~set_error_input->proc~comms_sync_error proc~set_error_input->proc~set_base_error

Called by

proc~~w90_readwrite_get_centre_constraints~~CalledByGraph proc~w90_readwrite_get_centre_constraints w90_readwrite_get_centre_constraints proc~w90_wannier90_readwrite_read_constrained_centres w90_wannier90_readwrite_read_constrained_centres proc~w90_wannier90_readwrite_read_constrained_centres->proc~w90_readwrite_get_centre_constraints proc~w90_wannier90_readwrite_read w90_wannier90_readwrite_read proc~w90_wannier90_readwrite_read->proc~w90_wannier90_readwrite_read_constrained_centres proc~w90_input_reader~2 w90_input_reader proc~w90_input_reader~2->proc~w90_wannier90_readwrite_read proc~w90_input_setopt w90_input_setopt proc~w90_input_setopt->proc~w90_wannier90_readwrite_read proc~w90_input_reader w90_input_reader proc~w90_input_reader->proc~w90_input_reader~2 proc~w90_input_setopt_f w90_input_setopt_f proc~w90_input_setopt_f->proc~w90_input_setopt program~wannier wannier program~wannier->proc~w90_input_reader~2

Source Code

  subroutine w90_readwrite_get_centre_constraints(settings, ccentres_cart, &
                                                  proj_site, num_wann, real_lattice, error, comm)
    !================================================!
    !!  assigns projection centres as default centre constraints and global
    !!  Lagrange multiplier as individual Lagrange multipliers then reads
    !!  the centre_constraints block for individual centre constraint parameters
    !
    !================================================!
    use w90_error, only: w90_error_type, set_error_input, set_error_alloc, set_error_dealloc
    use w90_utility, only: utility_frac_to_cart
    implicit none

    ! arguments
    real(kind=dp), intent(inout) :: ccentres_cart(:, :)
    real(kind=dp), intent(in) :: proj_site(:, :)
    integer, intent(in) :: num_wann
    real(kind=dp), intent(in) :: real_lattice(3, 3)
    type(w90_error_type), allocatable, intent(out) :: error
    type(w90_comm_type), intent(in) :: comm
    type(settings_type), intent(inout) :: settings

    ! local variables
    integer :: loop1, index1, constraint_num, loop2, ierr
    integer :: column, start, finish, wann
    character(len=maxlen) :: dummy
    real(kind=dp), allocatable :: ccentres_frac(:, :)

    allocate (ccentres_frac(num_wann, 3), stat=ierr)
    if (ierr /= 0) then
      call set_error_alloc(error, 'Error allocating ccentres_frac in w90_readwrite_get_centre_constraints', comm)
      return
    end if

    do loop1 = 1, num_wann
      do loop2 = 1, 3
        ccentres_frac(loop1, loop2) = proj_site(loop2, loop1)
      end do
    end do

    constraint_num = 0
    do loop1 = 1, settings%num_lines
      dummy = settings%in_data(loop1)
      if (constraint_num > 0) then
        if (trim(dummy) == '') cycle
        index1 = index(dummy, 'begin')
        if (index1 > 0) then
          call set_error_input(error, "slwf_centres block hasn't ended yet", comm)
          return
        end if
        index1 = index(dummy, 'end')
        if (index1 > 0) then
          index1 = index(dummy, 'slwf_centres')
          if (index1 == 0) then
            call set_error_input(error, 'Wrong ending of block (need to end slwf_centres)', comm)
            return
          end if
          settings%in_data(loop1) (1:maxlen) = ' '
          exit
        end if
        column = 0
        start = 1
        finish = 1
        do loop2 = 1, len_trim(dummy)
          if (start == loop2 .and. dummy(loop2:loop2) == ' ') then
            start = loop2 + 1
          end if
          if (start < loop2) then
            if (dummy(loop2:loop2) == ' ') then
              finish = loop2 - 1
              call get_centre_constraint_from_column(column, start, finish, &
                                                     wann, dummy, ccentres_frac, error, comm)
              if (allocated(error)) return
              start = loop2 + 1
              finish = start
            end if
          end if
          if (loop2 == len_trim(dummy) .and. dummy(loop2:loop2) /= ' ') then
            finish = loop2
            call get_centre_constraint_from_column(column, start, finish, &
                                                   wann, dummy, ccentres_frac, error, comm)
            if (allocated(error)) return
            start = loop2 + 1
            finish = start
          end if
        end do
        settings%in_data(loop1) (1:maxlen) = ' '
        constraint_num = constraint_num + 1
      end if
      index1 = index(dummy, 'slwf_centres')
      if (index1 > 0) then
        index1 = index(dummy, 'begin')
        if (index1 > 0) then
          constraint_num = 1
          settings%in_data(loop1) (1:maxlen) = ' '
        end if
      end if
    end do
    do loop1 = 1, num_wann
      call utility_frac_to_cart(ccentres_frac(loop1, :), &
                                ccentres_cart(loop1, :), real_lattice)
    end do

    deallocate (ccentres_frac, stat=ierr)
    if (ierr /= 0) then
      call set_error_dealloc(error, 'Error deallocating ccentres_frac in w90_readwrite_get_centre_constraints', comm)
      return
    end if
  end subroutine w90_readwrite_get_centre_constraints