mmpol_init_from_xyz Subroutine

public subroutine mmpol_init_from_xyz(sys_obj, xyz_file, prm_file)

Uses

  • proc~~mmpol_init_from_xyz~~UsesGraph proc~mmpol_init_from_xyz mmpol_init_from_xyz module~mod_electrostatics mod_electrostatics proc~mmpol_init_from_xyz->module~mod_electrostatics module~mod_prm mod_prm proc~mmpol_init_from_xyz->module~mod_prm module~mod_memory mod_memory proc~mmpol_init_from_xyz->module~mod_memory module~mod_constants mod_constants proc~mmpol_init_from_xyz->module~mod_constants module~mod_topology mod_topology proc~mmpol_init_from_xyz->module~mod_topology module~mod_io mod_io proc~mmpol_init_from_xyz->module~mod_io module~mod_adjacency_mat mod_adjacency_mat proc~mmpol_init_from_xyz->module~mod_adjacency_mat module~mod_mmpol mod_mmpol proc~mmpol_init_from_xyz->module~mod_mmpol module~mod_utils mod_utils proc~mmpol_init_from_xyz->module~mod_utils module~mod_electrostatics->module~mod_memory module~mod_electrostatics->module~mod_constants module~mod_electrostatics->module~mod_topology module~mod_electrostatics->module~mod_io module~mod_electrostatics->module~mod_adjacency_mat module~mod_profiling mod_profiling module~mod_electrostatics->module~mod_profiling module~mod_prm->module~mod_electrostatics module~mod_prm->module~mod_memory module~mod_prm->module~mod_constants module~mod_prm->module~mod_topology module~mod_prm->module~mod_io module~mod_prm->module~mod_utils module~mod_bonded mod_bonded module~mod_prm->module~mod_bonded module~mod_memory->module~mod_constants module~mod_memory->module~mod_io iso_c_binding iso_c_binding module~mod_memory->iso_c_binding module~mod_constants->iso_c_binding module~mod_topology->module~mod_memory module~mod_topology->module~mod_adjacency_mat module~mod_io->module~mod_constants module~mod_adjacency_mat->module~mod_memory module~mod_mmpol->module~mod_electrostatics module~mod_mmpol->module~mod_memory module~mod_mmpol->module~mod_constants module~mod_mmpol->module~mod_topology module~mod_mmpol->module~mod_io module~mod_mmpol->module~mod_adjacency_mat module~mod_mmpol->module~mod_bonded module~mod_nonbonded mod_nonbonded module~mod_mmpol->module~mod_nonbonded module~mod_link_atom mod_link_atom module~mod_mmpol->module~mod_link_atom module~mod_utils->module~mod_memory module~mod_utils->module~mod_constants module~mod_profiling->module~mod_memory module~mod_profiling->module~mod_constants module~mod_profiling->module~mod_io module~mod_bonded->module~mod_memory module~mod_bonded->module~mod_topology module~mod_bonded->module~mod_io module~mod_nonbonded->module~mod_memory module~mod_nonbonded->module~mod_constants module~mod_nonbonded->module~mod_topology module~mod_nonbonded->module~mod_adjacency_mat module~mod_neighbor_list mod_neighbor_list module~mod_nonbonded->module~mod_neighbor_list module~mod_link_atom->module~mod_memory module~mod_link_atom->module~mod_constants module~mod_link_atom->module~mod_topology module~mod_link_atom->module~mod_io module~mod_link_atom->module~mod_utils module~mod_link_atom->module~mod_bonded module~mod_link_atom->module~mod_nonbonded module~mod_neighbor_list->module~mod_memory module~mod_neighbor_list->module~mod_io module~mod_neighbor_list->module~mod_adjacency_mat

This function read a Tinker xyz and prm files and initialize all the quantities need to describe the environment within this library.

Arguments

Type IntentOptional Attributes Name
type(ommp_system), intent(inout), target :: sys_obj

The system object to be initialized

