read_atom_cards Subroutine

private subroutine read_atom_cards(top, prm_buf)

Uses

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

Arguments

Type IntentOptional Attributes Name
type(ommp_topology_type), intent(inout) :: top

Topology object

character(len=OMMP_STR_CHAR_MAX), intent(in) :: prm_buf(:)

Calls

proc~~read_atom_cards~~CallsGraph proc~read_atom_cards read_atom_cards proc~fatal_error fatal_error proc~read_atom_cards->proc~fatal_error interface~mallocate mallocate proc~read_atom_cards->interface~mallocate proc~tokenize tokenize proc~read_atom_cards->proc~tokenize proc~isint isint proc~read_atom_cards->proc~isint proc~count_substr_occurence count_substr_occurence proc~read_atom_cards->proc~count_substr_occurence interface~mfree mfree proc~read_atom_cards->interface~mfree proc~ommp_message ommp_message proc~fatal_error->proc~ommp_message proc~close_output close_output proc~fatal_error->proc~close_output proc~r_alloc3 r_alloc3 interface~mallocate->proc~r_alloc3 proc~i_alloc2 i_alloc2 interface~mallocate->proc~i_alloc2 proc~r_alloc1 r_alloc1 interface~mallocate->proc~r_alloc1 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~i_free1 i_free1 interface~mfree->proc~i_free1 proc~l_free1 l_free1 interface~mfree->proc~l_free1 proc~i_free2 i_free2 interface~mfree->proc~i_free2 proc~r_free3 r_free3 interface~mfree->proc~r_free3 proc~r_free1 r_free1 interface~mfree->proc~r_free1 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~i_free2->proc~chk_free proc~r_free3->proc~chk_free proc~r_free1->proc~chk_free proc~chk_alloc chk_alloc proc~r_alloc3->proc~chk_alloc proc~memory_init memory_init proc~r_alloc3->proc~memory_init proc~i_alloc2->proc~chk_alloc proc~i_alloc2->proc~memory_init proc~close_output->proc~ommp_message proc~r_alloc1->proc~chk_alloc proc~r_alloc1->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~r_free2->proc~chk_free proc~l_free2->proc~chk_free proc~i_free3->proc~chk_free proc~chk_free->proc~fatal_error proc~chk_alloc->proc~fatal_error

Called by

proc~~read_atom_cards~~CalledByGraph proc~read_atom_cards read_atom_cards proc~assign_tortors assign_tortors proc~assign_tortors->proc~read_atom_cards proc~assign_angtor assign_angtor proc~assign_angtor->proc~read_atom_cards proc~assign_angle assign_angle proc~assign_angle->proc~read_atom_cards proc~assign_bond assign_bond proc~assign_bond->proc~read_atom_cards proc~assign_urey assign_urey proc~assign_urey->proc~read_atom_cards proc~assign_vdw assign_vdw proc~assign_vdw->proc~read_atom_cards proc~assign_torsion assign_torsion proc~assign_torsion->proc~read_atom_cards proc~assign_strbnd assign_strbnd proc~assign_strbnd->proc~read_atom_cards proc~assign_opb assign_opb proc~assign_opb->proc~read_atom_cards proc~assign_pitors assign_pitors proc~assign_pitors->proc~read_atom_cards proc~assign_imptorsion assign_imptorsion proc~assign_imptorsion->proc~read_atom_cards proc~assign_strtor assign_strtor proc~assign_strtor->proc~read_atom_cards proc~mmpol_init_from_xyz mmpol_init_from_xyz proc~mmpol_init_from_xyz->proc~assign_tortors proc~mmpol_init_from_xyz->proc~assign_angtor proc~mmpol_init_from_xyz->proc~assign_angle proc~mmpol_init_from_xyz->proc~assign_bond proc~mmpol_init_from_xyz->proc~assign_urey proc~mmpol_init_from_xyz->proc~assign_vdw proc~mmpol_init_from_xyz->proc~assign_torsion proc~mmpol_init_from_xyz->proc~assign_strbnd proc~mmpol_init_from_xyz->proc~assign_opb proc~mmpol_init_from_xyz->proc~assign_pitors proc~mmpol_init_from_xyz->proc~assign_imptorsion proc~mmpol_init_from_xyz->proc~assign_strtor proc~ommp_system_from_qm_helper ommp_system_from_qm_helper proc~ommp_system_from_qm_helper->proc~assign_tortors proc~ommp_system_from_qm_helper->proc~assign_angtor proc~ommp_system_from_qm_helper->proc~assign_angle proc~ommp_system_from_qm_helper->proc~assign_bond proc~ommp_system_from_qm_helper->proc~assign_urey proc~ommp_system_from_qm_helper->proc~assign_vdw proc~ommp_system_from_qm_helper->proc~assign_torsion proc~ommp_system_from_qm_helper->proc~assign_strbnd proc~ommp_system_from_qm_helper->proc~assign_opb proc~ommp_system_from_qm_helper->proc~assign_pitors proc~ommp_system_from_qm_helper->proc~assign_imptorsion proc~ommp_system_from_qm_helper->proc~assign_strtor proc~init_bonded_for_link_atom init_bonded_for_link_atom proc~init_bonded_for_link_atom->proc~assign_angle proc~init_bonded_for_link_atom->proc~assign_bond proc~init_bonded_for_link_atom->proc~assign_torsion proc~qm_helper_init_vdw_prm qm_helper_init_vdw_prm proc~qm_helper_init_vdw_prm->proc~assign_vdw proc~ommp_init_xyz ommp_init_xyz proc~ommp_init_xyz->proc~mmpol_init_from_xyz proc~c_ommp_system_from_qm_helper C_ommp_system_from_qm_helper proc~c_ommp_system_from_qm_helper->proc~ommp_system_from_qm_helper proc~c_ommp_qm_helper_init_vdw_prm C_ommp_qm_helper_init_vdw_prm proc~c_ommp_qm_helper_init_vdw_prm->proc~qm_helper_init_vdw_prm proc~ommp_create_link_atom ommp_create_link_atom proc~ommp_create_link_atom->proc~init_bonded_for_link_atom proc~ommp_create_link_atom->proc~qm_helper_init_vdw_prm proc~c_ommp_init_xyz C_ommp_init_xyz proc~c_ommp_init_xyz->proc~ommp_init_xyz proc~c_ommp_create_link_atom C_ommp_create_link_atom proc~c_ommp_create_link_atom->proc~ommp_create_link_atom

