prepare_polelec Subroutine

public subroutine prepare_polelec(eel, arg_dogg)

Uses

  • proc~~prepare_polelec~~UsesGraph proc~prepare_polelec prepare_polelec module~mod_memory mod_memory proc~prepare_polelec->module~mod_memory module~mod_io mod_io module~mod_memory->module~mod_io module~mod_constants mod_constants module~mod_memory->module~mod_constants iso_c_binding iso_c_binding module~mod_memory->iso_c_binding module~mod_io->module~mod_constants module~mod_constants->iso_c_binding

Arguments

Type IntentOptional Attributes Name
type(ommp_electrostatics_type), intent(inout) :: eel
logical, intent(in), optional :: arg_dogg

Calls

proc~~prepare_polelec~~CallsGraph proc~prepare_polelec prepare_polelec interface~mallocate mallocate proc~prepare_polelec->interface~mallocate proc~fatal_error fatal_error proc~prepare_polelec->proc~fatal_error proc~elec_prop_m2d elec_prop_M2D proc~prepare_polelec->proc~elec_prop_m2d proc~elec_prop_d2m elec_prop_D2M proc~prepare_polelec->proc~elec_prop_d2m proc~elec_prop_d2d elec_prop_D2D proc~prepare_polelec->proc~elec_prop_d2d proc~r_alloc1 r_alloc1 interface~mallocate->proc~r_alloc1 proc~r_alloc3 r_alloc3 interface~mallocate->proc~r_alloc3 proc~i_alloc2 i_alloc2 interface~mallocate->proc~i_alloc2 proc~i_alloc1 i_alloc1 interface~mallocate->proc~i_alloc1 proc~r_alloc2 r_alloc2 interface~mallocate->proc~r_alloc2 proc~i_alloc3 i_alloc3 interface~mallocate->proc~i_alloc3 proc~l_alloc1 l_alloc1 interface~mallocate->proc~l_alloc1 proc~l_alloc2 l_alloc2 interface~mallocate->proc~l_alloc2 proc~ommp_message ommp_message proc~fatal_error->proc~ommp_message proc~close_output close_output proc~fatal_error->proc~close_output proc~damped_coulomb_kernel damped_coulomb_kernel proc~elec_prop_m2d->proc~damped_coulomb_kernel proc~quad_elec_prop quad_elec_prop proc~elec_prop_m2d->proc~quad_elec_prop proc~cart_propfar_at_ipart cart_propfar_at_ipart proc~elec_prop_m2d->proc~cart_propfar_at_ipart proc~q_elec_prop q_elec_prop proc~elec_prop_m2d->proc~q_elec_prop proc~mu_elec_prop mu_elec_prop proc~elec_prop_m2d->proc~mu_elec_prop proc~preapare_fmm_static preapare_fmm_static proc~elec_prop_m2d->proc~preapare_fmm_static proc~elec_prop_d2m->proc~fatal_error proc~elec_prop_d2m->proc~damped_coulomb_kernel proc~prepare_fmm_ipd prepare_fmm_ipd proc~elec_prop_d2m->proc~prepare_fmm_ipd proc~elec_prop_d2m->proc~cart_propfar_at_ipart proc~elec_prop_d2m->proc~mu_elec_prop proc~elec_prop_d2d->proc~fatal_error proc~elec_prop_d2d->proc~damped_coulomb_kernel proc~elec_prop_d2d->proc~prepare_fmm_ipd proc~elec_prop_d2d->proc~cart_propfar_at_ipart proc~elec_prop_d2d->proc~mu_elec_prop proc~damped_coulomb_kernel->proc~fatal_error proc~coulomb_kernel coulomb_kernel proc~damped_coulomb_kernel->proc~coulomb_kernel proc~prepare_fmm_ipd->proc~fatal_error proc~prepare_fmm_ext_ipd prepare_fmm_ext_ipd proc~prepare_fmm_ipd->proc~prepare_fmm_ext_ipd proc~chk_alloc chk_alloc proc~r_alloc1->proc~chk_alloc proc~memory_init memory_init proc~r_alloc1->proc~memory_init proc~r_alloc3->proc~chk_alloc proc~r_alloc3->proc~memory_init proc~i_alloc2->proc~chk_alloc proc~i_alloc2->proc~memory_init proc~i_alloc1->proc~chk_alloc proc~i_alloc1->proc~memory_init proc~r_alloc2->proc~chk_alloc proc~r_alloc2->proc~memory_init proc~i_alloc3->proc~chk_alloc proc~i_alloc3->proc~memory_init proc~l_alloc1->proc~chk_alloc proc~l_alloc1->proc~memory_init proc~l_alloc2->proc~chk_alloc proc~l_alloc2->proc~memory_init proc~close_output->proc~ommp_message proc~ntot_sph_harm ntot_sph_harm proc~cart_propfar_at_ipart->proc~ntot_sph_harm proc~fmm_l2l fmm_l2l proc~cart_propfar_at_ipart->proc~fmm_l2l proc~preapare_fmm_static->interface~mallocate proc~fmm_solve_for_multipoles fmm_solve_for_multipoles proc~preapare_fmm_static->proc~fmm_solve_for_multipoles interface~mfree mfree proc~preapare_fmm_static->interface~mfree proc~coulomb_kernel->proc~fatal_error proc~prepare_fmm_ext_ipd->interface~mallocate proc~prepare_fmm_ext_ipd->proc~fmm_solve_for_multipoles proc~prepare_fmm_ext_ipd->interface~mfree proc~chk_alloc->proc~fatal_error proc~make_vfact make_vfact proc~fmm_l2l->proc~make_vfact proc~fmm_l2l_rotation_work fmm_l2l_rotation_work proc~fmm_l2l->proc~fmm_l2l_rotation_work proc~fmm_solve_for_multipoles->proc~fatal_error proc~time_push time_push proc~fmm_solve_for_multipoles->proc~time_push proc~tree_m2m tree_m2m proc~fmm_solve_for_multipoles->proc~tree_m2m proc~tree_m2l tree_m2l proc~fmm_solve_for_multipoles->proc~tree_m2l proc~tree_p2m tree_p2m proc~fmm_solve_for_multipoles->proc~tree_p2m proc~tree_l2l tree_l2l proc~fmm_solve_for_multipoles->proc~tree_l2l proc~time_pull time_pull proc~fmm_solve_for_multipoles->proc~time_pull proc~i_free1 i_free1 interface~mfree->proc~i_free1 proc~l_free1 l_free1 interface~mfree->proc~l_free1 proc~r_free3 r_free3 interface~mfree->proc~r_free3 proc~r_free1 r_free1 interface~mfree->proc~r_free1 proc~i_free2 i_free2 interface~mfree->proc~i_free2 proc~r_free2 r_free2 interface~mfree->proc~r_free2 proc~l_free2 l_free2 interface~mfree->proc~l_free2 proc~i_free3 i_free3 interface~mfree->proc~i_free3 proc~chk_free chk_free proc~i_free1->proc~chk_free proc~l_free1->proc~chk_free proc~r_free3->proc~chk_free proc~carttosph carttosph proc~fmm_l2l_rotation_work->proc~carttosph proc~trgev trgev proc~fmm_l2l_rotation_work->proc~trgev proc~fmm_sph_rotate_oxz_work fmm_sph_rotate_oxz_work proc~fmm_l2l_rotation_work->proc~fmm_sph_rotate_oxz_work proc~fmm_l2l_ztranslate_work fmm_l2l_ztranslate_work proc~fmm_l2l_rotation_work->proc~fmm_l2l_ztranslate_work proc~fmm_sph_rotate_oz_adj_work fmm_sph_rotate_oz_adj_work proc~fmm_l2l_rotation_work->proc~fmm_sph_rotate_oz_adj_work proc~fmm_sph_rotate_oz_work fmm_sph_rotate_oz_work proc~fmm_l2l_rotation_work->proc~fmm_sph_rotate_oz_work proc~time_push->proc~fatal_error proc~mem_stat mem_stat proc~time_push->proc~mem_stat proc~tree_m2m->proc~ntot_sph_harm proc~fmm_m2m fmm_m2m proc~tree_m2m->proc~fmm_m2m proc~tree_m2l->proc~ntot_sph_harm proc~fmm_m2l fmm_m2l proc~tree_m2l->proc~fmm_m2l proc~tree_p2m->proc~ntot_sph_harm proc~fmm_error fmm_error proc~tree_p2m->proc~fmm_error proc~tree_p2m->proc~fmm_m2m proc~tree_l2l->proc~ntot_sph_harm proc~tree_l2l->proc~fmm_l2l proc~time_pull->proc~fatal_error proc~time_pull->proc~ommp_message proc~time_pull->proc~mem_stat proc~r_free1->proc~chk_free proc~i_free2->proc~chk_free proc~r_free2->proc~chk_free proc~l_free2->proc~chk_free proc~i_free3->proc~chk_free proc~chk_free->proc~fatal_error proc~mem_stat->proc~memory_init proc~fmm_m2m_rotation_work fmm_m2m_rotation_work proc~fmm_m2m->proc~fmm_m2m_rotation_work proc~fmm_m2l_rotation_work fmm_m2l_rotation_work proc~fmm_m2l->proc~fmm_m2l_rotation_work proc~fmm_m2m_rotation_work->proc~carttosph proc~fmm_m2m_rotation_work->proc~trgev proc~fmm_m2m_rotation_work->proc~fmm_sph_rotate_oxz_work proc~fmm_m2m_rotation_work->proc~fmm_sph_rotate_oz_adj_work proc~fmm_m2m_rotation_work->proc~fmm_sph_rotate_oz_work proc~fmm_m2m_ztranslate_work fmm_m2m_ztranslate_work proc~fmm_m2m_rotation_work->proc~fmm_m2m_ztranslate_work proc~fmm_m2l_rotation_work->proc~carttosph proc~fmm_m2l_rotation_work->proc~trgev proc~fmm_m2l_rotation_work->proc~fmm_sph_rotate_oxz_work proc~fmm_m2l_rotation_work->proc~fmm_sph_rotate_oz_adj_work proc~fmm_m2l_rotation_work->proc~fmm_sph_rotate_oz_work proc~fmm_m2l_ztranslate_work fmm_m2l_ztranslate_work proc~fmm_m2l_rotation_work->proc~fmm_m2l_ztranslate_work