character(len=*), intent(in) :: xyz_file

name of the input XYZ file

character(len=*), intent(in) :: prm_file

name of the input PRM file


Calls

proc~~mmpol_init_from_xyz~~CallsGraph proc~mmpol_init_from_xyz mmpol_init_from_xyz proc~assign_angle assign_angle proc~mmpol_init_from_xyz->proc~assign_angle proc~assign_strbnd assign_strbnd proc~mmpol_init_from_xyz->proc~assign_strbnd proc~tokenize_pure tokenize_pure proc~mmpol_init_from_xyz->proc~tokenize_pure proc~isreal isreal proc~mmpol_init_from_xyz->proc~isreal proc~str_uncomment str_uncomment proc~mmpol_init_from_xyz->proc~str_uncomment proc~time_pull time_pull proc~mmpol_init_from_xyz->proc~time_pull proc~ommp_message ommp_message proc~mmpol_init_from_xyz->proc~ommp_message proc~get_prm_ff_type get_prm_ff_type proc~mmpol_init_from_xyz->proc~get_prm_ff_type proc~build_conn_upto_n build_conn_upto_n proc~mmpol_init_from_xyz->proc~build_conn_upto_n proc~assign_mpoles assign_mpoles proc~mmpol_init_from_xyz->proc~assign_mpoles proc~mmpol_init_nonbonded mmpol_init_nonbonded proc~mmpol_init_from_xyz->proc~mmpol_init_nonbonded proc~mmpol_init mmpol_init proc~mmpol_init_from_xyz->proc~mmpol_init proc~fatal_error fatal_error proc~mmpol_init_from_xyz->proc~fatal_error proc~time_push time_push proc~mmpol_init_from_xyz->proc~time_push interface~mfree mfree proc~mmpol_init_from_xyz->interface~mfree proc~assign_imptorsion assign_imptorsion proc~mmpol_init_from_xyz->proc~assign_imptorsion interface~mallocate mallocate proc~mmpol_init_from_xyz->interface~mallocate proc~adj_mat_from_conn adj_mat_from_conn proc~mmpol_init_from_xyz->proc~adj_mat_from_conn proc~assign_torsion assign_torsion proc~mmpol_init_from_xyz->proc~assign_torsion proc~assign_bond assign_bond proc~mmpol_init_from_xyz->proc~assign_bond proc~assign_strtor assign_strtor proc~mmpol_init_from_xyz->proc~assign_strtor proc~check_keyword~2 check_keyword proc~mmpol_init_from_xyz->proc~check_keyword~2 interface~atof atof proc~mmpol_init_from_xyz->interface~atof proc~assign_vdw assign_vdw proc~mmpol_init_from_xyz->proc~assign_vdw proc~check_conn_matrix check_conn_matrix proc~mmpol_init_from_xyz->proc~check_conn_matrix proc~assign_pitors assign_pitors proc~mmpol_init_from_xyz->proc~assign_pitors interface~atoi atoi proc~mmpol_init_from_xyz->interface~atoi proc~assign_tortors assign_tortors proc~mmpol_init_from_xyz->proc~assign_tortors proc~assign_angtor assign_angtor proc~mmpol_init_from_xyz->proc~assign_angtor proc~mmpol_prepare mmpol_prepare proc~mmpol_init_from_xyz->proc~mmpol_prepare proc~assign_pol assign_pol proc~mmpol_init_from_xyz->proc~assign_pol proc~str_to_lower str_to_lower proc~mmpol_init_from_xyz->proc~str_to_lower proc~assign_urey assign_urey proc~mmpol_init_from_xyz->proc~assign_urey proc~mmpol_init_bonded mmpol_init_bonded proc~mmpol_init_from_xyz->proc~mmpol_init_bonded proc~assign_opb assign_opb proc~mmpol_init_from_xyz->proc~assign_opb proc~large_file_read large_file_read proc~mmpol_init_from_xyz->proc~large_file_read proc~assign_angle->proc~isreal proc~assign_angle->proc~ommp_message proc~assign_angle->proc~fatal_error proc~assign_angle->interface~mfree proc~assign_angle->interface~mallocate proc~angle_init angle_init proc~assign_angle->proc~angle_init proc~tokenize tokenize proc~assign_angle->proc~tokenize proc~read_atom_cards read_atom_cards proc~assign_angle->proc~read_atom_cards proc~isint isint proc~assign_angle->proc~isint proc~assign_strbnd->proc~isreal proc~assign_strbnd->proc~fatal_error proc~assign_strbnd->interface~mfree proc~assign_strbnd->interface~mallocate proc~assign_strbnd->proc~tokenize proc~assign_strbnd->proc~read_atom_cards proc~assign_strbnd->proc~isint proc~strbnd_init strbnd_init proc~assign_strbnd->proc~strbnd_init proc~time_pull->proc~ommp_message proc~time_pull->proc~fatal_error proc~mem_stat mem_stat proc~time_pull->proc~mem_stat proc~get_prm_ff_type->proc~tokenize proc~matfree matfree proc~build_conn_upto_n->proc~matfree proc~mat_mult mat_mult proc~build_conn_upto_n->proc~mat_mult proc~mat_andnot mat_andnot proc~build_conn_upto_n->proc~mat_andnot proc~sparse_identity sparse_identity proc~build_conn_upto_n->proc~sparse_identity proc~matcpy matcpy proc~build_conn_upto_n->proc~matcpy proc~assign_mpoles->proc~isreal proc~assign_mpoles->proc~ommp_message proc~assign_mpoles->proc~fatal_error proc~assign_mpoles->interface~mfree proc~assign_mpoles->interface~mallocate proc~assign_mpoles->proc~tokenize proc~set_screening_parameters set_screening_parameters proc~assign_mpoles->proc~set_screening_parameters proc~assign_mpoles->proc~isint proc~mmpol_init->proc~time_pull proc~mmpol_init->proc~fatal_error proc~mmpol_init->proc~time_push proc~topology_init topology_init proc~mmpol_init->proc~topology_init proc~electrostatics_init electrostatics_init proc~mmpol_init->proc~electrostatics_init proc~fatal_error->proc~ommp_message proc~close_output close_output proc~fatal_error->proc~close_output proc~time_push->proc~fatal_error proc~time_push->proc~mem_stat proc~r_free1 r_free1 interface~mfree->proc~r_free1 proc~r_free3 r_free3 interface~mfree->proc~r_free3 proc~i_free1 i_free1 interface~mfree->proc~i_free1 proc~r_free2 r_free2 interface~mfree->proc~r_free2 proc~i_free3 i_free3 interface~mfree->proc~i_free3 proc~l_free2 l_free2 interface~mfree->proc~l_free2 proc~i_free2 i_free2 interface~mfree->proc~i_free2 proc~l_free1 l_free1 interface~mfree->proc~l_free1 proc~assign_imptorsion->proc~isreal proc~assign_imptorsion->proc~fatal_error proc~assign_imptorsion->interface~mfree proc~assign_imptorsion->interface~mallocate proc~assign_imptorsion->proc~tokenize proc~assign_imptorsion->proc~read_atom_cards proc~assign_imptorsion->proc~isint proc~imptorsion_init imptorsion_init proc~assign_imptorsion->proc~imptorsion_init proc~l_alloc2 l_alloc2 interface~mallocate->proc~l_alloc2 proc~i_alloc3 i_alloc3 interface~mallocate->proc~i_alloc3 proc~i_alloc1 i_alloc1 interface~mallocate->proc~i_alloc1 proc~r_alloc1 r_alloc1 interface~mallocate->proc~r_alloc1 proc~r_alloc3 r_alloc3 interface~mallocate->proc~r_alloc3 proc~r_alloc2 r_alloc2 interface~mallocate->proc~r_alloc2 proc~i_alloc2 i_alloc2 interface~mallocate->proc~i_alloc2 proc~l_alloc1 l_alloc1 interface~mallocate->proc~l_alloc1 proc~adj_mat_from_conn->interface~mfree proc~adj_mat_from_conn->interface~mallocate proc~compress_list compress_list proc~adj_mat_from_conn->proc~compress_list proc~sort_ivec_inplace sort_ivec_inplace proc~adj_mat_from_conn->proc~sort_ivec_inplace proc~assign_torsion->proc~isreal proc~assign_torsion->proc~fatal_error proc~assign_torsion->interface~mfree proc~assign_torsion->interface~mallocate proc~assign_torsion->proc~tokenize proc~assign_torsion->proc~read_atom_cards proc~assign_torsion->proc~isint proc~torsion_init torsion_init proc~assign_torsion->proc~torsion_init proc~assign_bond->proc~isreal proc~assign_bond->proc~ommp_message proc~assign_bond->proc~fatal_error proc~assign_bond->interface~mfree proc~assign_bond->interface~mallocate proc~assign_bond->proc~tokenize proc~assign_bond->proc~read_atom_cards proc~assign_bond->proc~isint proc~bond_init bond_init proc~assign_bond->proc~bond_init proc~assign_strtor->proc~isreal proc~assign_strtor->proc~fatal_error proc~assign_strtor->interface~mfree proc~assign_strtor->interface~mallocate proc~assign_strtor->proc~tokenize proc~assign_strtor->proc~read_atom_cards proc~assign_strtor->proc~isint proc~strtor_init strtor_init proc~assign_strtor->proc~strtor_init proc~check_keyword~2->proc~ommp_message proc~check_keyword~2->proc~str_to_lower proc~starts_with_alpha starts_with_alpha proc~check_keyword~2->proc~starts_with_alpha proc~check_keyword~2->proc~tokenize proc~keyword_is_ignored~2 keyword_is_ignored proc~check_keyword~2->proc~keyword_is_ignored~2 proc~keyword_is_recognized~2 keyword_is_recognized proc~check_keyword~2->proc~keyword_is_recognized~2 proc~keyword_is_implemented~2 keyword_is_implemented proc~check_keyword~2->proc~keyword_is_implemented~2 proc~assign_vdw->proc~isreal proc~assign_vdw->proc~fatal_error proc~assign_vdw->interface~mfree proc~assign_vdw->interface~mallocate proc~assign_vdw->proc~tokenize proc~vdw_init vdw_init proc~assign_vdw->proc~vdw_init proc~vdw_set_pair vdw_set_pair proc~assign_vdw->proc~vdw_set_pair proc~assign_vdw->proc~read_atom_cards proc~assign_vdw->proc~isint proc~check_conn_matrix->proc~build_conn_upto_n proc~check_conn_matrix->proc~fatal_error proc~check_conn_matrix->proc~matfree proc~check_conn_matrix->proc~matcpy proc~assign_pitors->proc~isreal proc~assign_pitors->proc~fatal_error proc~assign_pitors->interface~mfree proc~assign_pitors->interface~mallocate proc~assign_pitors->proc~tokenize proc~pitors_init pitors_init proc~assign_pitors->proc~pitors_init proc~assign_pitors->proc~read_atom_cards proc~assign_pitors->proc~isint proc~assign_tortors->proc~isreal proc~assign_tortors->proc~fatal_error proc~assign_tortors->interface~mfree proc~assign_tortors->interface~mallocate proc~tortor_init tortor_init proc~assign_tortors->proc~tortor_init proc~assign_tortors->proc~tokenize proc~tortor_newmap tortor_newmap proc~assign_tortors->proc~tortor_newmap proc~assign_tortors->proc~read_atom_cards proc~assign_tortors->proc~isint proc~assign_angtor->proc~isreal proc~assign_angtor->proc~fatal_error proc~assign_angtor->interface~mfree proc~assign_angtor->interface~mallocate proc~assign_angtor->proc~tokenize proc~assign_angtor->proc~read_atom_cards proc~assign_angtor->proc~isint proc~angtor_init angtor_init proc~assign_angtor->proc~angtor_init proc~mmpol_prepare->proc~time_pull proc~mmpol_prepare->proc~ommp_message proc~mmpol_prepare->proc~build_conn_upto_n proc~mmpol_prepare->proc~time_push proc~remove_null_pol remove_null_pol proc~mmpol_prepare->proc~remove_null_pol proc~build_pg_adjacency_matrix build_pg_adjacency_matrix proc~mmpol_prepare->proc~build_pg_adjacency_matrix proc~thole_init thole_init proc~mmpol_prepare->proc~thole_init proc~rotate_multipoles rotate_multipoles proc~mmpol_prepare->proc~rotate_multipoles proc~mmpol_prepare->proc~matcpy proc~make_screening_lists make_screening_lists proc~mmpol_prepare->proc~make_screening_lists proc~reverse_grp_tab reverse_grp_tab proc~mmpol_prepare->proc~reverse_grp_tab proc~assign_pol->proc~isreal proc~assign_pol->proc~fatal_error proc~assign_pol->interface~mfree proc~assign_pol->interface~mallocate proc~assign_pol->proc~tokenize proc~assign_pol->proc~set_screening_parameters proc~assign_pol->proc~isint proc~assign_urey->proc~isreal proc~assign_urey->proc~fatal_error proc~assign_urey->interface~mfree proc~assign_urey->interface~mallocate proc~assign_urey->proc~tokenize proc~urey_init urey_init proc~assign_urey->proc~urey_init proc~assign_urey->proc~read_atom_cards proc~assign_urey->proc~isint proc~assign_opb->proc~isreal proc~assign_opb->proc~fatal_error proc~assign_opb->interface~mfree proc~assign_opb->interface~mallocate proc~assign_opb->proc~tokenize proc~assign_opb->proc~read_atom_cards proc~assign_opb->proc~isint proc~opb_init opb_init proc~assign_opb->proc~opb_init proc~large_file_read->proc~fatal_error proc~tortor_init->interface~mallocate proc~memory_init memory_init proc~l_alloc2->proc~memory_init proc~chk_alloc chk_alloc proc~l_alloc2->proc~chk_alloc proc~chk_free chk_free proc~r_free1->proc~chk_free proc~r_free3->proc~chk_free proc~angle_init->interface~mallocate proc~reallocate_mat reallocate_mat proc~mat_mult->proc~reallocate_mat proc~i_free1->proc~chk_free proc~set_screening_parameters->proc~fatal_error proc~r_free2->proc~chk_free proc~i_free3->proc~chk_free proc~remove_null_pol->proc~ommp_message proc~remove_null_pol->interface~mfree proc~remove_null_pol->interface~mallocate proc~urey_init->interface~mallocate proc~build_pg_adjacency_matrix->proc~reallocate_mat proc~i_alloc3->proc~memory_init proc~i_alloc3->proc~chk_alloc proc~l_free2->proc~chk_free proc~i_alloc1->proc~memory_init proc~i_alloc1->proc~chk_alloc proc~compress_list->interface~mfree proc~compress_list->interface~mallocate proc~vdw_init->proc~fatal_error proc~vdw_init->interface~mallocate proc~nl_init nl_init proc~vdw_init->proc~nl_init proc~vdw_set_pair->interface~mfree proc~vdw_set_pair->interface~mallocate proc~pitors_init->interface~mallocate proc~r_alloc1->proc~memory_init proc~r_alloc1->proc~chk_alloc proc~tortor_newmap->interface~mfree proc~tortor_newmap->interface~mallocate proc~cyclic_spline cyclic_spline proc~tortor_newmap->proc~cyclic_spline proc~topology_init->interface~mallocate proc~thole_init->proc~ommp_message proc~thole_init->proc~fatal_error proc~rotation_matrix rotation_matrix proc~rotate_multipoles->proc~rotation_matrix proc~mat_andnot->proc~reallocate_mat proc~i_free2->proc~chk_free proc~read_atom_cards->proc~fatal_error proc~read_atom_cards->interface~mfree proc~read_atom_cards->interface~mallocate proc~read_atom_cards->proc~tokenize proc~read_atom_cards->proc~isint proc~count_substr_occurence count_substr_occurence proc~read_atom_cards->proc~count_substr_occurence proc~strbnd_init->interface~mallocate proc~mem_stat->proc~memory_init proc~electrostatics_init->interface~mallocate proc~close_output->proc~ommp_message proc~l_free1->proc~chk_free proc~sort_ivec_inplace->interface~mfree proc~sort_ivec sort_ivec proc~sort_ivec_inplace->proc~sort_ivec proc~make_screening_lists->interface~mfree proc~make_screening_lists->interface~mallocate proc~make_screening_lists->proc~compress_list proc~screening_rules screening_rules proc~make_screening_lists->proc~screening_rules proc~compress_data compress_data proc~make_screening_lists->proc~compress_data proc~imptorsion_init->interface~mallocate proc~r_alloc3->proc~memory_init proc~r_alloc3->proc~chk_alloc proc~r_alloc2->proc~memory_init proc~r_alloc2->proc~chk_alloc proc~reverse_grp_tab->interface~mfree proc~reverse_grp_tab->interface~mallocate proc~reverse_grp_tab->proc~compress_list proc~i_alloc2->proc~memory_init proc~i_alloc2->proc~chk_alloc proc~torsion_init->interface~mallocate proc~opb_init->proc~ommp_message proc~opb_init->proc~fatal_error proc~opb_init->interface~mallocate proc~strtor_init->interface~mallocate proc~l_alloc1->proc~memory_init proc~l_alloc1->proc~chk_alloc proc~angtor_init->interface~mallocate proc~bond_init->interface~mallocate proc~screening_rules->proc~fatal_error proc~chk_free->proc~fatal_error proc~nl_init->proc~fatal_error proc~nl_init->interface~mallocate proc~nl_update nl_update proc~nl_init->proc~nl_update proc~chk_alloc->proc~fatal_error proc~cyclic_spline->interface~mfree proc~cyclic_spline->interface~mallocate dgetrf dgetrf proc~cyclic_spline->dgetrf dgetri dgetri proc~cyclic_spline->dgetri dgemm dgemm proc~cyclic_spline->dgemm proc~rotation_matrix->proc~fatal_error proc~sort_ivec->interface~mfree proc~sort_ivec->interface~mallocate proc~compress_data->interface~mallocate proc~nl_update->proc~time_pull proc~nl_update->proc~ommp_message proc~nl_update->proc~time_push proc~nl_update->interface~mfree proc~nl_update->proc~reverse_grp_tab

