tran_main Subroutine

public subroutine tran_main(atom_data, dis_manifold, fermi_energy_list, ham_logical, kpt_latt, output_file, real_space_ham, transport, print_output, wannier_data, ws_region, w90_calculation, ham_k, ham_r, u_matrix, u_matrix_opt, eigval, real_lattice, wannier_centres_translated, irvec, mp_grid, ndegen, shift_vec, nrpts, num_bands, num_kpts, num_wann, rpt_origin, bands_plot_mode, have_disentangled, lsitesymmetry, seedname, stdout, timer, error, comm)

Uses

  • proc~~tran_main~~UsesGraph proc~tran_main tran_main module~w90_error w90_error proc~tran_main->module~w90_error module~w90_hamiltonian w90_hamiltonian proc~tran_main->module~w90_hamiltonian module~w90_io w90_io proc~tran_main->module~w90_io module~w90_types w90_types proc~tran_main->module~w90_types module~w90_wannier90_types w90_wannier90_types proc~tran_main->module~w90_wannier90_types 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_hamiltonian->module~w90_error module~w90_hamiltonian->module~w90_types module~w90_constants w90_constants module~w90_hamiltonian->module~w90_constants module~w90_io->module~w90_constants module~w90_types->module~w90_constants module~w90_wannier90_types->module~w90_constants module~w90_comms->module~w90_constants module~w90_comms->module~w90_error_base

Main transport subroutine

Arguments