Contents

Source Code


Source Code

    subroutine read_atom_cards(top, prm_buf)
        use mod_memory, only: mallocate, mfree
        use mod_io, only: fatal_error
        
        implicit none
        
        type(ommp_topology_type), intent(inout) :: top
        !! Topology object
        character(len=OMMP_STR_CHAR_MAX), intent(in) :: prm_buf(:)

        integer(ip) :: i, il, lc, iat, toke, tokb, tokb1, nquote
        character(len=OMMP_STR_CHAR_MAX) :: line, errstring
        integer(ip) :: natype
        integer(ip), allocatable, dimension(:) :: typez, typeclass
        real(rp), allocatable, dimension(:) :: typemass


        if(.not. top%attype_initialized) then
            call fatal_error("Atom type array in topology should be initialized&
                            & before performing atomclass asignament.")
        end if
        
        ! Read all the lines of file just to count how large vector should be 
        ! allocated 
        natype = 0
        do il=1, size(prm_buf) 
            line = prm_buf(il)
            if(line(:5) == 'atom ') then
                tokb = 6
                toke = tokenize(line, tokb)
                if(.not. isint(line(tokb:toke))) then
                    write(errstring, *) "Wrong ATOM card"
                    call fatal_error(errstring)
                end if
                read(line(tokb:toke), *) iat
                natype = max(natype, iat)
            end if
        end do
       
        call mallocate('read_prm [typeclass]', natype, typeclass)
        call mallocate('read_prm [typez]', natype, typez)
        call mallocate('read_prm [typemass]', natype, typemass)
        typeclass = 0
        typez = 0
        typemass = 0.0

        ! Restart the reading from the beginning to actually save the parameters
        do il=1, size(prm_buf) 
            line = prm_buf(il)
           
            if(line(:5) == 'atom ') then
                tokb = 6
                toke = tokenize(line, tokb)
                if(.not. isint(line(tokb:toke))) then
                    write(errstring, *) "Wrong ATOM card"
                    call fatal_error(errstring)
                end if
                read(line(tokb:toke), *) iat

                tokb = toke+1
                toke = tokenize(line, tokb)
                read(line(tokb:toke), *) typeclass(iat)

                tokb = toke+1
                toke = tokenize(line, tokb)
                ! This token contain the atom name

                tokb = toke+1
                toke = tokenize(line, tokb)
                nquote = count_substr_occurence(line(tokb:toke), '"')
                do while(nquote < 2)
                    tokb1 = toke+1
                    toke = tokenize(line, tokb1)
                    nquote = nquote + count_substr_occurence(line(tokb1:toke), '"')
                end do
                ! This token contains the description string
                tokb = toke+1
                toke = tokenize(line, tokb)
                read(line(tokb:toke), *) typez(iat)
                
                tokb = toke+1
                toke = tokenize(line, tokb)
                read(line(tokb:toke), *) typemass(iat)

                ! Only partial reading of ATOM card is needed for now.
            end if
        end do
        
        !$omp parallel do
        do i = 1, top%mm_atoms
            if(.not. top%atclass_initialized) then
                top%atclass(i) = typeclass(top%attype(i)) 
            end if

            if(.not. top%atz_initialized) then
                top%atz(i) = typez(top%attype(i)) 
            end if
            
            if(.not. top%atmass_initialized) then
                top%atmass(i) = typemass(top%attype(i)) 
            end if
        end do
        
        top%atclass_initialized = .true.
        top%atz_initialized = .true.
        top%atmass_initialized = .true.
        
        call mfree('read_prm [typeclass]', typeclass)
        call mfree('read_prm [typez]', typez)
        call mfree('read_prm [typemass]', typemass)

    end subroutine read_atom_cards