Called by

proc~~prepare_polelec~~CalledByGraph proc~prepare_polelec prepare_polelec proc~polelec_geomgrad polelec_geomgrad proc~polelec_geomgrad->proc~prepare_polelec proc~ommp_get_polelec_energy ommp_get_polelec_energy proc~ommp_get_polelec_energy->proc~prepare_polelec proc~energy_mm_pol energy_MM_pol proc~ommp_get_polelec_energy->proc~energy_mm_pol proc~ommp_set_external_field ommp_set_external_field proc~ommp_set_external_field->proc~prepare_polelec proc~energy_mm_pol->proc~prepare_polelec proc~ommp_polelec_geomgrad ommp_polelec_geomgrad proc~ommp_polelec_geomgrad->proc~polelec_geomgrad proc~c_ommp_get_polelec_energy C_ommp_get_polelec_energy proc~c_ommp_get_polelec_energy->proc~ommp_get_polelec_energy proc~ommp_get_full_ele_energy ommp_get_full_ele_energy proc~ommp_get_full_ele_energy->proc~ommp_get_polelec_energy proc~ommp_set_external_field_nomm ommp_set_external_field_nomm proc~ommp_set_external_field_nomm->proc~ommp_set_external_field proc~ommp_full_geomgrad ommp_full_geomgrad proc~ommp_full_geomgrad->proc~polelec_geomgrad proc~c_ommp_set_external_field_nomm C_ommp_set_external_field_nomm proc~c_ommp_set_external_field_nomm->proc~ommp_set_external_field proc~c_ommp_set_external_field C_ommp_set_external_field proc~c_ommp_set_external_field->proc~ommp_set_external_field proc~c_ommp_polelec_geomgrad C_ommp_polelec_geomgrad proc~c_ommp_polelec_geomgrad->proc~ommp_polelec_geomgrad proc~c_ommp_full_geomgrad C_ommp_full_geomgrad proc~c_ommp_full_geomgrad->proc~ommp_full_geomgrad proc~c_ommp_get_full_ele_energy C_ommp_get_full_ele_energy proc~c_ommp_get_full_ele_energy->proc~ommp_get_full_ele_energy proc~ommp_get_full_energy ommp_get_full_energy proc~ommp_get_full_energy->proc~ommp_get_full_ele_energy proc~c_ommp_get_full_energy C_ommp_get_full_energy proc~c_ommp_get_full_energy->proc~ommp_get_full_energy