Type IntentOptional Attributes Name
type(atom_data_type), intent(in) :: atom_data
type(dis_manifold_type), intent(in) :: dis_manifold
real(kind=dp), intent(in), allocatable :: fermi_energy_list(:)
type(ham_logical_type), intent(inout) :: ham_logical
real(kind=dp), intent(in) :: kpt_latt(:,:)
type(output_file_type), intent(in) :: output_file
type(real_space_ham_type), intent(inout) :: real_space_ham
type(transport_type), intent(inout) :: transport
type(print_output_type), intent(in) :: print_output
type(wannier_data_type), intent(in) :: wannier_data
type(ws_region_type), intent(inout) :: ws_region
type(w90_calculation_type), intent(in) :: w90_calculation
complex(kind=dp), intent(inout), allocatable :: ham_k(:,:,:)
complex(kind=dp), intent(inout), allocatable :: ham_r(:,:,:)
complex(kind=dp), intent(in) :: u_matrix(:,:,:)
complex(kind=dp), intent(in) :: u_matrix_opt(:,:,:)
real(kind=dp), intent(in) :: eigval(:,:)
real(kind=dp), intent(in) :: real_lattice(3,3)
real(kind=dp), intent(inout), allocatable :: wannier_centres_translated(:,:)
integer, intent(inout), allocatable :: irvec(:,:)
integer, intent(in) :: mp_grid(3)
integer, intent(inout), allocatable :: ndegen(:)
integer, intent(inout), allocatable :: shift_vec(:,:)
integer, intent(inout) :: nrpts
integer, intent(in) :: num_bands
integer, intent(in) :: num_kpts
integer, intent(in) :: num_wann
integer, intent(inout) :: rpt_origin
character(len=*), intent(in) :: bands_plot_mode
logical, intent(in) :: have_disentangled
logical, intent(in) :: lsitesymmetry
character(len=50), intent(in) :: seedname
integer, intent(in) :: stdout
type(timer_list_type), intent(inout) :: timer
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~tran_main~~CallsGraph proc~tran_main tran_main proc~hamiltonian_get_hr hamiltonian_get_hr proc~tran_main->proc~hamiltonian_get_hr proc~hamiltonian_setup hamiltonian_setup proc~tran_main->proc~hamiltonian_setup proc~hamiltonian_write_hr hamiltonian_write_hr proc~tran_main->proc~hamiltonian_write_hr proc~io_stopwatch_start io_stopwatch_start proc~tran_main->proc~io_stopwatch_start proc~io_stopwatch_stop io_stopwatch_stop proc~tran_main->proc~io_stopwatch_stop proc~set_error_dealloc set_error_dealloc proc~tran_main->proc~set_error_dealloc proc~tran_bulk tran_bulk proc~tran_main->proc~tran_bulk proc~tran_cut_hr_one_dim tran_cut_hr_one_dim proc~tran_main->proc~tran_cut_hr_one_dim proc~tran_find_integral_signatures tran_find_integral_signatures proc~tran_main->proc~tran_find_integral_signatures proc~tran_get_ht tran_get_ht proc~tran_main->proc~tran_get_ht proc~tran_lcr tran_lcr proc~tran_main->proc~tran_lcr proc~tran_lcr_2c2_build_ham tran_lcr_2c2_build_ham proc~tran_main->proc~tran_lcr_2c2_build_ham proc~tran_lcr_2c2_sort tran_lcr_2c2_sort proc~tran_main->proc~tran_lcr_2c2_sort proc~tran_parity_enforce tran_parity_enforce proc~tran_main->proc~tran_parity_enforce proc~tran_reduce_hr tran_reduce_hr proc~tran_main->proc~tran_reduce_hr proc~tran_write_xyz tran_write_xyz proc~tran_main->proc~tran_write_xyz proc~hamiltonian_get_hr->proc~io_stopwatch_start proc~hamiltonian_get_hr->proc~io_stopwatch_stop proc~hamiltonian_get_hr->proc~set_error_dealloc proc~set_error_alloc set_error_alloc proc~hamiltonian_get_hr->proc~set_error_alloc proc~utility_cart_to_frac utility_cart_to_frac proc~hamiltonian_get_hr->proc~utility_cart_to_frac proc~utility_frac_to_cart utility_frac_to_cart proc~hamiltonian_get_hr->proc~utility_frac_to_cart proc~utility_inverse_mat utility_inverse_mat proc~hamiltonian_get_hr->proc~utility_inverse_mat proc~hamiltonian_wigner_seitz hamiltonian_wigner_seitz proc~hamiltonian_setup->proc~hamiltonian_wigner_seitz proc~hamiltonian_setup->proc~set_error_alloc proc~hamiltonian_write_hr->proc~io_stopwatch_start proc~hamiltonian_write_hr->proc~io_stopwatch_stop proc~io_date io_date proc~hamiltonian_write_hr->proc~io_date proc~set_error_file set_error_file proc~hamiltonian_write_hr->proc~set_error_file proc~comms_sync_error comms_sync_error proc~set_error_dealloc->proc~comms_sync_error proc~set_base_error set_base_error proc~set_error_dealloc->proc~set_base_error proc~tran_bulk->proc~io_stopwatch_start proc~tran_bulk->proc~io_stopwatch_stop proc~tran_bulk->proc~set_error_dealloc proc~tran_bulk->proc~io_date proc~tran_bulk->proc~set_error_alloc proc~tran_green tran_green proc~tran_bulk->proc~tran_green proc~tran_read_htx tran_read_htX proc~tran_bulk->proc~tran_read_htx proc~tran_transfer tran_transfer proc~tran_bulk->proc~tran_transfer zgemm zgemm proc~tran_bulk->zgemm proc~tran_cut_hr_one_dim->proc~io_stopwatch_start proc~tran_cut_hr_one_dim->proc~io_stopwatch_stop proc~tran_find_integral_signatures->proc~io_stopwatch_start proc~tran_find_integral_signatures->proc~io_stopwatch_stop proc~tran_find_integral_signatures->proc~set_error_dealloc proc~tran_find_integral_signatures->proc~set_error_alloc proc~tran_find_integral_signatures->proc~set_error_file proc~tran_get_ht->proc~io_stopwatch_start proc~tran_get_ht->proc~io_stopwatch_stop proc~tran_get_ht->proc~io_date proc~tran_get_ht->proc~set_error_alloc proc~set_error_fatal set_error_fatal proc~tran_get_ht->proc~set_error_fatal proc~tran_lcr->proc~io_stopwatch_start proc~tran_lcr->proc~io_stopwatch_stop proc~tran_lcr->proc~set_error_dealloc proc~tran_lcr->proc~io_date proc~tran_lcr->proc~set_error_alloc proc~tran_lcr->proc~set_error_fatal proc~tran_lcr->proc~tran_green proc~tran_read_htc tran_read_htC proc~tran_lcr->proc~tran_read_htc proc~tran_lcr->proc~tran_read_htx proc~tran_read_htxy tran_read_htXY proc~tran_lcr->proc~tran_read_htxy proc~tran_lcr->proc~tran_transfer zgbsv zgbsv proc~tran_lcr->zgbsv proc~tran_lcr->zgemm proc~tran_lcr_2c2_build_ham->proc~io_stopwatch_start proc~tran_lcr_2c2_build_ham->proc~io_stopwatch_stop proc~tran_lcr_2c2_build_ham->proc~set_error_dealloc proc~tran_lcr_2c2_build_ham->proc~tran_cut_hr_one_dim proc~tran_lcr_2c2_build_ham->proc~tran_reduce_hr proc~tran_lcr_2c2_build_ham->proc~io_date proc~tran_lcr_2c2_build_ham->proc~set_error_alloc proc~tran_lcr_2c2_build_ham->proc~set_error_fatal proc~tran_lcr_2c2_sort->proc~io_stopwatch_start proc~tran_lcr_2c2_sort->proc~io_stopwatch_stop proc~tran_lcr_2c2_sort->proc~set_error_dealloc proc~tran_lcr_2c2_sort->proc~tran_cut_hr_one_dim proc~tran_lcr_2c2_sort->proc~tran_reduce_hr proc~tran_lcr_2c2_sort->proc~tran_write_xyz proc~check_and_sort_similar_centres check_and_sort_similar_centres proc~tran_lcr_2c2_sort->proc~check_and_sort_similar_centres proc~group group proc~tran_lcr_2c2_sort->proc~group proc~master_sort_and_group master_sort_and_group proc~tran_lcr_2c2_sort->proc~master_sort_and_group proc~tran_lcr_2c2_sort->proc~set_error_alloc proc~tran_lcr_2c2_sort->proc~set_error_fatal proc~sort sort proc~tran_lcr_2c2_sort->proc~sort proc~tran_parity_enforce->proc~io_stopwatch_start proc~tran_parity_enforce->proc~io_stopwatch_stop proc~tran_reduce_hr->proc~io_stopwatch_start proc~tran_reduce_hr->proc~io_stopwatch_stop proc~tran_reduce_hr->proc~set_error_alloc proc~tran_reduce_hr->proc~set_error_fatal proc~tran_write_xyz->proc~io_date proc~check_and_sort_similar_centres->proc~io_stopwatch_start proc~check_and_sort_similar_centres->proc~io_stopwatch_stop proc~check_and_sort_similar_centres->proc~set_error_dealloc proc~check_and_sort_similar_centres->proc~tran_write_xyz proc~check_and_sort_similar_centres->proc~set_error_alloc proc~check_and_sort_similar_centres->proc~set_error_fatal proc~group->proc~set_error_dealloc proc~group->proc~set_error_alloc proc~hamiltonian_wigner_seitz->proc~io_stopwatch_start proc~hamiltonian_wigner_seitz->proc~io_stopwatch_stop proc~hamiltonian_wigner_seitz->proc~set_error_dealloc proc~hamiltonian_wigner_seitz->proc~set_error_alloc proc~hamiltonian_wigner_seitz->proc~set_error_fatal proc~utility_metric utility_metric proc~hamiltonian_wigner_seitz->proc~utility_metric proc~master_sort_and_group->proc~io_stopwatch_start proc~master_sort_and_group->proc~io_stopwatch_stop proc~master_sort_and_group->proc~set_error_dealloc proc~master_sort_and_group->proc~group proc~master_sort_and_group->proc~set_error_alloc proc~master_sort_and_group->proc~sort proc~set_error_alloc->proc~comms_sync_error proc~set_error_alloc->proc~set_base_error proc~set_error_fatal->proc~comms_sync_error proc~set_error_fatal->proc~set_base_error proc~set_error_file->proc~comms_sync_error proc~set_error_file->proc~set_base_error proc~tran_green->proc~set_error_dealloc proc~tran_green->proc~set_error_alloc proc~tran_green->proc~set_error_fatal proc~tran_green->zgemm zgesv zgesv proc~tran_green->zgesv proc~tran_read_htc->proc~set_error_file proc~tran_read_htx->proc~set_error_file proc~tran_read_htxy->proc~set_error_file proc~tran_transfer->proc~set_error_dealloc proc~tran_transfer->proc~set_error_alloc proc~tran_transfer->proc~set_error_fatal proc~tran_transfer->zgemm proc~set_error_unconv set_error_unconv proc~tran_transfer->proc~set_error_unconv zaxpy zaxpy proc~tran_transfer->zaxpy zcopy zcopy proc~tran_transfer->zcopy proc~tran_transfer->zgesv proc~utility_inv3 utility_inv3 proc~utility_inverse_mat->proc~utility_inv3 proc~set_error_unconv->proc~comms_sync_error proc~set_error_unconv->proc~set_base_error