Called by

proc~~mmpol_init_from_xyz~~CalledByGraph proc~mmpol_init_from_xyz mmpol_init_from_xyz proc~ommp_init_xyz ommp_init_xyz proc~ommp_init_xyz->proc~mmpol_init_from_xyz proc~c_ommp_init_xyz C_ommp_init_xyz proc~c_ommp_init_xyz->proc~ommp_init_xyz

Contents

Source Code


Source Code

    subroutine mmpol_init_from_xyz(sys_obj, xyz_file, prm_file)
        !! This function read a Tinker xyz and prm files
        !! and initialize all the quantities need to describe the environment
        !! within this library.
        use mod_mmpol, only: mmpol_prepare, mmpol_init, mmpol_init_nonbonded, &
                             mmpol_init_bonded
        use mod_topology, only: ommp_topology_type, check_conn_matrix
        use mod_electrostatics, only: ommp_electrostatics_type
        
        use mod_memory, only: ip, mfree, mallocate, memory_init
        use mod_constants, only: angstrom2au, OMMP_VERBOSE_DEBUG
        use mod_adjacency_mat, only: adj_mat_from_conn, yale_sparse, &
                                     build_conn_upto_n
        use mod_prm, only: check_keyword, assign_pol, assign_mpoles, &
                           assign_vdw, assign_bond, assign_angle, assign_urey, &
                           assign_strbnd, assign_opb, assign_pitors, &
                           assign_torsion, assign_tortors, assign_angtor, &
                           assign_strtor, assign_imptorsion, get_prm_ff_type
        use mod_utils, only: starts_with_alpha, isreal, isint, &
                             str_to_lower, str_uncomment, &
                             tokenize_pure, atoi, atof
        use mod_io, only: large_file_read

        implicit none

        type(ommp_system), intent(inout), target :: sys_obj
        !! The system object to be initialized
        character(len=*), intent(in) :: xyz_file
        !! name of the input XYZ file
        character(len=*), intent(in) :: prm_file
        !! name of the input PRM file

        integer(ip), parameter :: iof_xyzinp = 200, &
                                  maxn12 = 8
        integer(ip) :: my_mm_atoms, ist, i, j, atom_id, lc, tokx(2)
        integer(ip), allocatable :: i12(:,:), attype(:)
        character(len=OMMP_STR_CHAR_MAX) :: msg
        character(len=OMMP_STR_CHAR_MAX), allocatable :: lines(:), prm_buf(:)
        logical :: fex
        type(yale_sparse) :: adj
        type(ommp_topology_type), pointer :: top
        type(ommp_electrostatics_type), pointer :: eel

        call time_push()
        call time_push()
        ! Check that files are present
        inquire(file=prm_file(1:len(trim(prm_file))), exist=fex)
        if(.not. fex) then
            call fatal_error("Input file '"//&
                &prm_file(1:len(trim(prm_file)))//"' does not exist.")
        end if

        inquire(file=xyz_file(1:len(trim(xyz_file))), exist=fex)
        if(.not. fex) then
            call fatal_error("Input file '"//&
                &xyz_file(1:len(trim(xyz_file)))//"' does not exist.")
        end if

        write(msg, "(A)") "Reading XYZ file: "//xyz_file(1:len(trim(xyz_file)))
        call ommp_message(msg, OMMP_VERBOSE_DEBUG)
        
        ! read tinker xyz file
        call time_push()
        call large_file_read(xyz_file, lines)
        call time_pull('XYZ File reading')
        call large_file_read(prm_file, prm_buf)
        ! Remove comments from prm file
        !$omp parallel do
        do i=1, size(prm_buf)
            prm_buf(i) = str_to_lower(prm_buf(i))
            prm_buf(i) = str_uncomment(prm_buf(i), '!')
        end do
        
        ! First line contains as first word the number of atoms and
        ! then a comment that could be ignored.
        read(lines(1), *) my_mm_atoms
        
        ! Initialize the mmpol module
        ! TODO I'm assuming that it is AMOEBA and fully polarizable
        
        call mmpol_init(sys_obj, get_prm_ff_type(prm_buf), &
                        my_mm_atoms, my_mm_atoms)
        ! Those are just shortcut
        top => sys_obj%top
        eel => sys_obj%eel

        ! Temporary quantities that are only used during the initialization
        call mallocate('mmpol_init_from_xyz [attype]', my_mm_atoms, attype)
        call mallocate('mmpol_init_from_xyz [i12]', maxn12, my_mm_atoms, i12)
       
        call time_push()
        !$omp parallel do default(shared) private(i, lc, tokx) &
        !$omp private(atom_id, j)
        do i=1, my_mm_atoms
            lc = i+1
            
            ! Initializations
            attype(i) = 0_ip
            i12(:,i) = 0_ip
            eel%polar_mm(i) = i
            eel%pol(i) = 0.0

            ! First token contains an atom ID. Only sequential numbering is
            ! currently supported.
            !dir$ forceinline
            tokx = tokenize_pure(lines(lc))
            !dir$ forceinline
            tokx = tokenize_pure(lines(lc), tokx(2))

            atom_id = atoi(lines(lc)(tokx(1):tokx(2)))
            if(atom_id /= i) then
                call fatal_error('Non-sequential atom ids in xyz cannot be handled')
            end if
            
            ! This token should contain an atom name, so it should start
            ! with a letter. If this is not true, an unexpected error should
            ! be raised.
            !dir$ forceinline
            tokx = tokenize_pure(lines(lc), tokx(2)+1)
            if(isreal(lines(lc)(tokx(1):tokx(2)))) then
                call fatal_error('Atom symbol missing (or completely numerical) or PBC string present in XYZ')
            end if

            ! The remaining part contains cartesian coordinates, atom type
            ! and connectivity for the current atom.
            do j=1, 3
                ! Read coordinates and convert to angstrom
                !dir$ forceinline
                tokx = tokenize_pure(lines(lc), tokx(2)+1)
                top%cmm(j,i) = atof(lines(lc)(tokx(1):tokx(2))) * angstrom2au
            end do
            
            !dir$ forceinline
            tokx = tokenize_pure(lines(lc), tokx(2)+1)
            attype(i) = atoi(lines(lc)(tokx(1):tokx(2)))

            do j=1, maxn12
                !dir$ forceinline
                tokx = tokenize_pure(lines(lc), tokx(2)+1)
                if(tokx(2) < 0) exit
                i12(j,i) = atoi(lines(lc)(tokx(1):tokx(2)))
            end do
        end do
        deallocate(lines)
        call time_pull('Interpreting XYZ')

        ! Writes the adjacency matrix in Yale sparse format in adj and then
        ! build the connectivity up to 4th order. This is needed here to be
        ! able to assign the parameters
        
        call adj_mat_from_conn(i12, adj)
        call build_conn_upto_n(adj, 4, top%conn, .false.)

        call mfree('mmpol_init_from_xyz [i12]', i12)
        
        if( .not. check_keyword(prm_buf)) then
            call fatal_error("PRM file cannot be completely understood")
        end if
        call time_pull("XYZ reading and topology generation")

        top%attype = attype
        top%attype_initialized = .true.
        call mfree('mmpol_init_from_xyz [attype]', attype)
       
        call time_push()
        call ommp_message("Assigning electrostatic parameters", OMMP_VERBOSE_DEBUG)
        call assign_pol(eel, prm_buf)
        call assign_mpoles(eel, prm_buf)
        
        call ommp_message("Assigning non-bonded parameters", OMMP_VERBOSE_DEBUG)
        call mmpol_init_nonbonded(sys_obj)
        call assign_vdw(sys_obj%vdw, top, prm_buf)
        
        call ommp_message("Assigning bonded parameters", OMMP_VERBOSE_DEBUG)
        call mmpol_init_bonded(sys_obj)
        call check_conn_matrix(sys_obj%top, 4)
        call assign_bond(sys_obj%bds, prm_buf)
        call assign_angle(sys_obj%bds, prm_buf)
        call assign_urey(sys_obj%bds, prm_buf)
        call assign_strbnd(sys_obj%bds, prm_buf)
        call assign_opb(sys_obj%bds, prm_buf)
        call assign_pitors(sys_obj%bds, prm_buf)
        call assign_torsion(sys_obj%bds, prm_buf)
        call assign_imptorsion(sys_obj%bds, prm_buf)
        call assign_tortors(sys_obj%bds, prm_buf)
        call assign_angtor(sys_obj%bds, prm_buf)
        call assign_strtor(sys_obj%bds, prm_buf)
        call time_pull('Total prm assignament')

        deallocate(prm_buf)

        call mmpol_prepare(sys_obj)
        call time_pull('MMPol initialization from .xyz file')

    end subroutine mmpol_init_from_xyz