Contents

Source Code


Source Code

    subroutine prepare_polelec(eel, arg_dogg)
        use mod_memory, only: mallocate
        implicit none

        type(ommp_electrostatics_type), intent(inout) :: eel
        logical, optional, intent(in) :: arg_dogg

        logical :: do_gg

        do_gg = .false.
        if(present(arg_dogg)) then
            if(arg_dogg) do_gg = .true.
        end if
        
        if(.not. do_gg .and. eel%M2D_done) return
        if(do_gg .and. eel%M2D_done .and. eel%M2Dgg_done) return
        
        if(.not. allocated(eel%V_M2D) .and. eel%use_fmm) then
            ! This is needed just as a placeholder in fmm calls
            call mallocate('prepare_polelec [V_M2D]', eel%pol_atoms, &
                            eel%n_ipd, eel%V_M2D)
        end if
        
        if(.not. allocated(eel%E_M2D)) then
            call mallocate('prepare_polelec [E_M2D]', 3_ip, eel%pol_atoms, &
                            eel%n_ipd, eel%E_M2D)
        end if
        
        if(do_gg .or. eel%use_fmm) then
            if(.not. eel%ipd_done .and. do_gg) call fatal_error("IPD should be computed &
                &before computing analytical geometrical gradients of &
                &polarization energy.")
            
            if(.not. allocated(eel%Egrd_M2D)) then
                call mallocate('prepare_polelec [Egrd_M2D]', 6_ip, eel%pol_atoms, &
                                eel%n_ipd, eel%Egrd_M2D)
            end if
            
            if(.not. allocated(eel%V_D2D) .and. eel%use_fmm) then
                call mallocate('prepare_polelec [V_D2D]', eel%pol_atoms, &
                               eel%n_ipd, eel%V_D2D)
            end if
            
            if(.not. allocated(eel%E_D2D) .and. eel%use_fmm) then
                call mallocate('prepare_polelec [E_D2D]', 3_ip, eel%pol_atoms, &
                               eel%n_ipd, eel%E_D2D)
            end if
            
            if(.not. allocated(eel%Egrd_D2D)) then
                call mallocate('prepare_polelec [Egrd_D2D]', 6_ip, eel%pol_atoms, &
                               eel%n_ipd, eel%Egrd_D2D)
            end if
            
            if(.not. allocated(eel%EHes_D2D) .and. eel%use_fmm) then
                call mallocate('prepare_polelec [EHes_D2D]', 10_ip, eel%pol_atoms, &
                               eel%n_ipd, eel%EHes_D2D)
            end if
            
            if(.not. allocated(eel%V_D2M) .and. eel%use_fmm) then
                call mallocate('prepare_polelec [V_D2M]', eel%top%mm_atoms, &
                               eel%V_D2M)
            end if
            
            if(.not. allocated(eel%E_D2M)) then
                call mallocate('prepare_polelec [E_D2M]', 3_ip, eel%top%mm_atoms, &
                               eel%E_D2M)
            end if
            if(.not. allocated(eel%Egrd_D2M) .and. eel%amoeba) then
                call mallocate('prepare_polelec [Egrd_D2M]', 6_ip, eel%top%mm_atoms, &
                               eel%Egrd_D2M)
            end if
            if(.not. allocated(eel%EHes_D2M) .and. eel%amoeba) then
                call mallocate('prepare_polelec [E_D2M]', 10_ip, eel%top%mm_atoms, &
                               eel%EHes_D2M)
            end if

        end if
        
        if(.not. do_gg) then
            eel%E_M2D = 0.0_rp
            call elec_prop_M2D(eel, .false., .true., .false., .false.)
        else
            eel%E_M2D = 0.0_rp
            eel%Egrd_M2D = 0.0_rp
            call elec_prop_M2D(eel, .false., .true., .true., .false.)

            eel%E_D2M = 0.0_rp
            eel%Egrd_D2D = 0.0_rp
            
            if(eel%amoeba) then
                eel%Egrd_D2M = 0.0_rp
                eel%EHes_D2M = 0.0_rp
                call elec_prop_D2M(eel, 'P', .false., .true., .true., .true.)
                call elec_prop_D2M(eel, 'D', .false., .true., .true., .true.)
        
                eel%E_D2M = eel%E_D2M * 0.5
                eel%Egrd_D2M = eel%Egrd_D2M * 0.5
                eel%EHes_D2M = eel%EHes_D2M * 0.5

                call elec_prop_D2D(eel, 'P', .false., .false., .true., .false.)
                call elec_prop_D2D(eel, 'D', .false., .false., .true., .false.)
            else
                call elec_prop_D2M(eel, '-', .false., .true., .false., .false.)
                call elec_prop_D2D(eel, '-', .false., .false., .true., .false.)
            end if
        end if
        
        if(do_gg) eel%M2Dgg_done = .true.
        eel%M2D_done = .true.
    end subroutine prepare_polelec