Called by

proc~~tran_main~~CalledByGraph proc~tran_main tran_main proc~w90_transport w90_transport proc~w90_transport->proc~tran_main program~wannier wannier program~wannier->proc~w90_transport

Source Code

  subroutine tran_main(atom_data, dis_manifold, fermi_energy_list, ham_logical, kpt_latt, &
                       output_file, real_space_ham, transport, print_output, wannier_data, &
                       ws_region, w90_calculation, ham_k, ham_r, u_matrix, u_matrix_opt, eigval, &
                       real_lattice, wannier_centres_translated, irvec, mp_grid, ndegen, &
                       shift_vec, nrpts, num_bands, num_kpts, num_wann, rpt_origin, &
                       bands_plot_mode, have_disentangled, lsitesymmetry, seedname, stdout, &
                       timer, error, comm)
    !================================================!
    !
    !! Main transport subroutine
    !
    !================================================!

    use w90_io, only: io_stopwatch_start, io_stopwatch_stop
    use w90_error, only: w90_error_type, set_error_dealloc
    use w90_hamiltonian, only: hamiltonian_get_hr, hamiltonian_write_hr, hamiltonian_setup
    use w90_types, only: wannier_data_type, print_output_type, ws_region_type, &
                         atom_data_type, dis_manifold_type, timer_list_type
    use w90_wannier90_types, only: w90_calculation_type, transport_type, output_file_type, &
                                   real_space_ham_type, ham_logical_type

    implicit none

    ! arguments
    type(transport_type), intent(inout)         :: transport
    type(real_space_ham_type), intent(inout)    :: real_space_ham
    type(ws_region_type), intent(inout)         :: ws_region
    type(print_output_type), intent(in)         :: print_output
    type(w90_calculation_type), intent(in)      :: w90_calculation
    type(output_file_type), intent(in)          :: output_file
    type(wannier_data_type), intent(in)         :: wannier_data
    type(atom_data_type), intent(in)            :: atom_data
    type(dis_manifold_type), intent(in)         :: dis_manifold
    real(kind=dp), intent(in)                   :: kpt_latt(:, :)
    real(kind=dp), allocatable, intent(in)      :: fermi_energy_list(:)
    type(ham_logical_type), intent(inout)       :: ham_logical
    type(timer_list_type), intent(inout) :: timer
    type(w90_error_type), allocatable, intent(out) :: error
    type(w90_comm_type), intent(in) :: comm

    integer, intent(inout)              :: rpt_origin
    integer, intent(inout)              :: nrpts
    integer, intent(inout), allocatable :: ndegen(:)
    integer, intent(inout), allocatable :: shift_vec(:, :)
    integer, intent(inout), allocatable :: irvec(:, :)
    integer, intent(in)                 :: num_wann
    integer, intent(in)                 :: num_bands
    integer, intent(in)                 :: num_kpts
    integer, intent(in)                 :: stdout
    integer, intent(in)                 :: mp_grid(3)

    real(kind=dp), intent(inout), allocatable :: wannier_centres_translated(:, :)
    real(kind=dp), intent(in)                 :: real_lattice(3, 3)
    real(kind=dp), intent(in)                 :: eigval(:, :)

    complex(kind=dp), intent(in)                 :: u_matrix(:, :, :)
    complex(kind=dp), intent(in)                 :: u_matrix_opt(:, :, :)
    complex(kind=dp), allocatable, intent(inout) :: ham_k(:, :, :)
    complex(kind=dp), intent(inout), allocatable :: ham_r(:, :, :)

    character(len=*), intent(in) :: bands_plot_mode
    character(len=50), intent(in)  :: seedname
    logical, intent(in) :: have_disentangled
    logical, intent(in) :: lsitesymmetry  !YN:

    ! local variables
    integer              :: one_dim_vec
    !! cartesian axis to which real_lattice(:,one_dim_vec) is parallel
    integer              :: nrpts_one_dim
    integer              :: num_pl
    !! number of unit cell in a principal layer
    integer              :: coord(3)
    !! coord : coord(1) defines the conduction direction according to
    !1=x,2=y,3=z
    !! coord(2),coord(3) define the other directions during sorting routines
    integer, allocatable :: tran_sorted_idx(:)
    !! index of sorted WF centres to unsorted
    integer              :: num_G
    integer :: irvec_max ! size of hr_one_dim's last dimension (:, :, -irvec_max:irvec_max)
    integer :: ierr

    real(kind=dp), allocatable :: hr_one_dim(:, :, :)
    real(kind=dp), allocatable :: signatures(:, :)
    real(kind=dp), allocatable :: hB0(:, :)
    real(kind=dp), allocatable :: hB1(:, :)
    real(kind=dp), allocatable :: hC(:, :)
    real(kind=dp), allocatable :: hCR(:, :)
    real(kind=dp), allocatable :: hL0(:, :)
    real(kind=dp), allocatable :: hL1(:, :)
    real(kind=dp), allocatable :: hLC(:, :)
    real(kind=dp), allocatable :: hR0(:, :)
    real(kind=dp), allocatable :: hR1(:, :)

    logical :: pl_warning

    ! fixme printout guards as elsewhere please (even if not yet parallel)
    if (print_output%timing_level > 0) call io_stopwatch_start('tran: main', timer)

    write (stdout, '(/1x,a)') '*---------------------------------------------------------------------------*'
    write (stdout, '(1x,a)') '|                              TRANSPORT                                    |'
    write (stdout, '(1x,a)') '*---------------------------------------------------------------------------*'
    write (stdout, *)

    if (index(transport%mode, 'bulk') > 0) then
      write (stdout, '(/1x,a/)') 'Calculation of Quantum Conductance and DoS: bulk mode'
      if (.not. transport%read_ht) then
        call hamiltonian_setup(ham_logical, print_output, ws_region, w90_calculation, ham_k, &
                               ham_r, real_lattice, wannier_centres_translated, irvec, mp_grid, &
                               ndegen, num_kpts, num_wann, nrpts, rpt_origin, bands_plot_mode, &
                               stdout, timer, error, transport%mode, comm)
        if (allocated(error)) return

        call hamiltonian_get_hr(atom_data, dis_manifold, ham_logical, real_space_ham, &
                                print_output, ham_k, ham_r, u_matrix, u_matrix_opt, eigval, &
                                kpt_latt, real_lattice, wannier_data%centres, &
                                wannier_centres_translated, irvec, shift_vec, nrpts, num_bands, &
                                num_kpts, num_wann, have_disentangled, stdout, timer, error, &
                                lsitesymmetry, comm)
        if (allocated(error)) return

        if (output_file%write_hr) then
          ! is this redundant after the plot call?
          call hamiltonian_write_hr(ham_r, irvec, ndegen, nrpts, num_wann, &
                                    print_output%timing_level, seedname, timer, error, comm)
        end if

        if (allocated(error)) return

        call tran_reduce_hr(real_space_ham, ham_r, hr_one_dim, real_lattice, irvec, mp_grid, &
                            irvec_max, nrpts, nrpts_one_dim, num_wann, one_dim_vec, &
                            print_output%timing_level, stdout, timer, error, comm)
        if (allocated(error)) return

        call tran_cut_hr_one_dim(real_space_ham, transport, print_output, hr_one_dim, &
                                 real_lattice, wannier_centres_translated, mp_grid, irvec_max, &
                                 num_pl, num_wann, one_dim_vec, stdout, timer)

        call tran_get_ht(fermi_energy_list, transport, hB0, hB1, hr_one_dim, irvec_max, num_pl, &
                         num_wann, print_output%timing_level, seedname, timer, error, comm)
        if (allocated(error)) return

        if (output_file%write_xyz) then
          call tran_write_xyz(atom_data, transport, wannier_centres_translated, tran_sorted_idx, &
                              num_wann, seedname, stdout)
        end if
      end if
      call tran_bulk(transport, hB0, hB1, print_output%timing_level, stdout, seedname, timer, error, comm)
      if (allocated(error)) return
    end if

    if (index(transport%mode, 'lcr') > 0) then
      write (stdout, '(/1x,a/)') 'Calculation of Quantum Conductance and DoS: lead-conductor-lead mode'
      if (.not. transport%read_ht) then
        call hamiltonian_setup(ham_logical, print_output, ws_region, w90_calculation, ham_k, &
                               ham_r, real_lattice, wannier_centres_translated, irvec, mp_grid, &
                               ndegen, num_kpts, num_wann, nrpts, rpt_origin, bands_plot_mode, &
                               stdout, timer, error, transport%mode, comm)
        if (allocated(error)) return

        call hamiltonian_get_hr(atom_data, dis_manifold, ham_logical, real_space_ham, &
                                print_output, ham_k, ham_r, u_matrix, u_matrix_opt, eigval, &
                                kpt_latt, real_lattice, wannier_data%centres, &
                                wannier_centres_translated, irvec, shift_vec, nrpts, num_bands, &
                                num_kpts, num_wann, have_disentangled, stdout, timer, error, &
                                lsitesymmetry, comm)
        if (allocated(error)) return

        if (output_file%write_hr) then
          call hamiltonian_write_hr(ham_r, irvec, ndegen, nrpts, num_wann, &
                                    print_output%timing_level, seedname, timer, error, comm)
          if (allocated(error)) return
        end if

        call tran_reduce_hr(real_space_ham, ham_r, hr_one_dim, real_lattice, irvec, mp_grid, &
                            irvec_max, nrpts, nrpts_one_dim, num_wann, one_dim_vec, &
                            print_output%timing_level, stdout, timer, error, comm)
        if (allocated(error)) return

        call tran_cut_hr_one_dim(real_space_ham, transport, print_output, hr_one_dim, &
                                 real_lattice, wannier_centres_translated, mp_grid, irvec_max, &
                                 num_pl, num_wann, one_dim_vec, stdout, timer)

        write (stdout, *) '------------------------- 2c2 Calculation Type: ------------------------------'
        write (stdout, *) ' '
        call tran_find_integral_signatures(signatures, num_G, print_output, real_lattice, &
                                           u_matrix_opt, u_matrix, num_bands, num_wann, &
                                           have_disentangled, wannier_centres_translated, stdout, &
                                           seedname, timer, error, comm)
        if (allocated(error)) return

        call tran_lcr_2c2_sort(signatures, num_G, pl_warning, transport, atom_data, wannier_data, &
                               real_space_ham, print_output, real_lattice, num_wann, mp_grid, &
                               ham_r, irvec, nrpts, wannier_centres_translated, one_dim_vec, &
                               nrpts_one_dim, num_pl, coord, tran_sorted_idx, hr_one_dim, &
                               irvec_max, output_file%write_xyz, stdout, seedname, timer, error, comm)
        if (allocated(error)) return

        if (output_file%write_xyz) call tran_write_xyz(atom_data, transport, &
                                                       wannier_centres_translated, &
                                                       tran_sorted_idx, num_wann, seedname, stdout)

        call tran_parity_enforce(signatures, print_output, transport, num_wann, tran_sorted_idx, &
                                 hr_one_dim, irvec_max, stdout, timer)

        call tran_lcr_2c2_build_ham(pl_warning, real_space_ham, fermi_energy_list, kpt_latt, &
                                    num_wann, transport, print_output, real_lattice, mp_grid, &
                                    ham_r, irvec, nrpts, wannier_centres_translated, one_dim_vec, &
                                    nrpts_one_dim, num_pl, coord, tran_sorted_idx, hC, hCR, hL0, &
                                    hL1, hLC, hR0, hR1, hr_one_dim, irvec_max, stdout, seedname, &
                                    timer, error, comm)
        if (allocated(error)) return
      end if
      call tran_lcr(transport, hC, hCR, hL0, hL1, hLC, hR0, hR1, print_output%timing_level, &
                    stdout, seedname, timer, error, comm)
      if (allocated(error)) return

    end if

    if (print_output%timing_level > 0) call io_stopwatch_stop('tran: main', timer)

    if (allocated(hR1)) then
      deallocate (hR1, stat=ierr)
      if (ierr /= 0) then
        call set_error_dealloc(error, 'Error in deallocating hR1 in tran_main', comm)
        return
      end if
    end if
    if (allocated(hR0)) then
      deallocate (hR0, stat=ierr)
      if (ierr /= 0) then
        call set_error_dealloc(error, 'Error in deallocating hR0 in tran_main', comm)
        return
      end if
    end if
    if (allocated(hL1)) then
      deallocate (hL1, stat=ierr)
      if (ierr /= 0) then
        call set_error_dealloc(error, 'Error in deallocating hL1 in tran_main', comm)
        return
      end if
    end if
    if (allocated(hB1)) then
      deallocate (hB1, stat=ierr)
      if (ierr /= 0) then
        call set_error_dealloc(error, 'Error in deallocating hB1 in tran_main', comm)
        return
      end if
    end if
    if (allocated(hB0)) then
      deallocate (hB0, stat=ierr)
      if (ierr /= 0) then
        call set_error_dealloc(error, 'Error in deallocating hB0 in tran_main', comm)
        return
      end if
    end if
    if (allocated(hr_one_dim)) then
      deallocate (hr_one_dim, stat=ierr)
      if (ierr /= 0) then
        call set_error_dealloc(error, 'Error in deallocating hr_one_dim in tran_main', comm)
        return
      end if
    end if

  end subroutine tran_main